mirror of
https://github.com/tauri-apps/winit.git
synced 2026-02-04 02:11:19 +01:00
Add WindowExtUnix trait
This commit is contained in:
10
Cargo.toml
10
Cargo.toml
@@ -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"
|
||||
|
||||
@@ -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) -> >k::ApplicationWindow;
|
||||
|
||||
/// Not to display window icon in 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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user