Skip to content

Commit

Permalink
feat: add skip_taskabr impl for windows (rust-windowing#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir authored May 29, 2021
1 parent c402a38 commit 8334170
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changes/skip_taskbar_windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
tao: patch
---

Add `skip_taskbar` implementation for windows
2 changes: 1 addition & 1 deletion src/platform/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub trait WindowExtUnix {
/// Returns the `ApplicatonWindow` from gtk crate that is used by this window.
fn gtk_window(&self) -> &gtk::ApplicationWindow;

/// Not to display window icon in the task bar.
/// Removes the window icon from the task bar.
fn skip_taskbar(&self);
}

Expand Down
8 changes: 8 additions & 0 deletions src/platform/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ pub trait WindowExtWindows {

/// Returns the current window theme.
fn theme(&self) -> Theme;

/// Removes the window icon from the task bar.
fn skip_taskbar(&self);
}

impl WindowExtWindows for Window {
Expand Down Expand Up @@ -131,6 +134,11 @@ impl WindowExtWindows for Window {
fn theme(&self) -> Theme {
self.window.theme()
}

#[inline]
fn skip_taskbar(&self) {
self.window.skip_taskbar();
}
}

/// Additional methods on `WindowBuilder` that are specific to Windows.
Expand Down
22 changes: 20 additions & 2 deletions src/platform_impl/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ use winapi::{
windef::{HWND, POINT, POINTS, RECT},
},
um::{
combaseapi, dwmapi,
combaseapi::{self, CoCreateInstance, CLSCTX_SERVER},
dwmapi,
imm::{CFS_POINT, COMPOSITIONFORM},
libloaderapi,
objbase::COINIT_APARTMENTTHREADED,
ole2,
oleidl::LPDROPTARGET,
shobjidl_core::{CLSID_TaskbarList, ITaskbarList2},
shobjidl_core::{CLSID_TaskbarList, ITaskbarList, ITaskbarList2},
wingdi::{CreateRectRgn, DeleteObject},
winnt::{LPCWSTR, SHORT},
winuser,
},
Interface,
};

use crate::{
Expand Down Expand Up @@ -716,6 +718,22 @@ impl Window {
pub fn theme(&self) -> Theme {
self.window_state.lock().current_theme
}

#[inline]
pub fn skip_taskbar(&self) {
unsafe {
let mut taskbar_list: *mut ITaskbarList = std::mem::zeroed();
CoCreateInstance(
&CLSID_TaskbarList,
ptr::null_mut(),
CLSCTX_SERVER,
&ITaskbarList::uuidof(),
&mut taskbar_list as *mut _ as *mut _,
);
(*taskbar_list).DeleteTab(self.window.0);
(*taskbar_list).Release();
}
}
}

impl Drop for Window {
Expand Down

0 comments on commit 8334170

Please sign in to comment.