diff --git a/crates/menew-ui/src/lib.rs b/crates/menew-ui/src/lib.rs index e034046..4db2e9b 100644 --- a/crates/menew-ui/src/lib.rs +++ b/crates/menew-ui/src/lib.rs @@ -2055,12 +2055,19 @@ pub mod palette { self.notify("menew-queue", &tr("queue_done", lang, &[]), None); } self.queue_changed(); + // The queue action can be selected from the palette itself. Return focus to + // the previous app before sending Ctrl+V, then give GTK/Wayland time to publish + // the new clipboard contents to the compositor. + if self.window.is_visible() { + self.hide(); + } let mode = Config::load().paste_mode; match decide_paste(mode, menew_core::paste::uinput_writable()) { PasteAction::NotifyOnly => self.notify("menew-queue-next", &tr("queue_ready", lang, &[]), None), PasteAction::InjectCtrlV => { let this = Rc::clone(self); glib::spawn_future_local(async move { + glib::timeout_future(Duration::from_millis(menew_core::paste::FOCUS_DELAY_MS)).await; let result = gio::spawn_blocking(menew_core::paste::inject_ctrl_v).await; if !matches!(result, Ok(Ok(()))) { this.notify("menew-queue-next", &tr("queue_ready", lang, &[]), None); diff --git a/scripts/desktop-test/gnome.sh b/scripts/desktop-test/gnome.sh index 079676c..8782951 100755 --- a/scripts/desktop-test/gnome.sh +++ b/scripts/desktop-test/gnome.sh @@ -191,11 +191,13 @@ DE=gnome FIRST_TEXT="hello gnome" de_copy() { shell_copy_text "$1" >/dev/null; } de_clipboard_is() { - # St.Clipboard.get_text is asynchronous: store the result in a global, then read it back + # St.Clipboard.get_text is asynchronous: store the result in a global, then read it back. + # If Shell has not observed a compositor update yet, verify the selection through Wayland + # data-control as a second independent read path. shell_eval "globalThis.__menewClip = null; const St = imports.gi.St; St.Clipboard.get_default().get_text(St.ClipboardType.CLIPBOARD, (c, t) => { globalThis.__menewClip = t; }); 1" >/dev/null 2>&1 sleep 1 local out; out="$(shell_eval "globalThis.__menewClip" 2>/dev/null)" - [ "$out" = "(true, '\"$1\"')" ] || [ "$out" = "(true, '$1')" ] + [ "$out" = "(true, '\"$1\"')" ] || [ "$out" = "(true, '$1')" ] || clipboard_is "$1" } de_screenshot() { local res diff --git a/scripts/desktop-test/phase5.sh b/scripts/desktop-test/phase5.sh index 1dc3765..53c1671 100644 --- a/scripts/desktop-test/phase5.sh +++ b/scripts/desktop-test/phase5.sh @@ -2,7 +2,7 @@ # Phase 5 checks (images, files, filters, pause, smart actions, snippets, paste queue, OCR). # Sourced by gnome.sh and kde.sh after lib.sh. -db_sql() { sqlite3 "$MENEW_DB_PATH" "$1" 2>/dev/null; } +db_sql() { sqlite3 -cmd '.timeout 5000' "$MENEW_DB_PATH" "$1" 2>/dev/null; } images_dir() { echo "${MENEW_DB_PATH%.db}.images"; } count_kind() { db_sql "SELECT COUNT(*) FROM clipboard_entries WHERE kind='$1'"; }