Fixed #194: Scan Popup window doesn't get the keyboard focus on Linux.

Tested and verified on recent Unity, Gnome, KDE, LXDE systems.
This commit is contained in:
Tvangeste 2013-01-29 22:30:24 +01:00
parent d8decdae83
commit 3b7326e3be
2 changed files with 19 additions and 0 deletions

View file

@ -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();

View file

@ -71,6 +71,7 @@ signals:
#endif
public slots:
void requestWindowFocus();
/// Translates the word from the clipboard, showing the window etc.
void translateWordFromClipboard();