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.
This commit is contained in:
David Rowe 2015-02-09 22:07:12 -08:00
parent 9aa9dac7f3
commit 4fa2b3a6e9
3 changed files with 14 additions and 4 deletions

View file

@ -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<AddressManager>()->handleLookupString(url.toString());
return true;
}
}
}

View file

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

View file

@ -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) {