Add WindowExtUnix trait

This commit is contained in:
Ngo Iok Ui
2021-05-02 12:41:41 +08:00
parent 40cb846e2d
commit d35386d61d
3 changed files with 41 additions and 1 deletions

View File

@@ -20,7 +20,7 @@ default-target = "x86_64-unknown-linux-gnu"
targets = ["i686-pc-windows-msvc", "x86_64-pc-windows-msvc", "i686-unknown-linux-gnu", "x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "wasm32-unknown-unknown"]
[features]
default = ["x11", "wayland"]
default = ["x11"]
web-sys = ["web_sys", "wasm-bindgen", "instant/wasm-bindgen"]
stdweb = ["std_web", "instant/stdweb"]
x11 = ["x11-dl", "mio", "mio-misc", "percent-encoding", "parking_lot"]
@@ -95,6 +95,14 @@ mio-misc = { version = "1.0", optional = true }
x11-dl = { version = "2.18.5", optional = true }
percent-encoding = { version = "2.0", optional = true }
parking_lot = { version = "0.11.0", optional = true }
# gtk
cairo-rs = "0.9"
gio = "0.9"
glib = "0.10"
gtk = "0.9"
gdk = "0.13"
gdk-pixbuf = "0.9"
image = "0.23"
[target.'cfg(target_arch = "wasm32")'.dependencies.web_sys]
package = "web-sys"

View File

@@ -5,3 +5,26 @@
target_os = "netbsd",
target_os = "openbsd"
))]
use crate::window::Window;
/// Additional methods on `Window` that are specific to Unix.
pub trait WindowExtUnix {
/// Returns the `ApplicatonWindow` from gtk crate that is used by this window.
///
/// Returns `None` if the window doesn't use xlib (if it uses wayland for example).
fn gtk_window(&self) -> &gtk::ApplicationWindow;
/// Not to display window icon in the task bar.
fn skip_taskbar(&self);
}
impl WindowExtUnix for Window {
fn gtk_window(&self) -> &gtk::ApplicationWindow {
&self.window.window
}
fn skip_taskbar(&self) {
self.window.skip_taskbar()
}
}

View File

@@ -559,6 +559,15 @@ impl Window {
pub fn raw_window_handle(&self) -> raw_window_handle::RawWindowHandle {
todo!()
}
pub 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);
}
}
}
// We need GtkWindow to initialize WebView, so we have to keep it in the field.