diff --git a/Cargo.toml b/Cargo.toml index 2c04531..7986885 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,9 +12,13 @@ crate-type = ["cdylib"] [dependencies] napi = { version = "3.8.2", default-features = true, features = ["napi9"] } napi-derive = "3.5.1" -tao = "0.34.5" +tao = { version = "0.34.5", features = ["rwh_06"] } wry = { version = "0.53.5", features = ["devtools", "fullscreen"] } +[target.'cfg(target_os = "linux")'.dependencies] +gtk = "0.18" +glib = "0.18" + [build-dependencies] napi-build = "2" diff --git a/src/webview.rs b/src/webview.rs index 35f5e05..29fd4fb 100644 --- a/src/webview.rs +++ b/src/webview.rs @@ -9,6 +9,11 @@ use napi_derive::*; use tao::dpi::{LogicalPosition, LogicalSize}; use wry::{http::Request, Rect, WebViewBuilder}; +#[cfg(target_os = "linux")] +use tao::platform::unix::WindowExtUnix; +#[cfg(target_os = "linux")] +use wry::WebViewBuilderExtUnix; + use crate::{HeaderData, IpcMessage}; /// Represents the theme of the window. @@ -215,25 +220,20 @@ impl JsWebview { ) }; - #[cfg(not(target_os = "linux"))] let webview = { - if options.child.unwrap_or(false) { - webview.build_as_child(&window).map_err(handle_build_error) - } else { - webview.build(&window).map_err(handle_build_error) + #[cfg(target_os = "linux")] + { + webview.build_gtk(window.default_vbox().unwrap()).map_err(handle_build_error) } - }?; - - #[cfg(target_os = "linux")] - let webview = { - if options.child.unwrap_or(false) { - webview - .build_as_child(&window) - .map_err(handle_build_error)? - } else { - webview.build(&window).map_err(handle_build_error)? + #[cfg(not(target_os = "linux"))] + { + if options.child.unwrap_or(false) { + webview.build_as_child(window).map_err(handle_build_error) + } else { + webview.build(window).map_err(handle_build_error) + } } - }; + }?; Ok(Self { webview_inner: webview,