From 402b481d746f87df29ab535ab435dbbef77401c1 Mon Sep 17 00:00:00 2001 From: Abs62 Date: Sat, 29 Dec 2012 14:01:36 +0400 Subject: [PATCH] Focus GoldenDict window after restoring it from tray by hotkey under Ubuntu (issue #95) --- mainwindow.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mainwindow.cc b/mainwindow.cc index 5b6f033d..a063652a 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -33,6 +33,11 @@ #include "mouseover_win32/GDDataTranfer.h" #endif +#ifdef Q_WS_X11 +#include +#include +#endif + using std::set; using std::wstring; using std::map; @@ -2282,6 +2287,7 @@ void MainWindow::toggleMainWindow( bool onlyShow ) if ( !isVisible() ) { show(); + qApp->setActiveWindow( this ); activateWindow(); raise(); shown = true; @@ -2311,7 +2317,16 @@ void MainWindow::toggleMainWindow( bool onlyShow ) } if ( shown ) + { focusTranslateLine(); +#ifdef Q_WS_X11 + Window wh = 0; + int rev = 0; + XGetInputFocus( QX11Info::display(), &wh, &rev ); + if( wh != translateLine->internalWinId() ) + XSetInputFocus( QX11Info::display(), translateLine->internalWinId(), RevertToParent, CurrentTime ); +#endif + } } void MainWindow::installHotKeys()