Skip to content

Commit

Permalink
add with_skip_taskbar to viewport builder
Browse files Browse the repository at this point in the history
  • Loading branch information
AnotherNathan committed Feb 3, 2024
1 parent 114f820 commit 2047f31
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
10 changes: 8 additions & 2 deletions crates/egui-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,7 @@ pub fn create_winit_window_builder<T>(

// Windows:
drag_and_drop: _drag_and_drop,
skip_taskbar: _skip_taskbar,

// wayland:
app_id: _app_id,
Expand Down Expand Up @@ -1575,9 +1576,14 @@ pub fn create_winit_window_builder<T>(
}

#[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")]
Expand Down
18 changes: 17 additions & 1 deletion crates/egui/src/viewport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,17 @@ pub struct ViewportBuilder {
pub icon: Option<Arc<IconData>>,
pub active: Option<bool>,
pub visible: Option<bool>,
pub drag_and_drop: Option<bool>,

// macOS:
pub fullsize_content_view: Option<bool>,
pub title_shown: Option<bool>,
pub titlebar_buttons_shown: Option<bool>,
pub titlebar_shown: Option<bool>,

// windows:
pub drag_and_drop: Option<bool>,
pub skip_taskbar: Option<bool>,

pub close_button: Option<bool>,
pub minimize_button: Option<bool>,
pub maximize_button: Option<bool>,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 2047f31

Please sign in to comment.