소스 검색

fix(tauri-runtime-wry): window inner size regression on macOS, closes #9236 (#9276)

* fix(tauri-runtime-wry): window inner size regression on macOS, closes #9236

* lint
Lucas Fernandes Nogueira 1 년 전
부모
커밋
e7cd973123
4개의 변경된 파일16개의 추가작업 그리고 11개의 파일을 삭제
  1. 5 0
      .changes/fix-inner-size.md
  2. 7 9
      core/tauri-runtime-wry/src/lib.rs
  3. 2 0
      core/tauri-utils/src/platform/starting_binary.rs
  4. 2 2
      core/tauri/src/resources/mod.rs

+ 5 - 0
.changes/fix-inner-size.md

@@ -0,0 +1,5 @@
+---
+"tauri-runtime-wry": patch:bug
+---
+
+Fix window inner size evaluation on macOS.

+ 7 - 9
core/tauri-runtime-wry/src/lib.rs

@@ -436,14 +436,12 @@ impl WindowEventWrapper {
       // because wry replaces the NSView
       TaoWindowEvent::Resized(_) => {
         if let Some(w) = &window.inner {
-          Self(Some(WindowEvent::Resized(
-            PhysicalSizeWrapper(inner_size(
-              w,
-              &window.webviews,
-              window.has_children.load(Ordering::Relaxed),
-            ))
-            .into(),
-          )))
+          let size = inner_size(
+            w,
+            &window.webviews,
+            window.has_children.load(Ordering::Relaxed),
+          );
+          Self(Some(WindowEvent::Resized(PhysicalSizeWrapper(size).into())))
         } else {
           Self(None)
         }
@@ -3915,7 +3913,7 @@ fn inner_size(
   webviews: &[WebviewWrapper],
   has_children: bool,
 ) -> TaoPhysicalSize<u32> {
-  if has_children && webviews.len() == 1 {
+  if !has_children {
     use wry::WebViewExtMacOS;
     let webview = webviews.first().unwrap();
     let view_frame = unsafe { cocoa::appkit::NSView::frame(webview.webview()) };

+ 2 - 0
core/tauri-utils/src/platform/starting_binary.rs

@@ -41,6 +41,8 @@ impl StartingBinary {
   ///
   /// Because [`Error`] is not clone-able, it is recreated instead.
   pub(super) fn cloned(&self) -> Result<PathBuf> {
+    // false positive
+    #[allow(clippy::useless_asref)]
     self
       .0
       .as_ref()

+ 2 - 2
core/tauri/src/resources/mod.rs

@@ -127,7 +127,7 @@ impl ResourceTable {
       .index
       .get(&rid)
       .and_then(|rc| rc.downcast_arc::<T>())
-      .map(Clone::clone)
+      .cloned()
       .ok_or_else(|| Error::BadResourceId(rid))
   }
 
@@ -137,7 +137,7 @@ impl ResourceTable {
     self
       .index
       .get(&rid)
-      .map(Clone::clone)
+      .cloned()
       .ok_or_else(|| Error::BadResourceId(rid))
   }