mirror of
https://github.com/status-im/snorenotify.git
synced 2025-01-10 08:35:54 +00:00
extend bring to front
This commit is contained in:
parent
5e4838467a
commit
a36bfead69
@ -27,20 +27,19 @@
|
|||||||
|
|
||||||
using namespace Snore;
|
using namespace Snore;
|
||||||
|
|
||||||
void Utils::bringWindowToFront(qlonglong _wid)
|
void Utils::bringWindowToFront(qlonglong _wid, bool focus)
|
||||||
{
|
{
|
||||||
snoreDebug(SNORE_DEBUG) << _wid;
|
snoreDebug(SNORE_DEBUG) << _wid;
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
HWND wid = (HWND)_wid;
|
HWND wid = (HWND)_wid;
|
||||||
HWND hwndActiveWin = GetForegroundWindow();
|
int idActive = GetWindowThreadProcessId(GetForegroundWindow(), NULL);
|
||||||
int idActive = GetWindowThreadProcessId(hwndActiveWin, NULL);
|
bool attetched = AttachThreadInput(GetCurrentThreadId(), idActive, TRUE);
|
||||||
|
SetForegroundWindow(wid);
|
||||||
if (AttachThreadInput(GetCurrentThreadId(), idActive, TRUE)) {
|
if (focus) {
|
||||||
SetForegroundWindow(wid);
|
SetFocus(wid);
|
||||||
|
}
|
||||||
|
if (attetched) {
|
||||||
AttachThreadInput(GetCurrentThreadId(), idActive, FALSE);
|
AttachThreadInput(GetCurrentThreadId(), idActive, FALSE);
|
||||||
} else {
|
|
||||||
// try it anyhow
|
|
||||||
SetForegroundWindow(wid);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
~Utils();
|
~Utils();
|
||||||
|
|
||||||
//TODO: make Wid usable with the meta system and change signature.
|
//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()
|
animation.start()
|
||||||
window.visible = true
|
window.visible = true
|
||||||
utils.bringWindowToFront(window.wid)
|
utils.bringWindowToFront(window.wid, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user