Browse / github.com/storytold/artcraft / patch
Fix Linux transparent window rendering ISSUE 2514
Fix Linux transparent window rendering ISSUE 2514 The main window currently uses a fully transparent background, which may contribute to the UI repaint issue reported on Linux with WebKitGTK and NVIDIA drivers. This change sets an opaque, near-black background on Linux while preserving the existing transparent background behavior on macOS and Windows. Testing Rust formatting check passes. cargo check passes. Verify that the UI remains visible after repeated repaints on the affected Linux/NVIDIA environment. Confirm that existing window behavior remains unchanged on macOS and Windows. This is a targeted workaround to investigate the ren
- Status
- open
- Score
- 0.00
- Adopters
- 0 other operators
- Author
- Daviz8 (imported from pull request #2539, open)
- Base
7a2935cf9e3922e90e4ed5f3556b1cb107013148- Size
- +85 −79 in 1 file
- Review
- pending
- Shared
- 2026-10-28
- Id
2e8144f3308c10a05ca948b3
How it went
No other operator has reported using it yet.
Diff
raw · crates/desktop/artcraft/src/core/lifecycle/startup/setup_main_window.rs
@@ -1,99 +1,105 @@+ use crate::core::windows::main_window::constants::MAIN_WINDOW_NAME; use errors::AnyhowResult; use tauri::window::Color; use tauri::{AppHandle, TitleBarStyle, WebviewUrl, WebviewWindowBuilder}; -pub async fn setup_main_window(- app: &AppHandle,-) -> AnyhowResult<()> {+pub async fn setup_main_window(app: &AppHandle) -> AnyhowResult<()> {+ let win_builder =+ WebviewWindowBuilder::new(app, MAIN_WINDOW_NAME, WebviewUrl::default())+ .title("ArtCraft")+ .resizable(true)+ .fullscreen(false)+ .enable_clipboard_access()+ .inner_size(2400.0, 1300.0);++ // Linux: use an opaque background to avoid potential transparent-surface+ // rendering problems with WebKitGTK on some Linux/NVIDIA configurations.+ #[cfg(target_os = "linux")]+ let win_builder = win_builder.background_color(Color(9, 9, 11, 255)); - let win_builder =- WebviewWindowBuilder::new(app, MAIN_WINDOW_NAME, WebviewUrl::default())- .title("ArtCraft")- .resizable(true)- .fullscreen(false)- .background_color(Color(0, 0, 0, 0))- .enable_clipboard_access()- .inner_size(2400.0, 1300.0);+ // Preserve existing transparent background behavior on other platforms.+ #[cfg(not(target_os = "linux"))]+ let win_builder = win_builder.background_color(Color(0, 0, 0, 0)); - #[cfg(target_os = "macos")]- let win_builder = win_builder- .decorations(true) // NB: Mac requires decorations. Tons of capabilities disappear otherwise.- .title_bar_style(TitleBarStyle::Overlay)- .hidden_title(true)- .accept_first_mouse(true) // https://github.com/tauri-apps/tauri/issues/11605#issuecomment-2460112096- .focusable(true)- .focused(true);+ #[cfg(target_os = "macos")]+ let win_builder = win_builder+ .decorations(true) // NB: Mac requires decorations. Tons of capabilities disappear otherwise.+ .title_bar_style(TitleBarStyle::Overlay)+ .hidden_title(true)+ .accept_first_mouse(true) // https://github.com/tauri-apps/tauri/issues/11605#issuecomment-2460112096+ .focusable(true)+ .focused(true); - // NB: Setting decorations(false) "breaks" Mac, though I never documented how/why.- // NB: On Linux, setting decorations(false) will cause the window to be unable to be- // resized, despite the arrow cursor indicating resize is possible. This might be- // fixable another way, but for now it seems fine to disable this. There also seem to- // be some performance loss with decorations(false), but I might be imagining it.- #[cfg(target_os = "windows")]- let win_builder = win_builder- .decorations(false); // NB: This breaks Mac! (And breaks resize on Linux)+ // NB: Setting decorations(false) "breaks" Mac, though I never documented how/why.+ // NB: On Linux, setting decorations(false) will cause the window to be unable to be+ // resized, despite the arrow cursor indicating resize is possible. This might be+ // fixable another way, but for now it seems fine to disable this. There also seem to+ // be some performance loss with decorations(false), but I might be imagining it.+ #[cfg(target_os = "windows")]+ let win_builder = win_builder.decorations(false); // NB: This breaks Mac! (And breaks resize on Linux) - // On macOS, Cmd+A/C/V/X/Z and friends are dispatched by AppKit through the application- // menu. Without an Edit submenu containing the standard predefined items, these- // shortcuts never reach the WKWebView and text inputs behave as if Cmd is unmapped.- #[cfg(target_os = "macos")]- install_macos_app_menu(app)?;+ // On macOS, Cmd+A/C/V/X/Z and friends are dispatched by AppKit through the application+ // menu. Without an Edit submenu containing the standard predefined items, these+ // shortcuts never reach the WKWebView and text inputs behave as if Cmd is unmapped.+ #[cfg(target_os = "macos")]+ install_macos_app_menu(app)?; - let _window = win_builder.build()?;+ let _window = win_builder.build()?; - Ok(())+ Ok(()) } #[cfg(target_os = "macos")] fn install_macos_app_menu(app: &AppHandle) -> AnyhowResult<()> {- use tauri::menu::{Menu, PredefinedMenuItem, Submenu};+ use tauri::menu::{Menu, PredefinedMenuItem, Submenu};++ let app_submenu = Submenu::with_items(+ app,+ "ArtCraft",+ true,+ &[+ &PredefinedMenuItem::about(app, None, None)?,+ &PredefinedMenuItem::separator(app)?,+ &PredefinedMenuItem::services(app, None)?,+ &PredefinedMenuItem::separator(app)?,+ &PredefinedMenuItem::hide(app, None)?,+ &PredefinedMenuItem::hide_others(app, None)?,+ &PredefinedMenuItem::show_all(app, None)?,+ &PredefinedMenuItem::separator(app)?,+ &PredefinedMenuItem::quit(app, None)?,+ ],+ )?; - let app_submenu = Submenu::with_items(- app,- "ArtCraft",- true,- &[- &PredefinedMenuItem::about(app, None, None)?,- &PredefinedMenuItem::separator(app)?,- &PredefinedMenuItem::services(app, None)?,- &PredefinedMenuItem::separator(app)?,- &PredefinedMenuItem::hide(app, None)?,- &PredefinedMenuItem::hide_others(app, None)?,- &PredefinedMenuItem::show_all(app, None)?,- &PredefinedMenuItem::separator(app)?,- &PredefinedMenuItem::quit(app, None)?,- ],- )?;+ let edit_submenu = Submenu::with_items(+ app,+ "Edit",+ true,+ &[+ &PredefinedMenuItem::undo(app, None)?,+ &PredefinedMenuItem::redo(app, None)?,+ &PredefinedMenuItem::separator(app)?,+ &PredefinedMenuItem::cut(app, None)?,+ &PredefinedMenuItem::copy(app, None)?,+ &PredefinedMenuItem::paste(app, None)?,+ &PredefinedMenuItem::select_all(app, None)?,+ ],+ )?; - let edit_submenu = Submenu::with_items(- app,- "Edit",- true,- &[- &PredefinedMenuItem::undo(app, None)?,- &PredefinedMenuItem::redo(app, None)?,- &PredefinedMenuItem::separator(app)?,- &PredefinedMenuItem::cut(app, None)?,- &PredefinedMenuItem::copy(app, None)?,- &PredefinedMenuItem::paste(app, None)?,- &PredefinedMenuItem::select_all(app, None)?,- ],- )?;+ let window_submenu = Submenu::with_items(+ app,+ "Window",+ true,+ &[+ &PredefinedMenuItem::minimize(app, None)?,+ &PredefinedMenuItem::maximize(app, None)?,+ &PredefinedMenuItem::separator(app)?,+ &PredefinedMenuItem::close_window(app, None)?,+ ],+ )?; - let window_submenu = Submenu::with_items(- app,- "Window",- true,- &[- &PredefinedMenuItem::minimize(app, None)?,- &PredefinedMenuItem::maximize(app, None)?,- &PredefinedMenuItem::separator(app)?,- &PredefinedMenuItem::close_window(app, None)?,- ],- )?;+ let menu = Menu::with_items(app, &[&app_submenu, &edit_submenu, &window_submenu])?;+ app.set_menu(menu)?; - let menu = Menu::with_items(app, &[&app_submenu, &edit_submenu, &window_submenu])?;- app.set_menu(menu)?;- Ok(())+ Ok(()) }