Skip to content

Commit

Permalink
Merge branch 'dev' into set-theme-windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Legend-Master authored Sep 4, 2024
2 parents 7e044ea + ad652e5 commit 2c6de75
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 39 deletions.
6 changes: 3 additions & 3 deletions .changes/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
"dryRunCommand": true
},
{
"command": "cargo generate-lockfile",
"command": "echo '<details>\n<summary><em><h4>Cargo Audit</h4></em></summary>\n\n```'",
"dryRunCommand": true,
"runFromRoot": true,
"pipe": true
},
{
"command": "echo '<details>\n<summary><em><h4>Cargo Audit</h4></em></summary>\n\n```'",
"command": "cargo generate-lockfile",
"dryRunCommand": true,
"runFromRoot": true,
"pipe": true
},
{
Expand Down
5 changes: 5 additions & 0 deletions .changes/ios-custom-url-schemes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": patch
---

On iOS, implement `application:openURL:options:` to handle custom URL schemes.
5 changes: 0 additions & 5 deletions .changes/kde-taskbar-progress.md

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions src/platform/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -77,7 +77,7 @@ pub trait WindowExtUnix {
fn default_vbox(&self) -> Option<&gtk::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 {
Expand All @@ -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<T: 'static>(
Expand Down
7 changes: 4 additions & 3 deletions src/platform/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::path::Path;

use crate::{
dpi::PhysicalSize,
error::ExternalError,
event::DeviceId,
event_loop::EventLoopBuilder,
monitor::MonitorHandle,
Expand Down Expand Up @@ -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.
///
Expand Down Expand Up @@ -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]
Expand Down
51 changes: 39 additions & 12 deletions src/platform_impl/ios/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion src/platform_impl/linux/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/windows/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2211,7 +2211,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
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);
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/windows/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub fn from_point(x: f64, y: f64) -> Option<MonitorHandle> {
MONITOR_DEFAULTTONULL,
)
};
if hmonitor.is_invalid() {
if !hmonitor.is_invalid() {
Some(MonitorHandle::new(hmonitor))
} else {
None
Expand Down
17 changes: 9 additions & 8 deletions src/platform_impl/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -1194,7 +1194,7 @@ unsafe fn init<T: 'static>(
.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);

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 2c6de75

Please sign in to comment.