浏览代码

fix: initialize linux wry webview

In the wry 0.32 examples the linux webviews are initialized in a
different way to render properly using
tao::platform::unix::WindowExtUnix. Tested with Gnome 45.3 and Wayland.
Fredrik Söderström 1 年之前
父节点
当前提交
47d15fc8a1
共有 1 个文件被更改,包括 22 次插入1 次删除
  1. 22 1
      packages/desktop/src/webview.rs

+ 22 - 1
packages/desktop/src/webview.rs

@@ -91,7 +91,28 @@ impl WebviewInstance {
             }
         };
 
-        let mut webview = WebViewBuilder::new(&window)
+        #[cfg(any(
+            target_os = "windows",
+            target_os = "macos",
+            target_os = "ios",
+            target_os = "android"
+        ))]
+        let mut webview = WebViewBuilder::new(&window);
+
+        #[cfg(not(any(
+            target_os = "windows",
+            target_os = "macos",
+            target_os = "ios",
+            target_os = "android"
+        )))]
+        let mut webview = {
+            use tao::platform::unix::WindowExtUnix;
+            use wry::WebViewBuilderExtUnix;
+            let vbox = window.default_vbox().unwrap();
+            WebViewBuilder::new_gtk(vbox)
+        };
+
+        webview = webview
             .with_transparent(cfg.window.window.transparent)
             .with_url("dioxus://index.html/")
             .unwrap()