From c037a02096bdb1ee3ae5b1c894bf5585ae62f236 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Mon, 12 Apr 2021 07:52:14 -0700 Subject: Win32: Fix fullscreen errors using Taskbar system menu Changing window state using taskbar system menu could result in a titleless window. Differential Revision: https://developer.blender.org/D10812 Reviewed by Ray Molenkamp --- intern/ghost/intern/GHOST_SystemWin32.cpp | 17 ++++++++++++++--- intern/ghost/intern/GHOST_WindowWin32.cpp | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 430e8216ae3..38dea9c1142 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -1442,12 +1442,23 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, */ break; case WM_SYSCOMMAND: - /* The WM_SYSCHAR message is sent to the window when system commands such as + /* The WM_SYSCOMMAND message is sent to the window when system commands such as * maximize, minimize or close the window are triggered. Also it is sent when ALT * button is press for menu. To prevent this we must return preventing DefWindowProc. + * + * Note that the four low-order bits of the wParam parameter are used internally by the + * OS. To obtain the correct result when testing the value of wParam, an application + * must combine the value 0xFFF0 with the wParam value by using the bitwise AND operator. */ - if (wParam == SC_KEYMENU) { - eventHandled = true; + switch (wParam & 0xFFF0) { + case SC_KEYMENU: + eventHandled = true; + break; + case SC_RESTORE: + ::ShowWindow(hwnd, SW_RESTORE); + window->setState(window->getState()); + eventHandled = true; + break; } break; //////////////////////////////////////////////////////////////////////// diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 28ce1381562..ef155d96f99 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -521,7 +521,7 @@ GHOST_TSuccess GHOST_WindowWin32::setState(GHOST_TWindowState state) switch (state) { case GHOST_kWindowStateMinimized: - wp.showCmd = SW_SHOWMINIMIZED; + wp.showCmd = SW_MINIMIZE; break; case GHOST_kWindowStateMaximized: wp.showCmd = SW_SHOWMAXIMIZED; -- cgit v1.2.3