diff --git a/src-tauri/src/config/graphics_settings.rs b/src-tauri/src/config/graphics_settings.rs index f88f8e43c..7a7725b58 100644 --- a/src-tauri/src/config/graphics_settings.rs +++ b/src-tauri/src/config/graphics_settings.rs @@ -15,6 +15,37 @@ use rusqlite::{Connection, params}; use serde::{Deserialize, Serialize}; use std::sync::{Arc, Mutex}; +use std::sync::atomic::{AtomicBool, Ordering}; + +// --- Global startup state (set once in main.rs, read-only thereafter) --- +static GRAPHICS_USING_FALLBACK: AtomicBool = AtomicBool::new(false); +static GRAPHICS_IS_WAYLAND: AtomicBool = AtomicBool::new(false); +static GRAPHICS_HAS_NVIDIA: AtomicBool = AtomicBool::new(false); +static GRAPHICS_IS_VM: AtomicBool = AtomicBool::new(false); +static GRAPHICS_HW_ACCEL: AtomicBool = AtomicBool::new(true); +static GRAPHICS_FORCE_X11: AtomicBool = AtomicBool::new(false); + +/// Set startup graphics state (called once from main.rs) +pub fn set_startup_graphics_state( + using_fallback: bool, + is_wayland: bool, + has_nvidia: bool, + is_vm: bool, + hw_accel: bool, + force_x11: bool, +) { + GRAPHICS_USING_FALLBACK.store(using_fallback, Ordering::SeqCst); + GRAPHICS_IS_WAYLAND.store(is_wayland, Ordering::SeqCst); + GRAPHICS_HAS_NVIDIA.store(has_nvidia, Ordering::SeqCst); + GRAPHICS_IS_VM.store(is_vm, Ordering::SeqCst); + GRAPHICS_HW_ACCEL.store(hw_accel, Ordering::SeqCst); + GRAPHICS_FORCE_X11.store(force_x11, Ordering::SeqCst); +} + +/// Check if graphics is using fallback defaults (for UI warning) +pub fn is_using_graphics_fallback() -> bool { + GRAPHICS_USING_FALLBACK.load(Ordering::SeqCst) +} #[derive(Debug, Clone, Serialize, Deserialize)] pub struct GraphicsSettings { @@ -209,3 +240,36 @@ pub fn set_gdk_dpi_scale( let store = guard.as_ref().ok_or("Graphics settings store not initialized")?; store.set_gdk_dpi_scale(value) } + +// --- Startup Status (set once at app launch, read-only thereafter) --- + +/// Tracks graphics configuration status from startup +/// Used to show warnings in UI when settings failed to load +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct GraphicsStartupStatus { + /// True if graphics settings failed to load from DB (using safe defaults) + pub using_fallback: bool, + /// True if running on Wayland + pub is_wayland: bool, + /// True if NVIDIA GPU was detected + pub has_nvidia: bool, + /// True if running in a virtual machine + pub is_vm: bool, + /// True if hardware acceleration is enabled + pub hardware_accel_enabled: bool, + /// True if force_x11 is active + pub force_x11_active: bool, +} + +/// Get graphics startup status (reads from static atomics set in main.rs) +#[tauri::command] +pub fn get_graphics_startup_status() -> GraphicsStartupStatus { + GraphicsStartupStatus { + using_fallback: GRAPHICS_USING_FALLBACK.load(Ordering::SeqCst), + is_wayland: GRAPHICS_IS_WAYLAND.load(Ordering::SeqCst), + has_nvidia: GRAPHICS_HAS_NVIDIA.load(Ordering::SeqCst), + is_vm: GRAPHICS_IS_VM.load(Ordering::SeqCst), + hardware_accel_enabled: GRAPHICS_HW_ACCEL.load(Ordering::SeqCst), + force_x11_active: GRAPHICS_FORCE_X11.load(Ordering::SeqCst), + } +} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 20e9e3296..a529a7106 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1002,6 +1002,7 @@ pub fn run() { config::developer_settings::set_developer_force_dmabuf, // Graphics settings commands config::graphics_settings::get_graphics_settings, + config::graphics_settings::get_graphics_startup_status, config::graphics_settings::set_hardware_acceleration, config::graphics_settings::set_force_x11, config::graphics_settings::set_gdk_scale, diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 618698092..00ff6bc1e 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -280,6 +280,16 @@ fn main() { is_wayland, has_nvidia, force_x11, hardware_accel, graphics_using_fallback )); + // Store startup state for frontend queries + qbz_nix_lib::config::graphics_settings::set_startup_graphics_state( + graphics_using_fallback, + is_wayland, + has_nvidia, + is_vm, + hardware_accel, + force_x11, + ); + // --- Software rendering (GL layer) --- // LIBGL_ALWAYS_SOFTWARE=1 forces Mesa to use llvmpipe for all GL contexts. // Only for VMs or explicit user request. diff --git a/src/lib/components/views/SettingsView.svelte b/src/lib/components/views/SettingsView.svelte index 4493e1bfc..8722d3447 100644 --- a/src/lib/components/views/SettingsView.svelte +++ b/src/lib/components/views/SettingsView.svelte @@ -268,6 +268,10 @@ let gdkScale = $state(''); let gdkDpiScale = $state(''); let compositionCollapsed = $state(true); + // Graphics startup status (for showing degraded mode warning) + let graphicsUsingFallback = $state(false); + let graphicsIsWayland = $state(false); + let graphicsHasNvidia = $state(false); let showLogsModal = $state(false); // Navigation section IDs with translation keys @@ -901,6 +905,13 @@ gdkDpiScale = settings.gdk_dpi_scale || ''; }).catch(() => {}); + // Load graphics startup status (for fallback warning) + invoke('get_graphics_startup_status').then((status: any) => { + graphicsUsingFallback = status.using_fallback; + graphicsIsWayland = status.is_wayland; + graphicsHasNvidia = status.has_nvidia; + }).catch(() => {}); + // Subscribe to offline state changes const unsubscribeOffline = subscribeOffline(() => { offlineStatus = getOfflineStatus(); @@ -3267,6 +3278,17 @@ {#if !compositionCollapsed}

