Fix Windows tray show foregrounding
This commit is contained in:
@@ -53,6 +53,7 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QMenuBar>
|
||||
#include <QScreen>
|
||||
#include <QWindow>
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
using namespace OCC;
|
||||
@@ -283,6 +284,9 @@ void Application::showSettings()
|
||||
ensureWindowIntersectsAvailableScreen(window);
|
||||
window->raise();
|
||||
window->activateWindow();
|
||||
if (auto *windowHandle = window->windowHandle()) {
|
||||
windowHandle->requestActivate();
|
||||
}
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
// Windows disallows raising a Window when you're not the active application.
|
||||
@@ -294,7 +298,9 @@ void Application::showSettings()
|
||||
foregroundThreadId != 0 && foregroundThreadId != currentThreadId && AttachThreadInput(currentThreadId, foregroundThreadId, true);
|
||||
|
||||
const auto hwnd = reinterpret_cast<HWND>(window->winId());
|
||||
ShowWindow(hwnd, SW_RESTORE);
|
||||
ShowWindow(hwnd, IsIconic(hwnd) ? SW_RESTORE : SW_SHOW);
|
||||
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||
SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||
SetForegroundWindow(hwnd);
|
||||
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user