From 190774258c3d2a32451b05738188973ae0393a42 Mon Sep 17 00:00:00 2001 From: Nadji Abidi Date: Sat, 22 Jun 2024 16:12:19 +0100 Subject: [PATCH] Add `override_redirect` for X11 windows This commit add the `override_redirect` boolean field to the `PlatformSpecific` struct for linux platform. This is a X11-specific flag allow bypassing window manager mapping for precise positioning of windows. --- core/src/window/settings/linux.rs | 6 ++++++ winit/src/conversion.rs | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/core/src/window/settings/linux.rs b/core/src/window/settings/linux.rs index 009b9d9e0a..0a1e11cdef 100644 --- a/core/src/window/settings/linux.rs +++ b/core/src/window/settings/linux.rs @@ -8,4 +8,10 @@ pub struct PlatformSpecific { /// As a best practice, it is suggested to select an application id that match /// the basename of the application’s .desktop file. pub application_id: String, + + /// Whether bypass the window manager mapping for x11 windows + /// + /// This flag is particularly useful for creating UI elements that need precise + /// positioning and immediate display without window manager interference. + pub override_redirect: bool, } diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index 585e240903..aaaca1a98a 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -105,10 +105,14 @@ pub fn window_attributes( { use winit::platform::x11::WindowAttributesExtX11; - attributes = attributes.with_name( - &settings.platform_specific.application_id, - &settings.platform_specific.application_id, - ); + attributes = attributes + .with_override_redirect( + settings.platform_specific.override_redirect, + ) + .with_name( + &settings.platform_specific.application_id, + &settings.platform_specific.application_id, + ); } #[cfg(feature = "wayland")] {