Skip to content

Commit

Permalink
core(deps): bump wry to 0.11 (#2210)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemarier committed Jul 15, 2021
1 parent 58129e0 commit f0a8db6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .changes/tauri-wry-migrate.md
@@ -0,0 +1,6 @@
---
"tauri": patch
"tauri-runtime-wry": patch
---

Bump `wry` 0.11 and fix focus integration to make it compatible with tao 0.4.
2 changes: 1 addition & 1 deletion core/tauri-runtime-wry/Cargo.toml
Expand Up @@ -12,7 +12,7 @@ exclude = [ ".license_template", "CHANGELOG.md", "/target" ]
readme = "README.md"

[dependencies]
wry = { version = "0.10", default-features = false, features = [ "file-drop", "protocol", "win32" ] }
wry = { version = "0.11", default-features = false, features = [ "file-drop", "protocol", "win32" ] }
tauri-runtime = { version = "0.1.3", path = "../tauri-runtime" }
tauri-utils = { version = "1.0.0-beta.1", path = "../tauri-utils" }
uuid = { version = "0.8.2", features = [ "v4" ] }
Expand Down
45 changes: 28 additions & 17 deletions core/tauri-runtime-wry/src/lib.rs
Expand Up @@ -23,8 +23,11 @@ use tauri_runtime::window::MenuEvent;
use tauri_runtime::{SystemTray, SystemTrayEvent};
#[cfg(windows)]
use winapi::shared::windef::HWND;
#[cfg(target_os = "linux")]
use wry::application::platform::unix::{WindowBuilderExtUnix, WindowExtUnix};
#[cfg(windows)]
use wry::application::platform::windows::WindowBuilderExtWindows;
use wry::application::platform::windows::{WindowBuilderExtWindows, WindowExtWindows};

#[cfg(feature = "system-tray")]
use wry::application::system_tray::{SystemTray as WrySystemTray, SystemTrayBuilder};

Expand Down Expand Up @@ -446,10 +449,6 @@ impl WindowBuilder for WindowBuilderWrapper {
window = window.center();
}

if config.focus {
window = window.focus();
}

window
}

Expand Down Expand Up @@ -511,8 +510,9 @@ impl WindowBuilder for WindowBuilderWrapper {
self
}

fn focus(mut self) -> Self {
self.inner = self.inner.with_focus();
/// Deprecated since 0.1.4 (noop)
/// Windows is automatically focused when created.
fn focus(self) -> Self {
self
}

Expand Down Expand Up @@ -560,11 +560,17 @@ impl WindowBuilder for WindowBuilderWrapper {
Ok(self)
}

#[cfg(any(target_os = "windows", target_os = "linux"))]
fn skip_taskbar(mut self, skip: bool) -> Self {
self.inner = self.inner.with_skip_taskbar(skip);
self
}

#[cfg(target_os = "macos")]
fn skip_taskbar(self, _skip: bool) -> Self {
self
}

fn has_icon(&self) -> bool {
self.inner.window.window_icon.is_some()
}
Expand Down Expand Up @@ -593,7 +599,9 @@ impl From<FileDropEventWrapper> for FileDropEvent {
match event.0 {
WryFileDropEvent::Hovered(paths) => FileDropEvent::Hovered(paths),
WryFileDropEvent::Dropped(paths) => FileDropEvent::Dropped(paths),
WryFileDropEvent::Cancelled => FileDropEvent::Cancelled,
// default to cancelled
// FIXME(maybe): Add `FileDropEvent::Unknown` event?
_ => FileDropEvent::Cancelled,
}
}
}
Expand Down Expand Up @@ -1511,6 +1519,7 @@ fn handle_event_loop(
window_id,
menu_id,
origin: MenuType::MenuBar,
..
} => {
let window_id = window_id.unwrap(); // always Some on MenuBar event
let event = MenuEvent {
Expand All @@ -1527,6 +1536,7 @@ fn handle_event_loop(
window_id: _,
menu_id,
origin: MenuType::ContextMenu,
..
} => {
let event = SystemTrayEvent::MenuItemClick(menu_id.0);
for handler in tray_context.listeners.lock().unwrap().values() {
Expand All @@ -1538,21 +1548,25 @@ fn handle_event_loop(
bounds,
event,
position: _cursor_position,
..
} => {
let (position, size) = (
PhysicalPositionWrapper(bounds.position).into(),
PhysicalSizeWrapper(bounds.size).into(),
);
let event = match event {
TrayEvent::LeftClick => SystemTrayEvent::LeftClick { position, size },
TrayEvent::RightClick => SystemTrayEvent::RightClick { position, size },
TrayEvent::DoubleClick => SystemTrayEvent::DoubleClick { position, size },
// default to left click
_ => SystemTrayEvent::LeftClick { position, size },
};
for handler in tray_context.listeners.lock().unwrap().values() {
handler(&event);
}
}
Event::WindowEvent { event, window_id } => {
Event::WindowEvent {
event, window_id, ..
} => {
if let Some(event) = WindowEventWrapper::from(&event).0 {
for handler in window_event_listeners
.lock()
Expand Down Expand Up @@ -1642,10 +1656,7 @@ fn handle_event_loop(
tx.send(window.available_monitors().collect()).unwrap()
}
#[cfg(windows)]
WindowMessage::Hwnd(tx) => {
use wry::application::platform::windows::WindowExtWindows;
tx.send(Hwnd(window.hwnd() as HWND)).unwrap()
}
WindowMessage::Hwnd(tx) => tx.send(Hwnd(window.hwnd() as HWND)).unwrap(),
#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
Expand All @@ -1654,7 +1665,6 @@ fn handle_event_loop(
target_os = "openbsd"
))]
WindowMessage::GtkWindow(tx) => {
use wry::application::platform::unix::WindowExtUnix;
tx.send(GtkWindow(window.gtk_window().clone())).unwrap()
}
// Setters
Expand Down Expand Up @@ -1721,8 +1731,9 @@ fn handle_event_loop(
WindowMessage::SetIcon(icon) => {
window.set_window_icon(Some(icon));
}
WindowMessage::SetSkipTaskbar(skip) => {
window.set_skip_taskbar(skip);
WindowMessage::SetSkipTaskbar(_skip) => {
#[cfg(any(target_os = "windows", target_os = "linux"))]
window.set_skip_taskbar(_skip);
}
WindowMessage::DragWindow => {
let _ = window.drag_window();
Expand Down

0 comments on commit f0a8db6

Please sign in to comment.