From 0cea62699d3aeee77d9c363028303ba6e591ae2c Mon Sep 17 00:00:00 2001 From: wisherhxl Date: Mon, 23 May 2022 11:27:57 +0800 Subject: [PATCH] Linux-specific: workaround of clipboard issue with Ctrl+C+C Closes #1420, closes #650, closes #858. --- mainwindow.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mainwindow.cc b/mainwindow.cc index 4be02c6a..f06508cd 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -3095,7 +3095,19 @@ void MainWindow::hotKeyActivated( int hk ) toggleMainWindow(); else if ( scanPopup.get() ) + { +#ifdef HAVE_X11 + // When the user requests translation with the Ctrl+C+C hotkey in certain apps + // on some GNU/Linux systems, GoldenDict appears to handle Ctrl+C+C before the + // active application finishes handling Ctrl+C. As a result, GoldenDict finds + // the clipboard empty, silently cancels the translation request, and users report + // that Ctrl+C+C is broken in these apps. Slightly delay handling the clipboard + // hotkey to give the active application more time and thus work around the issue. + QTimer::singleShot( 10, scanPopup.get(), SLOT( translateWordFromClipboard() ) ); +#else scanPopup->translateWordFromClipboard(); +#endif + } } void MainWindow::prepareNewReleaseChecks()