diff --git a/src-tauri/src/clipboard.rs b/src-tauri/src/clipboard.rs index 57972cb02..791ce2184 100644 --- a/src-tauri/src/clipboard.rs +++ b/src-tauri/src/clipboard.rs @@ -10,7 +10,7 @@ use tauri::{AppHandle, Manager}; use tauri_plugin_clipboard_manager::ClipboardExt; #[cfg(target_os = "linux")] -use crate::utils::{is_kde_wayland, is_wayland}; +use crate::utils::{is_gnome_wayland, is_kde_wayland, is_wayland}; /// Pastes text using the clipboard: saves current content, writes text, sends paste keystroke, restores clipboard. fn paste_via_clipboard( @@ -83,9 +83,11 @@ fn paste_via_clipboard( #[cfg(target_os = "linux")] fn try_send_key_combo_linux(paste_method: &PasteMethod) -> Result { if is_wayland() { - // Wayland: prefer wtype (but not on KDE), then dotool, then ydotool + // Wayland: prefer wtype (but not on KDE or GNOME), then dotool, then ydotool // Note: wtype doesn't work on KDE (no zwp_virtual_keyboard_manager_v1 support) - if !is_kde_wayland() && is_wtype_available() { + // or on GNOME/Mutter (same reason — Mutter deliberately does not implement + // the virtual-keyboard-v1 protocol). + if !is_kde_wayland() && !is_gnome_wayland() && is_wtype_available() { info!("Using wtype for key combo"); send_key_combo_via_wtype(paste_method)?; return Ok(true); @@ -166,7 +168,9 @@ fn try_direct_typing_linux(text: &str, preferred_tool: TypingTool) -> Result bool { pub fn is_kde_wayland() -> bool { is_wayland() && is_kde_plasma() } + +/// Check if running on GNOME desktop environment +#[cfg(target_os = "linux")] +pub fn is_gnome() -> bool { + std::env::var("XDG_CURRENT_DESKTOP") + .map(|v| v.to_uppercase().contains("GNOME")) + .unwrap_or(false) +} + +/// Check if running on GNOME with Wayland +#[cfg(target_os = "linux")] +pub fn is_gnome_wayland() -> bool { + is_wayland() && is_gnome() +}