From 93286c8deb03a465a6bb7a37934358a3025b9b6e Mon Sep 17 00:00:00 2001 From: yoriswind <164435053+yoriswind@users.noreply.github.com> Date: Tue, 1 Dec 2026 02:14:03 -0800 Subject: [PATCH] Dock panels inside the window on native Wayland (#10341) --- apps/vectorcraft/src/main.rs | 10 ++++++++-- apps/vectorcraft/src/tests.rs | 13 +++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/vectorcraft/src/main.rs b/apps/vectorcraft/src/main.rs index dc6e7fd7d6..4b1c77e0f1 100644 --- a/apps/vectorcraft/src/main.rs +++ b/apps/vectorcraft/src/main.rs @@ -432,6 +432,12 @@ fn opens_through_xwayland(pref: Option<&str>) -> bool { true } +/// The docking runtime needs the backend the desktop window is opened on. +fn desktop_shell_info(detected: Backend, forced_to_x11: bool) -> ShellInfo { + let backend = if forced_to_x11 { Backend::X11 } else { detected }; + ShellInfo::current().backend(backend) +} + /// The nightly channel this build is, as a string for the log. fn channel_name() -> &'static str { match build_flavor::COMPILED { @@ -718,10 +724,10 @@ fn main() -> std::process::ExitCode { // A window forced onto XWayland runs on X11, whose window manager draws the frame: the // framework decides the frame for that backend, from the platform, `VECTORCRAFT_TITLEBAR` and // Preferences › User Interface › System Title Bar. - let shell_info = if forced_to_x11 { ShellInfo::current().backend(Backend::X11) } else { ShellInfo::current() }; + let shell_info = desktop_shell_info(Backend::from_env(), forced_to_x11); // On Wayland with no cursor theme, the system pointer stays and no tool cursor is painted // beside it (#2450, #5311). - let wayland = !forced_to_x11 && Backend::from_env() == Backend::Wayland; + let wayland = shell_info.backend == Backend::Wayland; let caps = cursor_theme::shell_caps(shell_info.caps, wayland, cursor_theme::theme_missing); let shell_info = shell_info.caps(caps); let titlebar_pref = diff --git a/apps/vectorcraft/src/tests.rs b/apps/vectorcraft/src/tests.rs index 838d96845a..c28fb19c13 100644 --- a/apps/vectorcraft/src/tests.rs +++ b/apps/vectorcraft/src/tests.rs @@ -1,5 +1,18 @@ use super::*; +#[test] +fn desktop_shell_reports_the_backend_selected_for_docking() { + let wayland = desktop_shell_info(Backend::Wayland, false); + assert_eq!(wayland.backend, Backend::Wayland); + assert!(!wayland.window_positions(), "native Wayland keeps palettes inside the window"); + + for (detected, force_x11) in [(Backend::Wayland, true), (Backend::X11, false)] { + let x11 = desktop_shell_info(detected, force_x11); + assert_eq!(x11.backend, Backend::X11); + assert!(x11.window_positions(), "X11 and XWayland can place native palettes"); + } +} + /// The saved UI state of an old `ui.json`, as the legacy import reads it. fn legacy_ui(bytes: &[u8]) -> Option { vectorcraft_ui_egui::parse_legacy(bytes).ok().map(|(settings, _)| settings.ui)