{$t('settings.appearance.composition.helpText')}

+ {#if graphicsUsingFallback} +
+ +
+ {$t('settings.appearance.composition.fallbackWarning')} + {$t('settings.appearance.composition.fallbackDesc')} + qbz --reset-graphics +
+
+ {/if} +
@@ -4807,6 +4829,28 @@ flatpak override --user --filesystem=/home/USUARIO/Música com.blitzfc.qbz margin-top: 1px; } + /* Fallback warning (more prominent - red/error style) */ + .composition-warning.fallback-warning { + background: rgba(239, 68, 68, 0.1); + border-color: rgba(239, 68, 68, 0.3); + } + + .composition-warning.fallback-warning :global(svg) { + color: #ef4444; + } + + .fallback-title { + display: block; + font-weight: 600; + color: #ef4444; + margin-bottom: 2px; + } + + .fallback-desc { + display: block; + color: var(--text-secondary); + } + .recovery-cmd { display: block; margin-top: 4px; diff --git a/src/lib/i18n/locales/de.json b/src/lib/i18n/locales/de.json index ea75f30d4..641c5399c 100644 --- a/src/lib/i18n/locales/de.json +++ b/src/lib/i18n/locales/de.json @@ -663,6 +663,8 @@ "helpText": "Diese Einstellungen steuern, wie QBZ die Benutzeroberflaeche rendert. Falsche Einstellungen koennen zu Abstuerzen oder schlechter Leistung fuehren. Alle Optionen erfordern einen Neustart.", "recoveryNote": "Falls QBZ nach dem Aendern dieser Einstellungen abstuerzt, starte vom Terminal mit:", "recoveryCmd": "QBZ_HARDWARE_ACCEL=0 qbz", + "fallbackWarning": "Grafikeinstellungen konnten nicht geladen werden", + "fallbackDesc": "Sichere Standardwerte werden verwendet. Dies kann zu verringerter Leistung fuehren. Zum Zuruecksetzen:", "forceX11": "X11-Backend erzwingen (Wayland)", "forceX11Desc": "XWayland statt nativem Wayland verwenden. Empfohlen fuer NVIDIA-GPUs mit Wayland-Abstuerzen.", "gdkScale": "Anzeigeskalierung (XWayland)", diff --git a/src/lib/i18n/locales/en.json b/src/lib/i18n/locales/en.json index a7b4e9370..4538f1a54 100644 --- a/src/lib/i18n/locales/en.json +++ b/src/lib/i18n/locales/en.json @@ -673,6 +673,8 @@ "helpText": "These settings control how QBZ renders the UI. Incorrect settings may cause crashes or poor performance. All options require a restart to take effect.", "recoveryNote": "If QBZ crashes after changing these settings, launch from terminal with:", "recoveryCmd": "QBZ_HARDWARE_ACCEL=0 qbz", + "fallbackWarning": "Graphics settings failed to load", + "fallbackDesc": "Using safe defaults. This may cause degraded performance. To reset:", "forceX11": "Force X11 backend (Wayland)", "forceX11Desc": "Use XWayland instead of native Wayland. Recommended for NVIDIA GPUs that crash on Wayland.", "gdkScale": "Display scale (XWayland)", diff --git a/src/lib/i18n/locales/es.json b/src/lib/i18n/locales/es.json index c806a5122..aa7409c10 100644 --- a/src/lib/i18n/locales/es.json +++ b/src/lib/i18n/locales/es.json @@ -673,6 +673,8 @@ "helpText": "Estos ajustes controlan como QBZ renderiza la interfaz. Una configuracion incorrecta puede causar crashes o bajo rendimiento. Todas las opciones requieren reiniciar.", "recoveryNote": "Si QBZ crashea despues de cambiar estos ajustes, ejecuta desde terminal:", "recoveryCmd": "QBZ_HARDWARE_ACCEL=0 qbz", + "fallbackWarning": "Los ajustes graficos no se pudieron cargar", + "fallbackDesc": "Usando valores predeterminados seguros. Esto puede causar rendimiento degradado. Para resetear:", "forceX11": "Forzar X11 (Wayland)", "forceX11Desc": "Usar XWayland en lugar de Wayland nativo. Recomendado para GPUs NVIDIA con crashes en Wayland.", "gdkScale": "Escala de pantalla (XWayland)", diff --git a/src/lib/i18n/locales/fr.json b/src/lib/i18n/locales/fr.json index 66cfe1f79..adf630e26 100644 --- a/src/lib/i18n/locales/fr.json +++ b/src/lib/i18n/locales/fr.json @@ -663,6 +663,8 @@ "helpText": "Ces parametres controlent comment QBZ rend l'interface. Des parametres incorrects peuvent causer des crashes ou une mauvaise performance. Toutes les options necessitent un redemarrage.", "recoveryNote": "Si QBZ plante apres avoir modifie ces parametres, lancez depuis le terminal avec :", "recoveryCmd": "QBZ_HARDWARE_ACCEL=0 qbz", + "fallbackWarning": "Les parametres graphiques n'ont pas pu etre charges", + "fallbackDesc": "Utilisation des valeurs par defaut securisees. Cela peut causer une performance degradee. Pour reinitialiser :", "forceX11": "Forcer le backend X11 (Wayland)", "forceX11Desc": "Utiliser XWayland au lieu du Wayland natif. Recommande pour les GPU NVIDIA avec des crashes sous Wayland.", "gdkScale": "Echelle d'affichage (XWayland)",