From 2047f311c5f9ade68e7a6a83d70bc1b8352ca89c Mon Sep 17 00:00:00 2001 From: AnotherNathan <85432173+AnotherNathan@users.noreply.github.com> Date: Sat, 3 Feb 2024 16:11:47 +0100 Subject: [PATCH] add with_skip_taskbar to viewport builder --- crates/egui-winit/src/lib.rs | 10 ++++++++-- crates/egui/src/viewport.rs | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 112606476e8..669c000e494 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -1498,6 +1498,7 @@ pub fn create_winit_window_builder( // Windows: drag_and_drop: _drag_and_drop, + skip_taskbar: _skip_taskbar, // wayland: app_id: _app_id, @@ -1575,9 +1576,14 @@ pub fn create_winit_window_builder( } #[cfg(target_os = "windows")] - if let Some(enable) = _drag_and_drop { + { use winit::platform::windows::WindowBuilderExtWindows as _; - window_builder = window_builder.with_drag_and_drop(enable); + if let Some(enable) = _drag_and_drop { + window_builder = window_builder.with_drag_and_drop(enable); + } + if let Some(skip) = _skip_taskbar { + window_builder = window_builder.with_skip_taskbar(skip); + } } #[cfg(target_os = "macos")] diff --git a/crates/egui/src/viewport.rs b/crates/egui/src/viewport.rs index 785579373f6..9b651c9b335 100644 --- a/crates/egui/src/viewport.rs +++ b/crates/egui/src/viewport.rs @@ -283,7 +283,6 @@ pub struct ViewportBuilder { pub icon: Option>, pub active: Option, pub visible: Option, - pub drag_and_drop: Option, // macOS: pub fullsize_content_view: Option, @@ -291,6 +290,10 @@ pub struct ViewportBuilder { pub titlebar_buttons_shown: Option, pub titlebar_shown: Option, + // windows: + pub drag_and_drop: Option, + pub skip_taskbar: Option, + pub close_button: Option, pub minimize_button: Option, pub maximize_button: Option, @@ -442,6 +445,13 @@ impl ViewportBuilder { self } + /// windows: Whether show or hide the window icon in the taskbar. + #[inline] + pub fn with_skip_taskbar(mut self, skip: bool) -> Self { + self.skip_taskbar = Some(skip); + self + } + /// Requests the window to be of specific dimensions. /// /// If this is not set, some platform-specific dimensions will be used. @@ -602,6 +612,7 @@ impl ViewportBuilder { maximize_button: new_maximize_button, window_level: new_window_level, mouse_passthrough: new_mouse_passthrough, + skip_taskbar: new_skip_taskbar, } = new_vp_builder; let mut commands = Vec::new(); @@ -758,6 +769,11 @@ impl ViewportBuilder { recreate_window = true; } + if new_skip_taskbar.is_some() && self.skip_taskbar != new_skip_taskbar { + self.skip_taskbar = new_skip_taskbar; + recreate_window = true; + } + if new_fullsize_content_view.is_some() && self.fullsize_content_view != new_fullsize_content_view {