Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(linux): keep opaque main window on GNOME X11 sessions (#12750)

technicalorsd030f4276f79
diff --git a/docs/content/docs/faq.cn.mdx b/docs/content/docs/faq.cn.mdx
index 07fe54f69b..c197c32a8f 100644
--- a/docs/content/docs/faq.cn.mdx
+++ b/docs/content/docs/faq.cn.mdx
@@ -35,15 +35,15 @@ description: DBX 常见问题:连接数据保存在哪里、如何备份、如
## Linux 窗口闪烁或内容消失
-在 GNOME 且系统已开启窗口合成时,Linux 主窗口会绘制带圆角、阴影的浮动边框;在其他桌面(KDE、XFCE、Cinnamon 等)默认使用不透明背景,避免部分显卡驱动与 WebKitGTK 的透明窗口合成兼容问题。两种模式都不会关闭 GPU 加速或改变 Wayland/X11 后端。
+在 GNOME 的 Wayland 会话中且系统已开启窗口合成时,Linux 主窗口会绘制带圆角、阴影的浮动边框;X11 下的 GNOME(“GNOME on Xorg”)以及其他桌面(KDE、XFCE、Cinnamon 等)默认使用不透明背景,避免部分显卡驱动与 WebKitGTK 的透明窗口合成兼容问题。两种模式都不会关闭 GPU 加速或改变 Wayland/X11 后端。
-可以通过环境变量覆盖默认行为。在其他桌面强制启用浮动边框:
+可以通过环境变量覆盖默认行为。在 X11 或其他桌面强制启用浮动边框:
```bash
DBX_LINUX_FLOATING_FRAME=1 dbx
```
-若在 GNOME 上出现闪烁、内容消失或必须缩放窗口才能重绘,请完全退出 DBX(包括托盘),并使用 `DBX_LINUX_FLOATING_FRAME=0 dbx` 重新启动以强制使用不透明窗口。没有窗口合成时始终不启用浮动边框。AppImage 用户请将 `dbx` 替换为实际的 AppImage 文件路径。
+若在 GNOME Wayland 上出现闪烁、内容消失或必须缩放窗口才能重绘,请完全退出 DBX(包括托盘),并使用 `DBX_LINUX_FLOATING_FRAME=0 dbx` 重新启动以强制使用不透明窗口。没有窗口合成时始终不启用浮动边框。AppImage 用户请将 `dbx` 替换为实际的 AppImage 文件路径。
如果默认的不透明窗口仍有问题,请在反馈中提供 DBX 版本、安装方式、KDE/Plasma 版本、Wayland/X11 会话类型、显卡及驱动信息,以及系统 WebKitGTK 版本。
diff --git a/docs/content/docs/faq.mdx b/docs/content/docs/faq.mdx
index 8756539d2b..56e41ccff7 100644
--- a/docs/content/docs/faq.mdx
+++ b/docs/content/docs/faq.mdx
@@ -35,15 +35,15 @@ description: Frequently asked questions about DBX, including where connection da
## Linux Window Flickering or Missing Content
-The Linux main window draws a rounded, shadowed floating frame on GNOME when a compositing manager is running. On other desktops (KDE, XFCE, Cinnamon, ...) it uses an opaque background by default to avoid transparent-window compositing problems with some graphics driver and WebKitGTK combinations. Neither mode disables GPU acceleration or changes the Wayland/X11 backend.
+The Linux main window draws a rounded, shadowed floating frame on GNOME in a Wayland session when a compositing manager is running. GNOME on X11 ("GNOME on Xorg") and other desktops (KDE, XFCE, Cinnamon, ...) use an opaque background by default to avoid transparent-window compositing problems with some graphics driver and WebKitGTK combinations. Neither mode disables GPU acceleration or changes the Wayland/X11 backend.
-The default can be overridden with an environment variable. To force the floating frame on another desktop:
+The default can be overridden with an environment variable. To force the floating frame on X11 or another desktop:
```bash
DBX_LINUX_FLOATING_FRAME=1 dbx
```
-To force the opaque window on GNOME, for example if you see flickering, missing content or redraws only after resizing, quit DBX completely, including its tray process, and restart with `DBX_LINUX_FLOATING_FRAME=0 dbx`. The frame is never used without a compositing manager. For AppImage installations, replace `dbx` with the actual AppImage path.
+To force the opaque window on GNOME Wayland, for example if you see flickering, missing content or redraws only after resizing, quit DBX completely, including its tray process, and restart with `DBX_LINUX_FLOATING_FRAME=0 dbx`. The frame is never used without a compositing manager. For AppImage installations, replace `dbx` with the actual AppImage path.
If the default opaque window still has problems, include the DBX version, installation format, KDE/Plasma version, Wayland/X11 session type, graphics hardware and driver details, and system WebKitGTK version in your report.
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 79fc9bb19b..ff38ced5af 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -188,10 +188,14 @@ fn linux_desktop_supports_floating_frame(current_desktop: Option<&std::ffi::OsSt
.unwrap_or(false)
}
-/// `DBX_LINUX_FLOATING_FRAME=1|0` is an optional override; without it the desktop decides.
+/// `DBX_LINUX_FLOATING_FRAME=1|0` is an optional override; without it the frame is only used on
+/// GNOME running as a native Wayland client. GNOME on X11 ("GNOME on Xorg") keeps the opaque
+/// window: there the transparent WebKitGTK window stays see-through and only repaints the regions
+/// that get damaged (e.g. under the mouse).
#[cfg_attr(not(target_os = "linux"), allow(dead_code))]
fn should_enable_linux_floating_frame(
compositing: bool,
+ native_wayland: bool,
override_value: Option<&std::ffi::OsStr>,
current_desktop: Option<&std::ffi::OsStr>,
) -> bool {
@@ -201,23 +205,34 @@ fn should_enable_linux_floating_frame(
match override_value.and_then(|value| value.to_str()) {
Some("1") => true,
Some("0") => false,
- _ => linux_desktop_supports_floating_frame(current_desktop),
+ _ => native_wayland && linux_desktop_supports_floating_frame(current_desktop),
}
}
/// The Linux config declares the main window with `create: false` so its transparency can
-/// depend at runtime on the desktop and on whether a compositor is available.
+/// depend at runtime on the desktop, the Wayland/X11 session and whether a compositor is available.
#[cfg(target_os = "linux")]
fn create_linux_main_window(app: &tauri::App) -> tauri::Result<()> {
let Some(config) = app.config().app.windows.iter().find(|window| window.label == "main").cloned() else {
return Ok(());
};
let compositing = linux_compositing_available();
+ let native_wayland = linux_uses_native_wayland(
+ std::env::var_os("WAYLAND_DISPLAY").as_deref(),
+ std::env::var_os("XDG_SESSION_TYPE").as_deref(),
+ std::env::var_os("GDK_BACKEND").as_deref(),
+ );
let override_value = std::env::var_os("DBX_LINUX_FLOATING_FRAME");
let current_desktop = std::env::var_os("XDG_CURRENT_DESKTOP");
- let floating_frame =
- should_enable_linux_floating_frame(compositing, override_value.as_deref(), current_desktop.as_deref());
- log::info!("[WINDOW] Linux main window compositing={compositing}; floating_frame={floating_frame}");
+ let floating_frame = should_enable_linux_floating_frame(
+ compositing,
+ native_wayland,
+ override_value.as_deref(),
+ current_desktop.as_deref(),
+ );
+ log::info!(
+ "[WINDOW] Linux main window compositing={compositing}; native_wayland={native_wayland}; floating_frame={floating_frame}"
+ );
let mut builder = tauri::WebviewWindowBuilder::from_config(app.handle(), &config)?.transparent(floating_frame);
if floating_frame {
// Read by index.html before first paint to draw the rounded, shadowed frame.
@@ -1238,30 +1253,38 @@ mod tests {
}
#[test]
- fn linux_floating_frame_is_enabled_by_default_on_gnome_only() {
+ fn linux_floating_frame_is_enabled_by_default_on_gnome_wayland_only() {
for desktop in ["GNOME", "ubuntu:GNOME", "gnome", "GNOME-Classic:GNOME"] {
- assert!(should_enable_linux_floating_frame(true, None, Some(OsStr::new(desktop))), "{desktop}");
+ assert!(should_enable_linux_floating_frame(true, true, None, Some(OsStr::new(desktop))), "{desktop}");
}
for desktop in ["KDE", "XFCE", "X-Cinnamon", "sway", "", "GNOMEISH"] {
- assert!(!should_enable_linux_floating_frame(true, None, Some(OsStr::new(desktop))), "{desktop}");
+ assert!(!should_enable_linux_floating_frame(true, true, None, Some(OsStr::new(desktop))), "{desktop}");
+ }
+ assert!(!should_enable_linux_floating_frame(true, true, None, None));
+ }
+
+ #[test]
+ fn linux_floating_frame_is_disabled_by_default_on_gnome_x11() {
+ for desktop in ["GNOME", "ubuntu:GNOME", "GNOME-Classic:GNOME"] {
+ assert!(!should_enable_linux_floating_frame(true, false, None, Some(OsStr::new(desktop))), "{desktop}");
}
- assert!(!should_enable_linux_floating_frame(true, None, None));
+ assert!(should_enable_linux_floating_frame(true, false, Some(OsStr::new("1")), Some(OsStr::new("GNOME"))));
}
#[test]
fn linux_floating_frame_override_wins_over_desktop() {
- assert!(should_enable_linux_floating_frame(true, Some(OsStr::new("1")), Some(OsStr::new("KDE"))));
- assert!(!should_enable_linux_floating_frame(true, Some(OsStr::new("0")), Some(OsStr::new("GNOME"))));
+ assert!(should_enable_linux_floating_frame(true, true, Some(OsStr::new("1")), Some(OsStr::new("KDE"))));
+ assert!(!should_enable_linux_floating_frame(true, true, Some(OsStr::new("0")), Some(OsStr::new("GNOME"))));
for value in ["", "true", "auto", "01"] {
- assert!(should_enable_linux_floating_frame(true, Some(OsStr::new(value)), Some(OsStr::new("GNOME"))));
- assert!(!should_enable_linux_floating_frame(true, Some(OsStr::new(value)), Some(OsStr::new("KDE"))));
+ assert!(should_enable_linux_floating_frame(true, true, Some(OsStr::new(value)), Some(OsStr::new("GNOME"))));
+ assert!(!should_enable_linux_floating_frame(true, true, Some(OsStr::new(value)), Some(OsStr::new("KDE"))));
}
}
#[test]
fn linux_floating_frame_requires_compositing() {
- assert!(!should_enable_linux_floating_frame(false, Some(OsStr::new("1")), Some(OsStr::new("GNOME"))));
- assert!(!should_enable_linux_floating_frame(false, None, Some(OsStr::new("GNOME"))));
+ assert!(!should_enable_linux_floating_frame(false, true, Some(OsStr::new("1")), Some(OsStr::new("GNOME"))));
+ assert!(!should_enable_linux_floating_frame(false, true, None, Some(OsStr::new("GNOME"))));
}
#[test]