From 4fa2b3a6e99bbb11abc68d1b1e87a6c71cc09f54 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 9 Feb 2015 22:07:12 -0800 Subject: [PATCH] Fix maximized Windows window unintentionally changing to windowed This stops a maximized Windows window changing to being windowed when you click on a menu item. --- interface/src/Application.cpp | 13 +++++++++++-- interface/src/Application.h | 2 ++ interface/src/main.cpp | 3 +-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 95b8cbb835..aa24711509 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -156,18 +156,27 @@ public: bool nativeEventFilter(const QByteArray &eventType, void* msg, long* result) Q_DECL_OVERRIDE { if (eventType == "windows_generic_MSG") { MSG* message = (MSG*)msg; + if (message->message == UWM_IDENTIFY_INSTANCES) { *result = UWM_IDENTIFY_INSTANCES; return true; } - if (message->message == WM_SHOWWINDOW) { - Application::getInstance()->getWindow()->showNormal(); + + if (message->message == UWM_SHOW_APPLICATION) { + MainWindow* applicationWindow = Application::getInstance()->getWindow(); + if (applicationWindow->isMinimized()) { + applicationWindow->showNormal(); // Restores to windowed or maximized state appropriately. + } + Application::getInstance()->setActiveWindow(applicationWindow); // Flashes the taskbar icon if not focus. + return true; } + if (message->message == WM_COPYDATA) { COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)(message->lParam); QUrl url = QUrl((const char*)(pcds->lpData)); if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) { DependencyManager::get()->handleLookupString(url.toString()); + return true; } } } diff --git a/interface/src/Application.h b/interface/src/Application.h index e131766309..d015d09035 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -117,6 +117,8 @@ static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-entities-commands.html #ifdef Q_OS_WIN static const UINT UWM_IDENTIFY_INSTANCES = RegisterWindowMessage("UWM_IDENTIFY_INSTANCES_{8AB82783-B74A-4258-955B-8188C22AA0D6}"); +static const UINT UWM_SHOW_APPLICATION = + RegisterWindowMessage("UWM_SHOW_APPLICATION_{71123FD6-3DA8-4DC1-9C27-8A12A6250CBA}"); #endif class Application; diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 4881bd4ff4..61278821ee 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -46,8 +46,7 @@ int main(int argc, const char * argv[]) { HWND otherInstance = NULL; EnumWindows(enumWindowsCallback, (LPARAM)&otherInstance); if (otherInstance) { - ShowWindow(otherInstance, SW_RESTORE); - SetForegroundWindow(otherInstance); + SendMessage(otherInstance, UWM_SHOW_APPLICATION, 0, 0); QUrl url = QUrl(argv[1]); if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) {