extend bring to front
This commit is contained in:
parent
5e4838467a
commit
a36bfead69
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ Rectangle {
|
|||
|
||||
animation.start()
|
||||
window.visible = true
|
||||
utils.bringWindowToFront(window.wid)
|
||||
utils.bringWindowToFront(window.wid, false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue