Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/mobile-resumed-suspended-event.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri": minor:changes
"tauri-runtime-wry": minor:changes
---

`WindowEvent::Resumed` and `WindowEvent::Suspended` are now only fired for the matching activity window instead of every window.
5 changes: 5 additions & 0 deletions .changes/update-dom-query.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri-utils": minor:deps
---

Updated `dom_query` dependency to 0.28.0
63 changes: 40 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions crates/tauri-runtime-wry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ edition.workspace = true
rust-version.workspace = true

[dependencies]
wry = { version = "0.55.0", default-features = false, features = [
"protocol",
wry = { version = "0.56.0", default-features = false, features = [
"os-webview",
"linux-body",
] }
tao = { version = "0.35.0", default-features = false, features = ["rwh_06"] }
tao = { version = "0.36.0", default-features = false, features = ["rwh_06"] }
tauri-runtime = { version = "2.11.3", path = "../tauri-runtime" }
tauri-utils = { version = "2.9.3", path = "../tauri-utils" }
raw-window-handle = "0.6"
Expand Down Expand Up @@ -62,11 +61,7 @@ jni = "0.21"
default = ["x11", "dbus"]
devtools = ["wry/devtools", "tauri-runtime/devtools"]
x11 = ["tao/x11", "wry/x11"]
macos-private-api = [
"wry/fullscreen",
"wry/transparent",
"tauri-runtime/macos-private-api",
]
macos-private-api = ["tauri-runtime/macos-private-api"]
# TODO: Remove in v3 - wry does not have this feature anymore
objc-exception = []
tracing = ["dep:tracing", "wry/tracing"]
Expand Down
48 changes: 10 additions & 38 deletions crates/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,7 @@ impl TryFrom<Icon<'_>> for TaoIcon {
pub struct WindowEventWrapper(pub Option<WindowEvent>);

impl WindowEventWrapper {
fn map_from_tao(
event: &TaoWindowEvent<'_>,
#[allow(unused_variables)] window: &WindowWrapper,
) -> Self {
fn map_from_tao(event: &TaoWindowEvent<'_>, #[cfg(windows)] window: &WindowWrapper) -> Self {
let event = match event {
TaoWindowEvent::Resized(size) => WindowEvent::Resized(*size),
TaoWindowEvent::Moved(position) => WindowEvent::Moved(*position),
Expand Down Expand Up @@ -557,6 +554,10 @@ impl WindowEventWrapper {
}
}
TaoWindowEvent::ThemeChanged(theme) => WindowEvent::ThemeChanged(map_theme(theme)),
#[cfg(mobile)]
TaoWindowEvent::Suspended => WindowEvent::Suspended,
#[cfg(mobile)]
TaoWindowEvent::Resumed => WindowEvent::Resumed,
_ => return Self(None),
};
Self(Some(event))
Expand All @@ -578,7 +579,11 @@ impl WindowEventWrapper {
Self(None)
}
}
e => Self::map_from_tao(e, window),
e => Self::map_from_tao(
e,
#[cfg(windows)]
window,
),
}
}
}
Expand Down Expand Up @@ -4334,39 +4339,6 @@ fn handle_event_loop<T: UserEvent>(
Event::SceneRequested { scene, options } => {
callback(RunEvent::SceneRequested { scene, options });
}
#[cfg(mobile)]
e @ Event::Resumed | e @ Event::Suspended => {
let event = match e {
Event::Resumed => WindowEvent::Resumed,
Event::Suspended => WindowEvent::Suspended,
_ => unreachable!(),
};

// Collect the per-window listener handles and release the `windows`
// borrow before dispatching: handlers and the `RunEvent` callback may
// create or close windows (`windows.0.borrow_mut()`), which would panic
// the `RefCell` if we held the borrow across them. The desktop
// `WindowEvent` branches drop the borrow before dispatching for the same
// reason; this mobile `Resumed`/`Suspended` branch was the exception.
let targets = windows
.0
.borrow()
.values()
.map(|w| (w.label.clone(), w.window_event_listeners.clone()))
.collect::<Vec<_>>();

for (label, window_event_listeners) in targets {
let listeners = window_event_listeners.lock().unwrap();
for handler in listeners.values() {
handler(&event);
}

callback(RunEvent::WindowEvent {
label,
event: event.clone(),
});
}
}
_ => (),
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ brotli = { version = "8", optional = true, default-features = false, features =
url = { version = "2", features = ["serde"] }
html5ever = { version = "0.29", optional = true }
kuchiki = { package = "kuchikiki", version = "0.8.8-speedreader", optional = true }
dom_query = { version = "0.27", optional = true, default-features = false }
dom_query = { version = "0.28", optional = true, default-features = false }
proc-macro2 = { version = "1", optional = true }
quote = { version = "1", optional = true }
# Our code requires at least 0.8.21 so don't change this to 0.8
Expand Down
37 changes: 16 additions & 21 deletions crates/tauri/mobile/android-codegen/TauriActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,13 @@ import android.content.Intent
import android.content.res.Configuration
import android.os.Bundle
import app.tauri.plugin.PluginManager
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ProcessLifecycleOwner

object TauriLifecycleObserver : DefaultLifecycleObserver {
override fun onResume(owner: LifecycleOwner) {
super.onResume(owner)
PluginManager.onResume()
}

override fun onPause(owner: LifecycleOwner) {
super.onPause(owner)
PluginManager.onPause()
}

override fun onStop(owner: LifecycleOwner) {
super.onStop(owner)
PluginManager.onStop()
}
}

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

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
PluginManager.onActivityCreate(this)
PluginManager.onCreate(this)
}

fun getPluginManager(): PluginManager {
Expand All @@ -53,6 +33,21 @@ abstract class TauriActivity : WryActivity() {
PluginManager.onRestart(this)
}

override fun onResume() {
super.onResume()
PluginManager.onResume(this)
}

override fun onPause() {
super.onPause()
PluginManager.onPause(this)
}

override fun onStop() {
super.onStop()
PluginManager.onStop(this)
}

override fun onDestroy() {
super.onDestroy()
PluginManager.onDestroy(this)
Expand Down
Loading
Loading