diff --git a/scanpopup.cc b/scanpopup.cc index 9ebdbbcc..7262c94d 100644 --- a/scanpopup.cc +++ b/scanpopup.cc @@ -752,9 +752,27 @@ void ScanPopup::enterEvent( QEvent * event ) } } +void ScanPopup::requestWindowFocus() +{ + // One of the rare, actually working workarounds for requesting a user keyboard focus on X11, + // works for Qt::Popup windows, exactly like our Scan Popup (in unpinned state). + // Modern window managers actively resist to automatically focus pop-up windows. +#ifdef Q_WS_X11 + if ( !ui.pinButton->isChecked() ) + { + QMenu m( this ); + m.addAction( "" ); + m.show(); + m.hide(); + } +#endif +} + void ScanPopup::showEvent( QShowEvent * ev ) { QMainWindow::showEvent( ev ); + + QTimer::singleShot(100, this, SLOT( requestWindowFocus() ) ); if ( groups.size() <= 1 ) // Only the default group? Hide then. ui.groupList->hide(); diff --git a/scanpopup.hh b/scanpopup.hh index 1c40137d..e4e59c64 100644 --- a/scanpopup.hh +++ b/scanpopup.hh @@ -71,6 +71,7 @@ signals: #endif public slots: + void requestWindowFocus(); /// Translates the word from the clipboard, showing the window etc. void translateWordFromClipboard();