Skip to content

Commit 7cc68e7

Browse files
feat: update tao to 0.36 and wry to 0.56 (#15307)
* feat: changes for tauri 0.36 * Tao 0.36 wry 0.56 events (#15789) * use git version of tao and wry * Migrate window events * use my wry branch * Gate behind mobile * tao 0.36 * wry 0.56 and dom_query 0.28 * change tag * Use `onCreate` exclusively --------- Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com>
1 parent 872428f commit 7cc68e7

9 files changed

Lines changed: 122 additions & 99 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri": minor:changes
3+
"tauri-runtime-wry": minor:changes
4+
---
5+
6+
`WindowEvent::Resumed` and `WindowEvent::Suspended` are now only fired for the matching activity window instead of every window.

‎.changes/update-dom-query.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-utils": minor:deps
3+
---
4+
5+
Updated `dom_query` dependency to 0.28.0

‎Cargo.lock‎

Lines changed: 40 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/tauri-runtime-wry/Cargo.toml‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ edition.workspace = true
1313
rust-version.workspace = true
1414

1515
[dependencies]
16-
wry = { version = "0.55.0", default-features = false, features = [
17-
"protocol",
16+
wry = { version = "0.56.0", default-features = false, features = [
1817
"os-webview",
1918
"linux-body",
2019
] }
21-
tao = { version = "0.35.0", default-features = false, features = ["rwh_06"] }
20+
tao = { version = "0.36.0", default-features = false, features = ["rwh_06"] }
2221
tauri-runtime = { version = "2.11.3", path = "../tauri-runtime" }
2322
tauri-utils = { version = "2.9.3", path = "../tauri-utils" }
2423
raw-window-handle = "0.6"
@@ -62,11 +61,7 @@ jni = "0.21"
6261
default = ["x11", "dbus"]
6362
devtools = ["wry/devtools", "tauri-runtime/devtools"]
6463
x11 = ["tao/x11", "wry/x11"]
65-
macos-private-api = [
66-
"wry/fullscreen",
67-
"wry/transparent",
68-
"tauri-runtime/macos-private-api",
69-
]
64+
macos-private-api = ["tauri-runtime/macos-private-api"]
7065
# TODO: Remove in v3 - wry does not have this feature anymore
7166
objc-exception = []
7267
tracing = ["dep:tracing", "wry/tracing"]

‎crates/tauri-runtime-wry/src/lib.rs‎

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -495,10 +495,7 @@ impl TryFrom<Icon<'_>> for TaoIcon {
495495
pub struct WindowEventWrapper(pub Option<WindowEvent>);
496496

497497
impl WindowEventWrapper {
498-
fn map_from_tao(
499-
event: &TaoWindowEvent<'_>,
500-
#[allow(unused_variables)] window: &WindowWrapper,
501-
) -> Self {
498+
fn map_from_tao(event: &TaoWindowEvent<'_>, #[cfg(windows)] window: &WindowWrapper) -> Self {
502499
let event = match event {
503500
TaoWindowEvent::Resized(size) => WindowEvent::Resized(*size),
504501
TaoWindowEvent::Moved(position) => WindowEvent::Moved(*position),
@@ -557,6 +554,10 @@ impl WindowEventWrapper {
557554
}
558555
}
559556
TaoWindowEvent::ThemeChanged(theme) => WindowEvent::ThemeChanged(map_theme(theme)),
557+
#[cfg(mobile)]
558+
TaoWindowEvent::Suspended => WindowEvent::Suspended,
559+
#[cfg(mobile)]
560+
TaoWindowEvent::Resumed => WindowEvent::Resumed,
560561
_ => return Self(None),
561562
};
562563
Self(Some(event))
@@ -578,7 +579,11 @@ impl WindowEventWrapper {
578579
Self(None)
579580
}
580581
}
581-
e => Self::map_from_tao(e, window),
582+
e => Self::map_from_tao(
583+
e,
584+
#[cfg(windows)]
585+
window,
586+
),
582587
}
583588
}
584589
}
@@ -4334,39 +4339,6 @@ fn handle_event_loop<T: UserEvent>(
43344339
Event::SceneRequested { scene, options } => {
43354340
callback(RunEvent::SceneRequested { scene, options });
43364341
}
4337-
#[cfg(mobile)]
4338-
e @ Event::Resumed | e @ Event::Suspended => {
4339-
let event = match e {
4340-
Event::Resumed => WindowEvent::Resumed,
4341-
Event::Suspended => WindowEvent::Suspended,
4342-
_ => unreachable!(),
4343-
};
4344-
4345-
// Collect the per-window listener handles and release the `windows`
4346-
// borrow before dispatching: handlers and the `RunEvent` callback may
4347-
// create or close windows (`windows.0.borrow_mut()`), which would panic
4348-
// the `RefCell` if we held the borrow across them. The desktop
4349-
// `WindowEvent` branches drop the borrow before dispatching for the same
4350-
// reason; this mobile `Resumed`/`Suspended` branch was the exception.
4351-
let targets = windows
4352-
.0
4353-
.borrow()
4354-
.values()
4355-
.map(|w| (w.label.clone(), w.window_event_listeners.clone()))
4356-
.collect::<Vec<_>>();
4357-
4358-
for (label, window_event_listeners) in targets {
4359-
let listeners = window_event_listeners.lock().unwrap();
4360-
for handler in listeners.values() {
4361-
handler(&event);
4362-
}
4363-
4364-
callback(RunEvent::WindowEvent {
4365-
label,
4366-
event: event.clone(),
4367-
});
4368-
}
4369-
}
43704342
_ => (),
43714343
}
43724344
}

‎crates/tauri-utils/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ brotli = { version = "8", optional = true, default-features = false, features =
2424
url = { version = "2", features = ["serde"] }
2525
html5ever = { version = "0.29", optional = true }
2626
kuchiki = { package = "kuchikiki", version = "0.8.8-speedreader", optional = true }
27-
dom_query = { version = "0.27", optional = true, default-features = false }
27+
dom_query = { version = "0.28", optional = true, default-features = false }
2828
proc-macro2 = { version = "1", optional = true }
2929
quote = { version = "1", optional = true }
3030
# Our code requires at least 0.8.21 so don't change this to 0.8

‎crates/tauri/mobile/android-codegen/TauriActivity.kt‎

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,13 @@ import android.content.Intent
1010
import android.content.res.Configuration
1111
import android.os.Bundle
1212
import app.tauri.plugin.PluginManager
13-
import androidx.lifecycle.DefaultLifecycleObserver
14-
import androidx.lifecycle.LifecycleOwner
15-
import androidx.lifecycle.ProcessLifecycleOwner
16-
17-
object TauriLifecycleObserver : DefaultLifecycleObserver {
18-
override fun onResume(owner: LifecycleOwner) {
19-
super.onResume(owner)
20-
PluginManager.onResume()
21-
}
22-
23-
override fun onPause(owner: LifecycleOwner) {
24-
super.onPause(owner)
25-
PluginManager.onPause()
26-
}
27-
28-
override fun onStop(owner: LifecycleOwner) {
29-
super.onStop(owner)
30-
PluginManager.onStop()
31-
}
32-
}
3313

3414
abstract class TauriActivity : WryActivity() {
3515
override val handleBackNavigation: Boolean = false
3616

3717
override fun onCreate(savedInstanceState: Bundle?) {
3818
super.onCreate(savedInstanceState)
39-
PluginManager.onActivityCreate(this)
19+
PluginManager.onCreate(this)
4020
}
4121

4222
fun getPluginManager(): PluginManager {
@@ -53,6 +33,21 @@ abstract class TauriActivity : WryActivity() {
5333
PluginManager.onRestart(this)
5434
}
5535

36+
override fun onResume() {
37+
super.onResume()
38+
PluginManager.onResume(this)
39+
}
40+
41+
override fun onPause() {
42+
super.onPause()
43+
PluginManager.onPause(this)
44+
}
45+
46+
override fun onStop() {
47+
super.onStop()
48+
PluginManager.onStop(this)
49+
}
50+
5651
override fun onDestroy() {
5752
super.onDestroy()
5853
PluginManager.onDestroy(this)

0 commit comments

Comments
 (0)