mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-25 03:33:36 +03:00
refactor: remove unneeded focus code (#5065)
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
This commit is contained in:
parent
8183153a86
commit
e6d9b670b0
8
.changes/windows-update.md
Normal file
8
.changes/windows-update.md
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
"tauri-runtime-wry": minor
|
||||
"tauri-runtime": minor
|
||||
"tauri-utils": minor
|
||||
"tauri": minor
|
||||
---
|
||||
|
||||
Update windows to 0.39.0 and webview2-com to 0.19.1.
|
@ -29,3 +29,6 @@ codegen-units = 1
|
||||
lto = true
|
||||
incremental = false
|
||||
opt-level = "s"
|
||||
|
||||
[patch.crates-io]
|
||||
tao = { git = "https://github.com/tauri-apps/tao", branch = "dev" }
|
||||
|
@ -13,7 +13,7 @@ exclude = [ "CHANGELOG.md", "/target" ]
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
wry = { version = "0.20", default-features = false, features = [ "file-drop", "protocol" ] }
|
||||
wry = { git = "https://github.com/tauri-apps/wry", branch = "dev", default-features = false, features = [ "file-drop", "protocol" ] }
|
||||
tauri-runtime = { version = "0.10.2", path = "../tauri-runtime" }
|
||||
tauri-utils = { version = "1.0.3", path = "../tauri-utils" }
|
||||
uuid = { version = "1", features = [ "v4" ] }
|
||||
@ -21,10 +21,10 @@ rand = "0.8"
|
||||
raw-window-handle = "0.5"
|
||||
|
||||
[target."cfg(windows)".dependencies]
|
||||
webview2-com = "0.16.0"
|
||||
webview2-com = "0.19.1"
|
||||
|
||||
[target."cfg(windows)".dependencies.windows]
|
||||
version = "0.37.0"
|
||||
version = "0.39.0"
|
||||
features = [ "Win32_Foundation" ]
|
||||
|
||||
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
|
||||
|
@ -2669,23 +2669,6 @@ fn handle_event_loop<T: UserEvent>(
|
||||
event, window_id, ..
|
||||
} => {
|
||||
if let Some(window_id) = webview_id_map.get(&window_id) {
|
||||
// NOTE(amrbashir): we handle this event here instead of `match` statement below because
|
||||
// we want to focus the webview as soon as possible, especially on windows.
|
||||
if event == WryWindowEvent::Focused(true) {
|
||||
let w = windows
|
||||
.borrow()
|
||||
.get(&window_id)
|
||||
.and_then(|w| w.inner.clone());
|
||||
if let Some(WindowHandle::Webview(webview)) = w {
|
||||
// only focus the webview if the window is visible
|
||||
// somehow tao is sending a Focused(true) event even when the window is invisible,
|
||||
// which causes a deadlock: https://github.com/tauri-apps/tauri/issues/3534
|
||||
if webview.window().is_visible() {
|
||||
webview.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
let windows_ref = windows.borrow();
|
||||
if let Some(window) = windows_ref.get(&window_id) {
|
||||
@ -2980,7 +2963,7 @@ fn create_webview<T: UserEvent>(
|
||||
let mut token = EventRegistrationToken::default();
|
||||
unsafe {
|
||||
controller.add_GotFocus(
|
||||
FocusChangedEventHandler::create(Box::new(move |_, _| {
|
||||
&FocusChangedEventHandler::create(Box::new(move |_, _| {
|
||||
let _ = proxy_.send_event(Message::Webview(
|
||||
window_id,
|
||||
WebviewMessage::WebviewEvent(WebviewEvent::Focused(true)),
|
||||
@ -2993,7 +2976,7 @@ fn create_webview<T: UserEvent>(
|
||||
.unwrap();
|
||||
unsafe {
|
||||
controller.add_LostFocus(
|
||||
FocusChangedEventHandler::create(Box::new(move |_, _| {
|
||||
&FocusChangedEventHandler::create(Box::new(move |_, _| {
|
||||
let _ = proxy.send_event(Message::Webview(
|
||||
window_id,
|
||||
WebviewMessage::WebviewEvent(WebviewEvent::Focused(false)),
|
||||
|
@ -35,10 +35,10 @@ raw-window-handle = "0.5"
|
||||
rand = "0.8"
|
||||
|
||||
[target."cfg(windows)".dependencies]
|
||||
webview2-com = "0.16.0"
|
||||
webview2-com = "0.19.1"
|
||||
|
||||
[target."cfg(windows)".dependencies.windows]
|
||||
version = "0.37.0"
|
||||
version = "0.39.0"
|
||||
features = [ "Win32_Foundation" ]
|
||||
|
||||
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
|
||||
|
@ -40,9 +40,8 @@ semver = "1"
|
||||
heck = "0.4"
|
||||
|
||||
[target."cfg(windows)".dependencies.windows]
|
||||
version = "0.37.0"
|
||||
version = "0.39.0"
|
||||
features = [
|
||||
"alloc",
|
||||
"implement",
|
||||
"Win32_Foundation",
|
||||
"Win32_System_Com",
|
||||
|
@ -202,11 +202,15 @@ pub use windows_platform::{is_windows_7, windows_version};
|
||||
|
||||
#[cfg(windows)]
|
||||
mod windows_platform {
|
||||
use windows::Win32::{
|
||||
Foundation::FARPROC,
|
||||
System::{
|
||||
LibraryLoader::{GetProcAddress, LoadLibraryA},
|
||||
SystemInformation::OSVERSIONINFOW,
|
||||
use std::{iter::once, os::windows::prelude::OsStrExt};
|
||||
use windows::{
|
||||
core::{PCSTR, PCWSTR},
|
||||
Win32::{
|
||||
Foundation::FARPROC,
|
||||
System::{
|
||||
LibraryLoader::{GetProcAddress, LoadLibraryW},
|
||||
SystemInformation::OSVERSIONINFOW,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@ -221,11 +225,19 @@ mod windows_platform {
|
||||
false
|
||||
}
|
||||
|
||||
fn get_function_impl(library: &str, function: &str) -> Option<FARPROC> {
|
||||
assert_eq!(library.chars().last(), Some('\0'));
|
||||
assert_eq!(function.chars().last(), Some('\0'));
|
||||
fn encode_wide(string: impl AsRef<std::ffi::OsStr>) -> Vec<u16> {
|
||||
string.as_ref().encode_wide().chain(once(0)).collect()
|
||||
}
|
||||
|
||||
let module = unsafe { LoadLibraryA(library) }.unwrap_or_default();
|
||||
// Helper function to dynamically load function pointer.
|
||||
// `library` and `function` must be zero-terminated.
|
||||
fn get_function_impl(library: &str, function: &str) -> Option<FARPROC> {
|
||||
let library = encode_wide(library);
|
||||
assert_eq!(function.chars().last(), Some('\0'));
|
||||
let function = PCSTR::from_raw(function.as_ptr());
|
||||
|
||||
// Library names we will use are ASCII so we can use the A version to avoid string conversion.
|
||||
let module = unsafe { LoadLibraryW(PCWSTR::from_raw(library.as_ptr())) }.unwrap_or_default();
|
||||
if module.is_invalid() {
|
||||
None
|
||||
} else {
|
||||
|
@ -107,11 +107,11 @@ cocoa = "0.24"
|
||||
objc = "0.2"
|
||||
|
||||
[target."cfg(windows)".dependencies]
|
||||
webview2-com = "0.16.0"
|
||||
webview2-com = "0.19.1"
|
||||
win7-notifications = { version = "0.3.0", optional = true }
|
||||
|
||||
[target."cfg(windows)".dependencies.windows]
|
||||
version = "0.37.0"
|
||||
version = "0.39.0"
|
||||
features = [ "Win32_Foundation" ]
|
||||
|
||||
[build-dependencies]
|
||||
|
153
examples/api/src-tauri/Cargo.lock
generated
153
examples/api/src-tauri/Cargo.lock
generated
@ -3089,9 +3089,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tao"
|
||||
version = "0.13.2"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ad691ca9fca6c2c76c09ffcddf6ae6593fba65d95477cf31780910ed272f5b8"
|
||||
checksum = "a2093fa6bba3cc0c185b21c900de1b757e66637e78848cbcdda967b836d8c0ec"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cairo-rs",
|
||||
@ -3131,7 +3131,7 @@ dependencies = [
|
||||
"unicode-segmentation",
|
||||
"uuid 1.1.2",
|
||||
"windows 0.37.0",
|
||||
"windows-implement",
|
||||
"windows-implement 0.37.0",
|
||||
"x11-dl",
|
||||
]
|
||||
|
||||
@ -3203,9 +3203,9 @@ dependencies = [
|
||||
"url",
|
||||
"uuid 1.1.2",
|
||||
"webkit2gtk",
|
||||
"webview2-com",
|
||||
"webview2-com 0.16.0",
|
||||
"win7-notifications",
|
||||
"windows 0.37.0",
|
||||
"windows 0.39.0",
|
||||
"zip",
|
||||
]
|
||||
|
||||
@ -3276,8 +3276,8 @@ dependencies = [
|
||||
"tauri-utils",
|
||||
"thiserror",
|
||||
"uuid 1.1.2",
|
||||
"webview2-com",
|
||||
"windows 0.37.0",
|
||||
"webview2-com 0.19.1",
|
||||
"windows 0.39.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3293,8 +3293,8 @@ dependencies = [
|
||||
"tauri-utils",
|
||||
"uuid 1.1.2",
|
||||
"webkit2gtk",
|
||||
"webview2-com",
|
||||
"windows 0.37.0",
|
||||
"webview2-com 0.19.1",
|
||||
"windows 0.39.0",
|
||||
"wry",
|
||||
]
|
||||
|
||||
@ -3323,7 +3323,7 @@ dependencies = [
|
||||
"thiserror",
|
||||
"url",
|
||||
"walkdir",
|
||||
"windows 0.37.0",
|
||||
"windows 0.39.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3872,9 +3872,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a489a9420acabb3c2ed0434b6f71f6b56b9485ec32665a28dec1ee186d716e0f"
|
||||
dependencies = [
|
||||
"webview2-com-macros",
|
||||
"webview2-com-sys",
|
||||
"webview2-com-sys 0.16.0",
|
||||
"windows 0.37.0",
|
||||
"windows-implement",
|
||||
"windows-implement 0.37.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webview2-com"
|
||||
version = "0.19.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4a769c9f1a64a8734bde70caafac2b96cada12cd4aefa49196b3a386b8b4178"
|
||||
dependencies = [
|
||||
"webview2-com-macros",
|
||||
"webview2-com-sys 0.19.0",
|
||||
"windows 0.39.0",
|
||||
"windows-implement 0.39.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3899,7 +3911,22 @@ dependencies = [
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"windows 0.37.0",
|
||||
"windows-bindgen",
|
||||
"windows-bindgen 0.37.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webview2-com-sys"
|
||||
version = "0.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aac48ef20ddf657755fdcda8dfed2a7b4fc7e4581acce6fe9b88c3d64f29dee7"
|
||||
dependencies = [
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"windows 0.39.0",
|
||||
"windows-bindgen 0.39.0",
|
||||
"windows-metadata 0.39.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -4004,7 +4031,7 @@ version = "0.37.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57b543186b344cc61c85b5aab0d2e3adf4e0f99bc076eff9aa5927bcc0b8a647"
|
||||
dependencies = [
|
||||
"windows-implement",
|
||||
"windows-implement 0.37.0",
|
||||
"windows_aarch64_msvc 0.37.0",
|
||||
"windows_i686_gnu 0.37.0",
|
||||
"windows_i686_msvc 0.37.0",
|
||||
@ -4012,14 +4039,38 @@ dependencies = [
|
||||
"windows_x86_64_msvc 0.37.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows"
|
||||
version = "0.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1c4bd0a50ac6020f65184721f758dba47bb9fbc2133df715ec74a237b26794a"
|
||||
dependencies = [
|
||||
"windows-implement 0.39.0",
|
||||
"windows_aarch64_msvc 0.39.0",
|
||||
"windows_i686_gnu 0.39.0",
|
||||
"windows_i686_msvc 0.39.0",
|
||||
"windows_x86_64_gnu 0.39.0",
|
||||
"windows_x86_64_msvc 0.39.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-bindgen"
|
||||
version = "0.37.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0bed7be31ade0af08fec9b5343e9edcc005d22b1f11859b8a59b24797f5858e8"
|
||||
dependencies = [
|
||||
"windows-metadata",
|
||||
"windows-tokens",
|
||||
"windows-metadata 0.37.0",
|
||||
"windows-tokens 0.37.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-bindgen"
|
||||
version = "0.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68003dbd0e38abc0fb85b939240f4bce37c43a5981d3df37ccbaaa981b47cb41"
|
||||
dependencies = [
|
||||
"windows-metadata 0.39.0",
|
||||
"windows-tokens 0.39.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -4029,7 +4080,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67a1062e555f7d9d66fd1130ed4f7c6ec41a47529ee0850cd0e926d95b26bb14"
|
||||
dependencies = [
|
||||
"syn",
|
||||
"windows-tokens",
|
||||
"windows-tokens 0.37.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-implement"
|
||||
version = "0.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba01f98f509cb5dc05f4e5fc95e535f78260f15fea8fe1a8abdd08f774f1cee7"
|
||||
dependencies = [
|
||||
"syn",
|
||||
"windows-tokens 0.39.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -4038,6 +4099,12 @@ version = "0.37.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f33f2b90a6664e369c41ab5ff262d06f048fc9685d9bf8a0e99a47750bb0463"
|
||||
|
||||
[[package]]
|
||||
name = "windows-metadata"
|
||||
version = "0.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ee5e275231f07c6e240d14f34e1b635bf1faa1c76c57cfd59a5cdb9848e4278"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.36.1"
|
||||
@ -4057,6 +4124,12 @@ version = "0.37.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3263d25f1170419995b78ff10c06b949e8a986c35c208dc24333c64753a87169"
|
||||
|
||||
[[package]]
|
||||
name = "windows-tokens"
|
||||
version = "0.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f838de2fe15fe6bac988e74b798f26499a8b21a9d97edec321e79b28d1d7f597"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.32.0"
|
||||
@ -4075,6 +4148,12 @@ version = "0.37.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2623277cb2d1c216ba3b578c0f3cf9cdebeddb6e66b1b218bb33596ea7769c3a"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec7711666096bd4096ffa835238905bb33fb87267910e154b18b44eaabb340f2"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.24.0"
|
||||
@ -4099,6 +4178,12 @@ version = "0.37.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3925fd0b0b804730d44d4b6278c50f9699703ec49bcd628020f46f4ba07d9e1"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "763fc57100a5f7042e3057e7e8d9bdd7860d330070251a73d003563a3bb49e1b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.24.0"
|
||||
@ -4123,6 +4208,12 @@ version = "0.37.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce907ac74fe331b524c1298683efbf598bb031bc84d5e274db2083696d07c57c"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7bc7cbfe58828921e10a9f446fcaaf649204dcfe6c1ddd712c5eebae6bda1106"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.24.0"
|
||||
@ -4147,6 +4238,12 @@ version = "0.37.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2babfba0828f2e6b32457d5341427dcbb577ceef556273229959ac23a10af33d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6868c165637d653ae1e8dc4d82c25d4f97dd6605eaa8d784b5c6e0ab2a252b65"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.24.0"
|
||||
@ -4171,6 +4268,12 @@ version = "0.37.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4dd6dc7df2d84cf7b33822ed5b86318fb1781948e9663bacd047fc9dd52259d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e4d40883ae9cae962787ca76ba76390ffa29214667a111db9e0a1ad8377e809"
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.10.1"
|
||||
@ -4202,18 +4305,21 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wry"
|
||||
version = "0.20.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22a806297d9fae9fef5a9d52480e5edc5452f97ea9d15b55c8a58ab93c9582f1"
|
||||
version = "0.20.2"
|
||||
source = "git+https://github.com/tauri-apps/wry?branch=dev#854d2226f4161d4fc783f64e79b6a8add31ac4eb"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"block",
|
||||
"cocoa",
|
||||
"core-graphics",
|
||||
"crossbeam-channel",
|
||||
"gdk",
|
||||
"gio",
|
||||
"glib",
|
||||
"gtk",
|
||||
"html5ever",
|
||||
"http",
|
||||
"kuchiki",
|
||||
"libc",
|
||||
"log",
|
||||
"objc",
|
||||
@ -4221,14 +4327,15 @@ dependencies = [
|
||||
"once_cell",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"tao",
|
||||
"thiserror",
|
||||
"url",
|
||||
"webkit2gtk",
|
||||
"webkit2gtk-sys",
|
||||
"webview2-com",
|
||||
"windows 0.37.0",
|
||||
"windows-implement",
|
||||
"webview2-com 0.19.1",
|
||||
"windows 0.39.0",
|
||||
"windows-implement 0.39.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
Loading…
Reference in New Issue
Block a user