mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
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:
parent
d8decdae83
commit
3b7326e3be
18
scanpopup.cc
18
scanpopup.cc
|
@ -752,10 +752,28 @@ 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();
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ signals:
|
|||
#endif
|
||||
|
||||
public slots:
|
||||
void requestWindowFocus();
|
||||
|
||||
/// Translates the word from the clipboard, showing the window etc.
|
||||
void translateWordFromClipboard();
|
||||
|
|
Loading…
Reference in a new issue