diff --git a/.changes/config.json b/.changes/config.json index f121a03be..8694ed12e 100644 --- a/.changes/config.json +++ b/.changes/config.json @@ -17,14 +17,14 @@ "dryRunCommand": true }, { - "command": "cargo generate-lockfile", + "command": "echo '
\n

Cargo Audit

\n\n```'", "dryRunCommand": true, - "runFromRoot": true, "pipe": true }, { - "command": "echo '
\n

Cargo Audit

\n\n```'", + "command": "cargo generate-lockfile", "dryRunCommand": true, + "runFromRoot": true, "pipe": true }, { diff --git a/.changes/ios-custom-url-schemes.md b/.changes/ios-custom-url-schemes.md new file mode 100644 index 000000000..810da0f6f --- /dev/null +++ b/.changes/ios-custom-url-schemes.md @@ -0,0 +1,5 @@ +--- +"tao": patch +--- + +On iOS, implement `application:openURL:options:` to handle custom URL schemes. diff --git a/.changes/kde-taskbar-progress.md b/.changes/kde-taskbar-progress.md deleted file mode 100644 index a23413a8c..000000000 --- a/.changes/kde-taskbar-progress.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"tao": "patch" ---- - -On Linux, removed internal check for current desktop environment before applying `Window::set_progress_bar` API. This should allow `Window::set_progress_bar` to work on KDE Plasma and similar environments that support `libunity` APIs. diff --git a/CHANGELOG.md b/CHANGELOG.md index b11b2b956..b2a3b833e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## \[0.30.0] + +- [`222d5786`](https://github.com/tauri-apps/tao/commit/222d57862b24511eda733812524df1736cd1f64d) ([#971](https://github.com/tauri-apps/tao/pull/971) by [@amrbashir](https://github.com/tauri-apps/tao/../../amrbashir)) On Windows, fix `Window::monitor_from_point` and `EventLoopTargetWindow::monitor_from_point` returning invalid monitor handle. +- [`e47d4c4a`](https://github.com/tauri-apps/tao/commit/e47d4c4aa08cb1d0f431c6bdf8f81cc82ecc72d1) ([#967](https://github.com/tauri-apps/tao/pull/967) by [@amrbashir](https://github.com/tauri-apps/tao/../../amrbashir)) On Linux, removed internal check for current desktop environment before applying `Window::set_progress_bar` API. This should allow `Window::set_progress_bar` to work on KDE Plasma and similar environments that support `libunity` APIs. +- [`9b5aa60b`](https://github.com/tauri-apps/tao/commit/9b5aa60ba6f6e45ac3fc42dc715d7e071d29bb2b) ([#970](https://github.com/tauri-apps/tao/pull/970) by [@amrbashir](https://github.com/tauri-apps/tao/../../amrbashir)) Changed `WindowExtWindows::set_skip_taskbar` and `WindowExtUnix::set_skip_taskbar` to return a result instead of panicing internally. + ## \[0.29.1] - [`4cd53415`](https://github.com/tauri-apps/tao/commit/4cd534151a2d7a14ade906f960ec02655a91feae) ([#964](https://github.com/tauri-apps/tao/pull/964) by [@lucasfernog](https://github.com/tauri-apps/tao/../../lucasfernog)) Allow Android domain names to include `_1` as escaped `_` characters - required because `_` is the separator for domain parts. diff --git a/Cargo.toml b/Cargo.toml index 3bdd76772..5dddbf637 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tao" -version = "0.29.1" +version = "0.30.0" description = "Cross-platform window manager library." authors = [ "Tauri Programme within The Commons Conservancy", diff --git a/src/platform/unix.rs b/src/platform/unix.rs index 781c6b36b..743f5be9a 100644 --- a/src/platform/unix.rs +++ b/src/platform/unix.rs @@ -18,7 +18,7 @@ pub use crate::platform_impl::x11; pub use crate::platform_impl::EventLoop as UnixEventLoop; use crate::{ - error::OsError, + error::{ExternalError, OsError}, event_loop::{EventLoopBuilder, EventLoopWindowTarget}, platform_impl::{x11::xdisplay::XError, Parent, Window as UnixWindow}, window::{Window, WindowBuilder}, @@ -77,7 +77,7 @@ pub trait WindowExtUnix { fn default_vbox(&self) -> Option<>k::Box>; /// Whether to show the window icon in the taskbar or not. - fn set_skip_taskbar(&self, skip: bool); + fn set_skip_taskbar(&self, skip: bool) -> Result<(), ExternalError>; } impl WindowExtUnix for Window { @@ -89,8 +89,8 @@ impl WindowExtUnix for Window { self.window.default_vbox.as_ref() } - fn set_skip_taskbar(&self, skip: bool) { - self.window.set_skip_taskbar(skip); + fn set_skip_taskbar(&self, skip: bool) -> Result<(), ExternalError> { + self.window.set_skip_taskbar(skip) } fn new_from_gtk_window( diff --git a/src/platform/windows.rs b/src/platform/windows.rs index 0f05eccd7..0d266b133 100644 --- a/src/platform/windows.rs +++ b/src/platform/windows.rs @@ -8,6 +8,7 @@ use std::path::Path; use crate::{ dpi::PhysicalSize, + error::ExternalError, event::DeviceId, event_loop::EventLoopBuilder, monitor::MonitorHandle, @@ -172,7 +173,7 @@ pub trait WindowExtWindows { fn begin_resize_drag(&self, edge: isize, button: u32, x: i32, y: i32); /// Whether to show the window icon in the taskbar or not. - fn set_skip_taskbar(&self, skip: bool); + fn set_skip_taskbar(&self, skip: bool) -> Result<(), ExternalError>; /// Shows or hides the background drop shadow for undecorated windows. /// @@ -224,8 +225,8 @@ impl WindowExtWindows for Window { } #[inline] - fn set_skip_taskbar(&self, skip: bool) { - self.window.set_skip_taskbar(skip); + fn set_skip_taskbar(&self, skip: bool) -> Result<(), ExternalError> { + self.window.set_skip_taskbar(skip) } #[inline] diff --git a/src/platform_impl/ios/view.rs b/src/platform_impl/ios/view.rs index 18b6025b8..bed79b856 100644 --- a/src/platform_impl/ios/view.rs +++ b/src/platform_impl/ios/view.rs @@ -555,7 +555,40 @@ pub fn create_delegate_class() { YES } + fn handle_deep_link(url: id) { + unsafe { + let absolute_url: id = msg_send![url, absoluteString]; + let bytes = { + let bytes: *const c_char = msg_send![absolute_url, UTF8String]; + bytes as *const u8 + }; + + // 4 represents utf8 encoding + let len = msg_send![absolute_url, lengthOfBytesUsingEncoding: 4]; + let bytes = std::slice::from_raw_parts(bytes, len); + + let url = url::Url::parse(std::str::from_utf8(bytes).unwrap()).unwrap(); + + app_state::handle_nonuser_event(EventWrapper::StaticEvent(Event::Opened { urls: vec![url] })); + } + } + + // custom URL schemes + // https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app + extern "C" fn application_open_url( + _self: &mut Object, + _cmd: Sel, + _app: id, + url: id, + _options: id, + ) -> BOOL { + handle_deep_link(url); + + YES + } + // universal links + // https://developer.apple.com/documentation/xcode/supporting-universal-links-in-your-app extern "C" fn application_continue( _: &mut Object, _: Sel, @@ -568,19 +601,8 @@ pub fn create_delegate_class() { if webpage_url == nil { return NO; } - let absolute_url: id = msg_send![webpage_url, absoluteString]; - let bytes = { - let bytes: *const c_char = msg_send![absolute_url, UTF8String]; - bytes as *const u8 - }; - // 4 represents utf8 encoding - let len = msg_send![absolute_url, lengthOfBytesUsingEncoding: 4]; - let bytes = std::slice::from_raw_parts(bytes, len); - - let url = url::Url::parse(std::str::from_utf8(bytes).unwrap()).unwrap(); - - app_state::handle_nonuser_event(EventWrapper::StaticEvent(Event::Opened { urls: vec![url] })); + handle_deep_link(webpage_url); YES } @@ -631,6 +653,11 @@ pub fn create_delegate_class() { did_finish_launching as extern "C" fn(&mut Object, Sel, id, id) -> BOOL, ); + decl.add_method( + sel!(application:openURL:options:), + application_open_url as extern "C" fn(&mut Object, Sel, id, id, id) -> BOOL, + ); + decl.add_method( sel!(application:continueUserActivity:restorationHandler:), application_continue as extern "C" fn(&mut Object, Sel, id, id, id) -> BOOL, diff --git a/src/platform_impl/linux/window.rs b/src/platform_impl/linux/window.rs index 2aef9aa4c..c296c707a 100644 --- a/src/platform_impl/linux/window.rs +++ b/src/platform_impl/linux/window.rs @@ -920,13 +920,15 @@ impl Window { } } - pub fn set_skip_taskbar(&self, skip: bool) { + pub fn set_skip_taskbar(&self, skip: bool) -> Result<(), ExternalError> { if let Err(e) = self .window_requests_tx .send((self.window_id, WindowRequest::SetSkipTaskbar(skip))) { log::warn!("Fail to send skip taskbar request: {}", e); } + + Ok(()) } pub fn set_progress_bar(&self, progress: ProgressBarState) { diff --git a/src/platform_impl/windows/event_loop.rs b/src/platform_impl/windows/event_loop.rs index 7ec200c83..b74ccc3c5 100644 --- a/src/platform_impl/windows/event_loop.rs +++ b/src/platform_impl/windows/event_loop.rs @@ -2211,7 +2211,7 @@ unsafe fn public_window_callback_inner( result = ProcResult::Value(LRESULT(0)); } else if msg == *S_U_TASKBAR_RESTART { let window_state = subclass_input.window_state.lock(); - set_skip_taskbar(window, window_state.skip_taskbar); + let _ = set_skip_taskbar(window, window_state.skip_taskbar); } } }; diff --git a/src/platform_impl/windows/monitor.rs b/src/platform_impl/windows/monitor.rs index 24853e1f5..e209df746 100644 --- a/src/platform_impl/windows/monitor.rs +++ b/src/platform_impl/windows/monitor.rs @@ -133,7 +133,7 @@ pub fn from_point(x: f64, y: f64) -> Option { MONITOR_DEFAULTTONULL, ) }; - if hmonitor.is_invalid() { + if !hmonitor.is_invalid() { Some(MonitorHandle::new(hmonitor)) } else { None diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index 5c5a24fbb..fee076d8e 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -981,9 +981,9 @@ impl Window { } #[inline] - pub(crate) fn set_skip_taskbar(&self, skip: bool) { + pub(crate) fn set_skip_taskbar(&self, skip: bool) -> Result<(), ExternalError> { self.window_state.lock().skip_taskbar = skip; - unsafe { set_skip_taskbar(self.hwnd(), skip) }; + unsafe { set_skip_taskbar(self.hwnd(), skip) } } #[inline] @@ -1194,7 +1194,7 @@ unsafe fn init( .lock() .insert(win.id(), KeyEventBuilder::default()); - win.set_skip_taskbar(pl_attribs.skip_taskbar); + let _ = win.set_skip_taskbar(pl_attribs.skip_taskbar); win.set_window_icon(attributes.window_icon); win.set_taskbar_icon(pl_attribs.taskbar_icon); @@ -1400,15 +1400,16 @@ unsafe fn force_window_active(handle: HWND) { let _ = SetForegroundWindow(handle); } -pub(crate) unsafe fn set_skip_taskbar(hwnd: HWND, skip: bool) { +pub(crate) unsafe fn set_skip_taskbar(hwnd: HWND, skip: bool) -> Result<(), ExternalError> { com_initialized(); - let taskbar_list: ITaskbarList = - CoCreateInstance(&TaskbarList, None, CLSCTX_SERVER).expect("failed to create TaskBarList"); + let taskbar_list: ITaskbarList = CoCreateInstance(&TaskbarList, None, CLSCTX_SERVER)?; if skip { - taskbar_list.DeleteTab(hwnd).expect("DeleteTab failed"); + taskbar_list.DeleteTab(hwnd)?; } else { - taskbar_list.AddTab(hwnd).expect("AddTab failed"); + taskbar_list.AddTab(hwnd)?; } + + Ok(()) } impl ResizeDirection {