From eec2fae5b3bade0c0a687db167667445ba65d5ea Mon Sep 17 00:00:00 2001 From: Justin Bennett Date: Thu, 6 Mar 2025 03:15:35 +0000 Subject: [PATCH 1/2] Improve compat w/ X11 and Wayland on linux --- src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 0e44089..1f72565 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,7 +21,7 @@ use tao::{ }; use wry::http::header::{HeaderName, HeaderValue}; use wry::http::Response as HttpResponse; -use wry::WebViewBuilder; +use wry::{WebViewBuilder, WebViewBuilderExtUnix}; use actson::feeder::BufReaderJsonFeeder; use actson::{JsonEvent, JsonParser}; @@ -496,8 +496,16 @@ pub fn run(webview_options: Options) -> wry::Result<()> { if let Some(user_agent) = webview_options.user_agent { webview_builder = webview_builder.with_user_agent(user_agent.as_str()); } + #[cfg(not(target_os = "linux"))] let webview = webview_builder.build(&window)?; + #[cfg(target_os = "linux")] + let webview = { + use tao::platform::unix::WindowExtUnix; + let vbox = window.default_vbox().unwrap(); + webview_builder.build_gtk(vbox)? + }; + let notify_tx = tx.clone(); let notify = move |notification: Notification| { debug!(notification = ?notification, "Sending notification to client"); From 225238edee8b117bc2163add360285f038ffb239 Mon Sep 17 00:00:00 2001 From: Justin Bennett Date: Thu, 6 Mar 2025 03:20:33 +0000 Subject: [PATCH 2/2] Move unix import in linux cfg scope --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 1f72565..93ed8fb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,7 +21,7 @@ use tao::{ }; use wry::http::header::{HeaderName, HeaderValue}; use wry::http::Response as HttpResponse; -use wry::{WebViewBuilder, WebViewBuilderExtUnix}; +use wry::WebViewBuilder; use actson::feeder::BufReaderJsonFeeder; use actson::{JsonEvent, JsonParser}; @@ -502,6 +502,7 @@ pub fn run(webview_options: Options) -> wry::Result<()> { #[cfg(target_os = "linux")] let webview = { use tao::platform::unix::WindowExtUnix; + use wry::WebViewBuilderExtUnix; let vbox = window.default_vbox().unwrap(); webview_builder.build_gtk(vbox)? };