mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-01-31 00:35:19 +01:00
fix linux impl
This commit is contained in:
@@ -3005,6 +3005,18 @@ pub(crate) fn create_webview<T: UserEvent>(
|
||||
|
||||
browser.set_bounds(bounds.as_ref());
|
||||
|
||||
// On Linux, explicitly set parent after creation as set_as_child may not work correctly
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
// Try to set parent - if window handle isn't available yet, this will be a no-op
|
||||
// but the browser should become visible once the handle is available
|
||||
browser.set_parent(&window);
|
||||
// Ensure browser is visible after setting parent
|
||||
browser.set_visible(1);
|
||||
// Set bounds again after reparenting to ensure correct size
|
||||
browser.set_bounds(bounds.as_ref());
|
||||
}
|
||||
|
||||
#[cfg(any(not(target_os = "macos"), feature = "macos-private-api"))]
|
||||
if webview_attributes.transparent {
|
||||
browser.set_background_color(0x00000000);
|
||||
@@ -3052,6 +3064,7 @@ pub(crate) fn create_webview<T: UserEvent>(
|
||||
}),
|
||||
);
|
||||
|
||||
println!(" browser view");
|
||||
let browser_view = browser_view_create(
|
||||
Some(&mut client),
|
||||
Some(&url),
|
||||
|
||||
@@ -91,6 +91,8 @@ impl CefBrowserExt for cef::Browser {
|
||||
rect.width as u32,
|
||||
rect.height as u32,
|
||||
);
|
||||
// Ensure window is mapped and raised after setting bounds
|
||||
(xlib.XMapRaised)(display, xid as xlib::Window);
|
||||
(xlib.XFlush)(display);
|
||||
(xlib.XCloseDisplay)(display);
|
||||
}
|
||||
@@ -161,6 +163,9 @@ impl CefBrowserExt for cef::Browser {
|
||||
};
|
||||
|
||||
let parent_xid = parent.window_handle() as u64;
|
||||
if parent_xid == 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
let Some(xlib) = X11.as_ref() else {
|
||||
return;
|
||||
@@ -172,6 +177,24 @@ impl CefBrowserExt for cef::Browser {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if window exists before reparenting
|
||||
let mut root: xlib::Window = 0;
|
||||
let mut parent_window: xlib::Window = 0;
|
||||
let mut children: *mut xlib::Window = std::ptr::null_mut();
|
||||
let mut nchildren: u32 = 0;
|
||||
let status = (xlib.XQueryTree)(
|
||||
display,
|
||||
xid as xlib::Window,
|
||||
&mut root,
|
||||
&mut parent_window,
|
||||
&mut children,
|
||||
&mut nchildren,
|
||||
);
|
||||
|
||||
if status != 0 && !children.is_null() {
|
||||
(xlib.XFree)(children as *mut std::ffi::c_void);
|
||||
}
|
||||
|
||||
(xlib.XReparentWindow)(
|
||||
display,
|
||||
xid as xlib::Window,
|
||||
@@ -179,6 +202,9 @@ impl CefBrowserExt for cef::Browser {
|
||||
0,
|
||||
0,
|
||||
);
|
||||
|
||||
// Ensure window is mapped and raised after reparenting
|
||||
(xlib.XMapRaised)(display, xid as xlib::Window);
|
||||
(xlib.XFlush)(display);
|
||||
(xlib.XCloseDisplay)(display);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user