diff --git a/src/libsnore/utils.cpp b/src/libsnore/utils.cpp index 8bda77d..5a9a2e8 100644 --- a/src/libsnore/utils.cpp +++ b/src/libsnore/utils.cpp @@ -27,20 +27,19 @@ using namespace Snore; -void Utils::bringWindowToFront(qlonglong _wid) +void Utils::bringWindowToFront(qlonglong _wid, bool focus) { snoreDebug(SNORE_DEBUG) << _wid; #ifdef Q_OS_WIN HWND wid = (HWND)_wid; - HWND hwndActiveWin = GetForegroundWindow(); - int idActive = GetWindowThreadProcessId(hwndActiveWin, NULL); - - if (AttachThreadInput(GetCurrentThreadId(), idActive, TRUE)) { - SetForegroundWindow(wid); + int idActive = GetWindowThreadProcessId(GetForegroundWindow(), NULL); + bool attetched = AttachThreadInput(GetCurrentThreadId(), idActive, TRUE); + SetForegroundWindow(wid); + if (focus) { + SetFocus(wid); + } + if (attetched) { AttachThreadInput(GetCurrentThreadId(), idActive, FALSE); - } else { - // try it anyhow - SetForegroundWindow(wid); } #endif } diff --git a/src/libsnore/utils.h b/src/libsnore/utils.h index 327ecbd..ec8442e 100644 --- a/src/libsnore/utils.h +++ b/src/libsnore/utils.h @@ -30,7 +30,7 @@ public: ~Utils(); //TODO: make Wid usable with the meta system and change signature. - Q_INVOKABLE void bringWindowToFront(qlonglong wid); + Q_INVOKABLE void bringWindowToFront(qlonglong wid, bool focus); }; diff --git a/src/plugins/backends/snore/notification.qml b/src/plugins/backends/snore/notification.qml index 2166ec0..e820c59 100644 --- a/src/plugins/backends/snore/notification.qml +++ b/src/plugins/backends/snore/notification.qml @@ -45,7 +45,7 @@ Rectangle { animation.start() window.visible = true - utils.bringWindowToFront(window.wid) + utils.bringWindowToFront(window.wid, false) } }