Skip to content

Commit 40254eb

Browse files
AnotherNathanhacknus
authored andcommitted
add with_taskbar to viewport builder (emilk#3958)
Allows removing the taskbar icon of a viewport. This can be useful when making an overlay type viewport (window is always on top).
1 parent 3609e85 commit 40254eb

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

crates/egui-winit/src/lib.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,7 @@ pub fn create_winit_window_builder<T>(
14981498

14991499
// Windows:
15001500
drag_and_drop: _drag_and_drop,
1501+
taskbar: _taskbar,
15011502

15021503
// wayland:
15031504
app_id: _app_id,
@@ -1575,9 +1576,14 @@ pub fn create_winit_window_builder<T>(
15751576
}
15761577

15771578
#[cfg(target_os = "windows")]
1578-
if let Some(enable) = _drag_and_drop {
1579+
{
15791580
use winit::platform::windows::WindowBuilderExtWindows as _;
1580-
window_builder = window_builder.with_drag_and_drop(enable);
1581+
if let Some(enable) = _drag_and_drop {
1582+
window_builder = window_builder.with_drag_and_drop(enable);
1583+
}
1584+
if let Some(show) = _taskbar {
1585+
window_builder = window_builder.with_skip_taskbar(!show);
1586+
}
15811587
}
15821588

15831589
#[cfg(target_os = "macos")]

crates/egui/src/viewport.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,17 @@ pub struct ViewportBuilder {
283283
pub icon: Option<Arc<IconData>>,
284284
pub active: Option<bool>,
285285
pub visible: Option<bool>,
286-
pub drag_and_drop: Option<bool>,
287286

288287
// macOS:
289288
pub fullsize_content_view: Option<bool>,
290289
pub title_shown: Option<bool>,
291290
pub titlebar_buttons_shown: Option<bool>,
292291
pub titlebar_shown: Option<bool>,
293292

293+
// windows:
294+
pub drag_and_drop: Option<bool>,
295+
pub taskbar: Option<bool>,
296+
294297
pub close_button: Option<bool>,
295298
pub minimize_button: Option<bool>,
296299
pub maximize_button: Option<bool>,
@@ -442,6 +445,13 @@ impl ViewportBuilder {
442445
self
443446
}
444447

448+
/// windows: Whether show or hide the window icon in the taskbar.
449+
#[inline]
450+
pub fn with_taskbar(mut self, show: bool) -> Self {
451+
self.taskbar = Some(show);
452+
self
453+
}
454+
445455
/// Requests the window to be of specific dimensions.
446456
///
447457
/// If this is not set, some platform-specific dimensions will be used.
@@ -602,6 +612,7 @@ impl ViewportBuilder {
602612
maximize_button: new_maximize_button,
603613
window_level: new_window_level,
604614
mouse_passthrough: new_mouse_passthrough,
615+
taskbar: new_taskbar,
605616
} = new_vp_builder;
606617

607618
let mut commands = Vec::new();
@@ -758,6 +769,11 @@ impl ViewportBuilder {
758769
recreate_window = true;
759770
}
760771

772+
if new_taskbar.is_some() && self.taskbar != new_taskbar {
773+
self.taskbar = new_taskbar;
774+
recreate_window = true;
775+
}
776+
761777
if new_fullsize_content_view.is_some()
762778
&& self.fullsize_content_view != new_fullsize_content_view
763779
{

0 commit comments

Comments
 (0)