From 8ece7a0c45f7a296be74c20ba4f6fdb56924c179 Mon Sep 17 00:00:00 2001 From: David Lemarier Date: Wed, 7 Jul 2021 09:04:47 -0400 Subject: [PATCH 1/5] fix(examples): Update `set_skip_taskbar` --- examples/system_tray.rs | 14 +++++++++----- examples/system_tray_no_menu.rs | 10 ++++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/examples/system_tray.rs b/examples/system_tray.rs index b23b01b05..6a6e83cce 100644 --- a/examples/system_tray.rs +++ b/examples/system_tray.rs @@ -7,12 +7,16 @@ fn main() -> wry::Result<()> { use std::collections::HashMap; #[cfg(target_os = "linux")] use std::path::Path; + #[cfg(target_os = "linux")] + use wry::application::platform::linux::WindowExtLinux; #[cfg(target_os = "macos")] use wry::application::platform::macos::{ ActivationPolicy, CustomMenuItemExtMacOS, EventLoopExtMacOS, NativeImage, }; #[cfg(target_os = "windows")] use wry::application::platform::windows::SystemTrayExtWindows; + #[cfg(target_os = "windows")] + use wry::application::platform::windows::WindowExtWindows; use wry::{ application::{ accelerator::{Accelerator, SysMods}, @@ -49,7 +53,7 @@ fn main() -> wry::Result<()> { let event_loop = EventLoop::new(); // launch macos app without menu and without dock icon - // shouold be set at launch + // should be set at launch #[cfg(target_os = "macos")] event_loop.set_activation_policy(ActivationPolicy::Accessory); @@ -116,10 +120,10 @@ fn main() -> wry::Result<()> { .unwrap(); // create our new window / webview instance - let window = WindowBuilder::new() - .with_skip_taskbar(true) - .build(event_loop) - .unwrap(); + let window = WindowBuilder::new().build(event_loop).unwrap(); + + #[cfg(any(target_os = "windows", target_os = "linux"))] + window.set_skip_taskbar(true); let id = window.id(); diff --git a/examples/system_tray_no_menu.rs b/examples/system_tray_no_menu.rs index 0e12ac9ea..98ec69ce6 100644 --- a/examples/system_tray_no_menu.rs +++ b/examples/system_tray_no_menu.rs @@ -9,8 +9,12 @@ fn main() -> wry::Result<()> { use std::path::Path; #[cfg(target_os = "linux")] use tao::menu::{ContextMenu, MenuItemAttributes}; + #[cfg(target_os = "linux")] + use wry::application::platform::linux::WindowExtLinux; #[cfg(target_os = "macos")] use wry::application::platform::macos::{ActivationPolicy, EventLoopExtMacOS}; + #[cfg(target_os = "windows")] + use wry::application::platform::windows::WindowExtWindows; use wry::{ application::{ dpi::{LogicalSize, PhysicalPosition}, @@ -45,7 +49,7 @@ fn main() -> wry::Result<()> { let event_loop = EventLoop::new(); // launch macos app without menu and without dock icon - // shouold be set at launch + // should be set at launch #[cfg(target_os = "macos")] event_loop.set_activation_policy(ActivationPolicy::Accessory); @@ -114,12 +118,14 @@ fn main() -> wry::Result<()> { } // create our new window / webview instance let window = WindowBuilder::new() - .with_skip_taskbar(true) .with_position(window_position) .with_inner_size(window_size) .build(event_loop) .unwrap(); + #[cfg(any(target_os = "windows", target_os = "linux"))] + window.set_skip_taskbar(true); + let id = window.id(); let webview = WebViewBuilder::new(window) From b9d1261bb0cb0e762c699d9a916d52469efc55b5 Mon Sep 17 00:00:00 2001 From: David Lemarier Date: Wed, 7 Jul 2021 09:27:46 -0400 Subject: [PATCH 2/5] fix linux --- examples/system_tray.rs | 2 +- examples/system_tray_no_menu.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/system_tray.rs b/examples/system_tray.rs index 6a6e83cce..0059da5b4 100644 --- a/examples/system_tray.rs +++ b/examples/system_tray.rs @@ -8,7 +8,7 @@ fn main() -> wry::Result<()> { #[cfg(target_os = "linux")] use std::path::Path; #[cfg(target_os = "linux")] - use wry::application::platform::linux::WindowExtLinux; + use wry::application::platform::unix::WindowExtUnix; #[cfg(target_os = "macos")] use wry::application::platform::macos::{ ActivationPolicy, CustomMenuItemExtMacOS, EventLoopExtMacOS, NativeImage, diff --git a/examples/system_tray_no_menu.rs b/examples/system_tray_no_menu.rs index 98ec69ce6..7cc4a7ff8 100644 --- a/examples/system_tray_no_menu.rs +++ b/examples/system_tray_no_menu.rs @@ -10,7 +10,7 @@ fn main() -> wry::Result<()> { #[cfg(target_os = "linux")] use tao::menu::{ContextMenu, MenuItemAttributes}; #[cfg(target_os = "linux")] - use wry::application::platform::linux::WindowExtLinux; + use wry::application::platform::unix::WindowExtUnix; #[cfg(target_os = "macos")] use wry::application::platform::macos::{ActivationPolicy, EventLoopExtMacOS}; #[cfg(target_os = "windows")] From e43c1d51e738a3d9ca62ec2cc91965cfa030f25d Mon Sep 17 00:00:00 2001 From: David Lemarier Date: Wed, 7 Jul 2021 09:37:19 -0400 Subject: [PATCH 3/5] bump `tao` to 0.4 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index facd66718..8a7056032 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ serde = { version = "1.0", features = [ "derive" ] } serde_json = "1.0" thiserror = "1.0" url = "2.2" -tao = { version = "0.3", default-features = false, features = [ "serde" ] } +tao = { version = "0.4", default-features = false, features = [ "serde" ] } [dev-dependencies] anyhow = "1.0.41" From 081fd6c1f3981be6ee62186cff653c5fc9fcfbfa Mon Sep 17 00:00:00 2001 From: David Lemarier Date: Wed, 14 Jul 2021 14:03:21 -0400 Subject: [PATCH 4/5] fix examples --- examples/custom_titlebar.rs | 5 ++++- examples/multi_window.rs | 1 + examples/system_tray.rs | 15 +++++++++------ examples/system_tray_no_menu.rs | 21 +++++++++++++-------- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/examples/custom_titlebar.rs b/examples/custom_titlebar.rs index 7f9e611af..a7b962349 100644 --- a/examples/custom_titlebar.rs +++ b/examples/custom_titlebar.rs @@ -131,7 +131,10 @@ fn main() -> wry::Result<()> { } } - if let Event::WindowEvent { event, window_id } = event { + if let Event::WindowEvent { + event, window_id, .. + } = event + { match event { WindowEvent::CloseRequested => { webviews.remove(&window_id); diff --git a/examples/multi_window.rs b/examples/multi_window.rs index a11d0600f..ce7026f2d 100644 --- a/examples/multi_window.rs +++ b/examples/multi_window.rs @@ -89,6 +89,7 @@ fn main() -> wry::Result<()> { if let Event::WindowEvent { window_id, event: WindowEvent::CloseRequested, + .. } = event { webviews.remove(&window_id); diff --git a/examples/system_tray.rs b/examples/system_tray.rs index 0059da5b4..0a353c6f7 100644 --- a/examples/system_tray.rs +++ b/examples/system_tray.rs @@ -7,16 +7,16 @@ fn main() -> wry::Result<()> { use std::collections::HashMap; #[cfg(target_os = "linux")] use std::path::Path; - #[cfg(target_os = "linux")] - use wry::application::platform::unix::WindowExtUnix; #[cfg(target_os = "macos")] use wry::application::platform::macos::{ ActivationPolicy, CustomMenuItemExtMacOS, EventLoopExtMacOS, NativeImage, }; + #[cfg(target_os = "linux")] + use wry::application::platform::unix::WindowBuilderExtUnix; #[cfg(target_os = "windows")] use wry::application::platform::windows::SystemTrayExtWindows; #[cfg(target_os = "windows")] - use wry::application::platform::windows::WindowExtWindows; + use wry::application::platform::windows::WindowBuilderExtWindows; use wry::{ application::{ accelerator::{Accelerator, SysMods}, @@ -120,10 +120,12 @@ fn main() -> wry::Result<()> { .unwrap(); // create our new window / webview instance - let window = WindowBuilder::new().build(event_loop).unwrap(); - #[cfg(any(target_os = "windows", target_os = "linux"))] - window.set_skip_taskbar(true); + let window_builder = WindowBuilder::new().with_skip_taskbar(true); + #[cfg(target_os = "macos")] + let window_builder = WindowBuilder::new(); + + let window = window_builder.build(event_loop).unwrap(); let id = window.id(); @@ -159,6 +161,7 @@ fn main() -> wry::Result<()> { Event::WindowEvent { event: WindowEvent::CloseRequested, window_id, + .. } => { println!("Window {:?} has received the signal to close", window_id); let mut open_new_window = open_new_window.clone(); diff --git a/examples/system_tray_no_menu.rs b/examples/system_tray_no_menu.rs index 7cc4a7ff8..0a034601f 100644 --- a/examples/system_tray_no_menu.rs +++ b/examples/system_tray_no_menu.rs @@ -9,12 +9,12 @@ fn main() -> wry::Result<()> { use std::path::Path; #[cfg(target_os = "linux")] use tao::menu::{ContextMenu, MenuItemAttributes}; - #[cfg(target_os = "linux")] - use wry::application::platform::unix::WindowExtUnix; #[cfg(target_os = "macos")] use wry::application::platform::macos::{ActivationPolicy, EventLoopExtMacOS}; + #[cfg(target_os = "linux")] + use wry::application::platform::unix::WindowBuilderExtUnix; #[cfg(target_os = "windows")] - use wry::application::platform::windows::WindowExtWindows; + use wry::application::platform::windows::WindowBuilderExtWindows; use wry::{ application::{ dpi::{LogicalSize, PhysicalPosition}, @@ -116,15 +116,19 @@ fn main() -> wry::Result<()> { } return; } + // create our new window / webview instance - let window = WindowBuilder::new() + let mut window_builder = WindowBuilder::new(); + window_builder = window_builder .with_position(window_position) - .with_inner_size(window_size) - .build(event_loop) - .unwrap(); + .with_inner_size(window_size); #[cfg(any(target_os = "windows", target_os = "linux"))] - window.set_skip_taskbar(true); + { + window_builder = window_builder.with_skip_taskbar(true); + } + + let window = window_builder.build(event_loop).unwrap(); let id = window.id(); @@ -146,6 +150,7 @@ fn main() -> wry::Result<()> { Event::WindowEvent { event: WindowEvent::CloseRequested, window_id, + .. } => { println!("Window {:?} has received the signal to close", window_id); // Remove webview from our hashmap From 623d4e2203126cc4151e25bcd155f1519c9e55ca Mon Sep 17 00:00:00 2001 From: David Lemarier Date: Wed, 14 Jul 2021 14:24:02 -0400 Subject: [PATCH 5/5] add changelog --- .changes/tao-new-minor.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/tao-new-minor.md diff --git a/.changes/tao-new-minor.md b/.changes/tao-new-minor.md new file mode 100644 index 000000000..eacf3ac0d --- /dev/null +++ b/.changes/tao-new-minor.md @@ -0,0 +1,5 @@ +--- +"wry": minor +--- + +Bump tao to `0.4`. Please refer to `tao` changelog for more details.