fix error
This commit is contained in:
@@ -8,6 +8,15 @@ use x11mod::{
|
|||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
|
// X11 reparenting requires our own window to be an X11 window. On Wayland
|
||||||
|
// sessions, GTK defaults to the Wayland backend and embedding is impossible.
|
||||||
|
// Force the X11 backend (via XWayland on Wayland sessions) so we always get
|
||||||
|
// an X11 toplevel we can reparent into.
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
{
|
||||||
|
std::env::set_var("GDK_BACKEND", "x11");
|
||||||
|
}
|
||||||
|
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.manage(PtyState::default())
|
.manage(PtyState::default())
|
||||||
.manage(X11State::new())
|
.manage(X11State::new())
|
||||||
|
|||||||
@@ -104,9 +104,12 @@ fn fetch_tauri_xid(app: &AppHandle, window: tauri::WebviewWindow) -> Result<u32,
|
|||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
let gtk_win = window.gtk_window().map_err(|e| e.to_string())?;
|
let gtk_win = window.gtk_window().map_err(|e| e.to_string())?;
|
||||||
let gdk_win = gtk_win.window().ok_or_else(|| "no GDK window yet".to_string())?;
|
let gdk_win = gtk_win.window().ok_or_else(|| "no GDK window yet".to_string())?;
|
||||||
let x11: gdkx11::X11Window = gdk_win
|
let x11: gdkx11::X11Window = gdk_win.downcast().map_err(|_| {
|
||||||
.downcast()
|
"Tauri's window is not an X11 window — likely running on Wayland. \
|
||||||
.map_err(|_| "GDK window is not an X11Window".to_string())?;
|
GDK_BACKEND=x11 should force X11; check that XWayland is installed \
|
||||||
|
(apt install xwayland) and restart the app."
|
||||||
|
.to_string()
|
||||||
|
})?;
|
||||||
Ok(x11.xid() as u32)
|
Ok(x11.xid() as u32)
|
||||||
})();
|
})();
|
||||||
let _ = tx.send(result);
|
let _ = tx.send(result);
|
||||||
|
|||||||
Reference in New Issue
Block a user