extend bring to front

This commit is contained in:
Patrick von Reth 2015-04-13 20:14:34 +02:00
parent 5e4838467a
commit a36bfead69
3 changed files with 10 additions and 11 deletions

View File

@ -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
}

View File

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

View File

@ -45,7 +45,7 @@ Rectangle {
animation.start()
window.visible = true
utils.bringWindowToFront(window.wid)
utils.bringWindowToFront(window.wid, false)
}
}