mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-09-11 07:55:34 +03:00
parent
6569c2bf5c
commit
e0a8e09cab
7
.changes/gtk-window.md
Normal file
7
.changes/gtk-window.md
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
"tauri": patch
|
||||
"tauri-runtime": patch
|
||||
"tauri-runtime-wry": patch
|
||||
---
|
||||
|
||||
Expose `gtk_window` getter.
|
@ -22,8 +22,9 @@ infer = "0.4"
|
||||
ico = "0.1"
|
||||
winapi = "0.3"
|
||||
|
||||
[target."cfg(target_os = \"linux\")".dependencies]
|
||||
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
|
||||
png = "0.16"
|
||||
gtk = { version = "0.9", features = [ "v3_16" ] }
|
||||
|
||||
[features]
|
||||
dox = [ "wry/dox" ]
|
||||
|
@ -599,6 +599,23 @@ struct Hwnd(HWND);
|
||||
#[cfg(windows)]
|
||||
unsafe impl Send for Hwnd {}
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
struct GtkWindow(gtk::ApplicationWindow);
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
unsafe impl Send for GtkWindow {}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
enum WindowMessage {
|
||||
// Getters
|
||||
@ -619,6 +636,14 @@ enum WindowMessage {
|
||||
AvailableMonitors(Sender<Vec<MonitorHandle>>),
|
||||
#[cfg(windows)]
|
||||
Hwnd(Sender<Hwnd>),
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
GtkWindow(Sender<GtkWindow>),
|
||||
// Setters
|
||||
Center(Sender<Result<()>>),
|
||||
RequestUserAttention(Option<UserAttentionTypeWrapper>),
|
||||
@ -830,6 +855,18 @@ impl Dispatch for WryDispatcher {
|
||||
Ok(dispatcher_getter!(self, WindowMessage::Hwnd).0)
|
||||
}
|
||||
|
||||
/// Returns the `ApplicatonWindow` from gtk crate that is used by this window.
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
fn gtk_window(&self) -> Result<gtk::ApplicationWindow> {
|
||||
Ok(dispatcher_getter!(self, WindowMessage::GtkWindow).0)
|
||||
}
|
||||
|
||||
// Setters
|
||||
|
||||
fn center(&self) -> Result<()> {
|
||||
@ -1592,6 +1629,17 @@ fn handle_event_loop(
|
||||
use wry::application::platform::windows::WindowExtWindows;
|
||||
tx.send(Hwnd(window.hwnd() as HWND)).unwrap()
|
||||
}
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
WindowMessage::GtkWindow(tx) => {
|
||||
use wry::application::platform::unix::WindowExtUnix;
|
||||
tx.send(GtkWindow(window.gtk_window().clone())).unwrap()
|
||||
}
|
||||
// Setters
|
||||
WindowMessage::Center(tx) => {
|
||||
tx.send(center_window(window)).unwrap();
|
||||
|
@ -31,6 +31,9 @@ uuid = { version = "0.8.2", features = [ "v4" ] }
|
||||
[target."cfg(windows)".dependencies]
|
||||
winapi = "0.3"
|
||||
|
||||
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
|
||||
gtk = { version = "0.9", features = [ "v3_16" ] }
|
||||
|
||||
[features]
|
||||
menu = [ ]
|
||||
system-tray = [ ]
|
||||
|
@ -417,6 +417,16 @@ pub trait Dispatch: Clone + Send + Sized + 'static {
|
||||
#[cfg(windows)]
|
||||
fn hwnd(&self) -> crate::Result<HWND>;
|
||||
|
||||
/// Returns the `ApplicatonWindow` from gtk crate that is used by this window.
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
fn gtk_window(&self) -> crate::Result<gtk::ApplicationWindow>;
|
||||
|
||||
// SETTERS
|
||||
|
||||
/// Centers the window.
|
||||
|
@ -69,6 +69,9 @@ rfd = "0.4"
|
||||
raw-window-handle = { version = "0.3.3", optional = true }
|
||||
minisign-verify = { version = "0.1", optional = true }
|
||||
|
||||
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
|
||||
gtk = { version = "0.9", features = [ "v3_16" ] }
|
||||
|
||||
[build-dependencies]
|
||||
cfg_aliases = "0.1.1"
|
||||
|
||||
|
@ -511,6 +511,20 @@ impl<P: Params> Window<P> {
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Returns the `ApplicatonWindow` from gtk crate that is used by this window.
|
||||
///
|
||||
/// Note that this can only be used on the main thread.
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
pub fn gtk_window(&self) -> crate::Result<gtk::ApplicationWindow> {
|
||||
self.window.dispatcher.gtk_window().map_err(Into::into)
|
||||
}
|
||||
|
||||
// Setters
|
||||
|
||||
/// Centers the window.
|
||||
|
Loading…
Reference in New Issue
Block a user