From 0566fb17a573948f6a4c5bd7a3c7b7139b1d219f Mon Sep 17 00:00:00 2001 From: Ivor Wanders Date: Mon, 5 Jan 2026 07:16:00 -0500 Subject: [PATCH] Allow specifying override_redirect x11 window attribute (#7830) --- crates/egui-winit/src/lib.rs | 6 +++++- crates/egui/src/viewport.rs | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index a16865d17..54059cbd6 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -1728,6 +1728,7 @@ pub fn create_winit_window_attributes( // x11 window_type: _window_type, + override_redirect: _override_redirect, mouse_passthrough: _, // handled in `apply_viewport_builder_to_window` clamp_size_to_monitor_size: _, // Handled in `viewport_builder` in `epi_integration.rs` @@ -1827,8 +1828,8 @@ pub fn create_winit_window_attributes( #[cfg(all(feature = "x11", target_os = "linux"))] { + use winit::platform::x11::WindowAttributesExtX11 as _; if let Some(window_type) = _window_type { - use winit::platform::x11::WindowAttributesExtX11 as _; use winit::platform::x11::WindowType; window_attributes = window_attributes.with_x11_window_type(vec![match window_type { egui::X11WindowType::Normal => WindowType::Normal, @@ -1847,6 +1848,9 @@ pub fn create_winit_window_attributes( egui::X11WindowType::Dnd => WindowType::Dnd, }]); } + if let Some(override_redirect) = _override_redirect { + window_attributes = window_attributes.with_override_redirect(override_redirect); + } } #[cfg(target_os = "windows")] diff --git a/crates/egui/src/viewport.rs b/crates/egui/src/viewport.rs index 15741c017..ef6ee6c63 100644 --- a/crates/egui/src/viewport.rs +++ b/crates/egui/src/viewport.rs @@ -332,6 +332,7 @@ pub struct ViewportBuilder { // X11 pub window_type: Option, + pub override_redirect: Option, } impl ViewportBuilder { @@ -663,13 +664,22 @@ impl ViewportBuilder { /// ### On X11 /// This sets the window type. - /// Maps directly to [`_NET_WM_WINDOW_TYPE`](https://specifications.freedesktop.org/wm-spec/wm-spec-1.5.html). + /// Maps directly to [`_NET_WM_WINDOW_TYPE`](https://specifications.freedesktop.org/wm/1.5/ar01s05.html#id-1.6.7). #[inline] pub fn with_window_type(mut self, value: X11WindowType) -> Self { self.window_type = Some(value); self } + /// ### On X11 + /// This sets the override-redirect flag. When this is set to true the window type should be specified. + /// Maps directly to [`Override-redirect windows`](https://specifications.freedesktop.org/wm/1.5/ar01s02.html#id-1.3.13). + #[inline] + pub fn with_override_redirect(mut self, value: bool) -> Self { + self.override_redirect = Some(value); + self + } + /// Update this `ViewportBuilder` with a delta, /// returning a list of commands and a bool indicating if the window needs to be recreated. #[must_use] @@ -706,6 +716,7 @@ impl ViewportBuilder { mouse_passthrough: new_mouse_passthrough, taskbar: new_taskbar, window_type: new_window_type, + override_redirect: new_override_redirect, } = new_vp_builder; let mut commands = Vec::new(); @@ -903,6 +914,11 @@ impl ViewportBuilder { recreate_window = true; } + if new_override_redirect.is_some() && self.override_redirect != new_override_redirect { + self.override_redirect = new_override_redirect; + recreate_window = true; + } + (commands, recreate_window) } }