1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 04:40:03 -04:00

Allow specifying override_redirect x11 window attribute (#7830)

This commit is contained in:
Ivor Wanders
2026-01-05 07:16:00 -05:00
committed by GitHub
parent 6d416fab2e
commit 0566fb17a5
2 changed files with 22 additions and 2 deletions

View File

@@ -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")]

View File

@@ -332,6 +332,7 @@ pub struct ViewportBuilder {
// X11
pub window_type: Option<X11WindowType>,
pub override_redirect: Option<bool>,
}
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)
}
}