mirror of
https://github.com/tauri-apps/tao.git
synced 2026-01-31 00:35:16 +01:00
refactor: move set_skip_taskbar to Window
This commit is contained in:
@@ -17,17 +17,10 @@ pub use crate::platform_impl::hit_test;
|
||||
pub trait WindowExtUnix {
|
||||
/// Returns the `ApplicatonWindow` from gtk crate that is used by this window.
|
||||
fn gtk_window(&self) -> >k::ApplicationWindow;
|
||||
|
||||
/// Removes the window icon from the task bar.
|
||||
fn skip_taskbar(&self);
|
||||
}
|
||||
|
||||
impl WindowExtUnix for Window {
|
||||
fn gtk_window(&self) -> >k::ApplicationWindow {
|
||||
&self.window.window
|
||||
}
|
||||
|
||||
fn skip_taskbar(&self) {
|
||||
self.window.skip_taskbar()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,9 +102,6 @@ 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 {
|
||||
@@ -134,11 +131,6 @@ 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.
|
||||
|
||||
@@ -550,6 +550,9 @@ impl Window {
|
||||
|
||||
pub fn request_user_attention(&self, _request_type: Option<window::UserAttentionType>) {}
|
||||
|
||||
#[inline]
|
||||
pub fn set_skip_taskbar(&self, _skip: bool) {}
|
||||
|
||||
pub fn set_cursor_icon(&self, _: window::CursorIcon) {}
|
||||
|
||||
pub fn set_cursor_position(&self, _: Position) -> Result<(), error::ExternalError> {
|
||||
|
||||
@@ -297,6 +297,10 @@ impl Inner {
|
||||
warn!("`Window::set_ime_position` is ignored on iOS")
|
||||
}
|
||||
|
||||
pub fn set_skip_taskbar(&self, _skip: bool) {
|
||||
warn!("`Window::set_skip_taskbar` is ignored on iOS")
|
||||
}
|
||||
|
||||
pub fn request_user_attention(&self, _request_type: Option<UserAttentionType>) {
|
||||
warn!("`Window::request_user_attention` is ignored on iOS")
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ impl<T: 'static> EventLoop<T> {
|
||||
window.set_urgency_hint(true)
|
||||
}
|
||||
}
|
||||
WindowRequest::SkipTaskbar => window.set_skip_taskbar_hint(true),
|
||||
WindowRequest::SetSkipTaskbar(skip) => window.set_skip_taskbar_hint(skip),
|
||||
WindowRequest::CursorIcon(cursor) => {
|
||||
if let Some(gdk_window) = window.get_window() {
|
||||
let display = window.get_display();
|
||||
|
||||
@@ -600,10 +600,10 @@ impl Window {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn skip_taskbar(&self) {
|
||||
pub fn set_skip_taskbar(&self, skip: bool) {
|
||||
if let Err(e) = self
|
||||
.window_requests_tx
|
||||
.send((self.window_id, WindowRequest::SkipTaskbar))
|
||||
.send((self.window_id, WindowRequest::SetSkipTaskbar(skip)))
|
||||
{
|
||||
log::warn!("Fail to send skip taskbar request: {}", e);
|
||||
}
|
||||
@@ -632,7 +632,7 @@ pub enum WindowRequest {
|
||||
AlwaysOnTop(bool),
|
||||
WindowIcon(Option<Icon>),
|
||||
UserAttention(Option<UserAttentionType>),
|
||||
SkipTaskbar,
|
||||
SetSkipTaskbar(bool),
|
||||
CursorIcon(Option<CursorIcon>),
|
||||
WireUpEvents,
|
||||
Redraw,
|
||||
|
||||
@@ -1031,6 +1031,9 @@ impl UnownedWindow {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_skip_taskbar(&self, _skip: bool) {}
|
||||
|
||||
#[inline]
|
||||
// Allow directly accessing the current monitor internally without unwrapping.
|
||||
pub(crate) fn current_monitor_inner(&self) -> RootMonitorHandle {
|
||||
|
||||
@@ -720,7 +720,7 @@ impl Window {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn skip_taskbar(&self) {
|
||||
pub fn set_skip_taskbar(&self, skip: bool) {
|
||||
unsafe {
|
||||
let mut taskbar_list: *mut ITaskbarList = std::mem::zeroed();
|
||||
CoCreateInstance(
|
||||
@@ -730,7 +730,11 @@ impl Window {
|
||||
&ITaskbarList::uuidof(),
|
||||
&mut taskbar_list as *mut _ as *mut _,
|
||||
);
|
||||
(*taskbar_list).DeleteTab(self.window.0);
|
||||
if skip {
|
||||
(*taskbar_list).DeleteTab(self.hwnd());
|
||||
} else {
|
||||
(*taskbar_list).AddTab(self.hwnd());
|
||||
}
|
||||
(*taskbar_list).Release();
|
||||
}
|
||||
}
|
||||
@@ -996,7 +1000,7 @@ unsafe fn taskbar_mark_fullscreen(handle: HWND, fullscreen: bool) {
|
||||
let mut task_bar_list = task_bar_list_ptr.get();
|
||||
|
||||
if task_bar_list == ptr::null_mut() {
|
||||
use winapi::{shared::winerror::S_OK, Interface};
|
||||
use winapi::shared::winerror::S_OK;
|
||||
|
||||
let hr = combaseapi::CoCreateInstance(
|
||||
&CLSID_TaskbarList,
|
||||
|
||||
@@ -813,6 +813,15 @@ impl Window {
|
||||
pub fn request_user_attention(&self, request_type: Option<UserAttentionType>) {
|
||||
self.window.request_user_attention(request_type)
|
||||
}
|
||||
|
||||
/// Removes the window icon from the task bar.
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **macOS/ iOS / Android:** Unsupported.
|
||||
pub fn set_skip_taskbar(&self, skip: bool) {
|
||||
self.window.set_skip_taskbar(skip);
|
||||
}
|
||||
}
|
||||
|
||||
/// Cursor functions.
|
||||
|
||||
Reference in New Issue
Block a user