Skip to content

Commit

Permalink
feat: WindowExtUnix trait (#192)
Browse files Browse the repository at this point in the history
* Add WindowExtUnix

* Add change file
  • Loading branch information
Ngo Iok Ui (Wu Yu Wei) authored Apr 23, 2021
1 parent 1ef1f58 commit 004e298
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changes/unix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"wry": minor
---

Add platform module and WindowExtUnix trait on Linux

1 change: 1 addition & 0 deletions src/application/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ impl<T: 'static> EventLoop<T> {
window.set_urgency_hint(true)
}
}
WindowRequest::SkipTaskbar => window.set_skip_taskbar_hint(true),
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/application/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ mod icon;
#[cfg(target_os = "linux")]
pub mod monitor;
#[cfg(target_os = "linux")]
pub mod platform;
#[cfg(target_os = "linux")]
pub mod window;

#[cfg(not(target_os = "linux"))]
Expand Down
22 changes: 22 additions & 0 deletions src/application/platform.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

pub mod unix {
use crate::application::window::{Window, WindowRequest};

pub trait WindowExtUnix {
fn skip_taskbar(&self);
}

impl WindowExtUnix for Window {
fn skip_taskbar(&self) {
if let Err(e) = self
.window_requests_tx
.send((self.window_id, WindowRequest::SkipTaskbar))
{
log::warn!("Fail to send skip taskbar request: {}", e);
}
}
}
}
3 changes: 2 additions & 1 deletion src/application/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ pub struct Window {
/// Gtk application window.
pub(crate) window: gtk::ApplicationWindow,
/// Window requests sender
window_requests_tx: Sender<(WindowId, WindowRequest)>,
pub(crate) window_requests_tx: Sender<(WindowId, WindowRequest)>,
scale_factor: f64,
position: (AtomicI32, AtomicI32),
size: (AtomicI32, AtomicI32),
Expand Down Expand Up @@ -725,6 +725,7 @@ pub(crate) enum WindowRequest {
AlwaysOnTop(bool),
WindowIcon(Option<Icon>),
UserAttention(Option<UserAttentionType>),
SkipTaskbar,
}

pub(crate) fn hit_test(window: &gdk::Window, cx: f64, cy: f64) -> WindowEdge {
Expand Down

0 comments on commit 004e298

Please sign in to comment.