From b83f6733ca5fea85e4209046b07b4a60600f0598 Mon Sep 17 00:00:00 2001 From: glx Date: Sat, 30 Jun 2007 15:13:55 +0000 Subject: [PATCH] (svn r10400) [0.5] -Backport from trunk (r10399): - Fix: [Windows] _wnd.has_focus was not properly set after using ALT-TAB [FS#962] (r10399) --- video/win32_v.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/video/win32_v.c b/video/win32_v.c index e111fdfac3..0a76a7d8ed 100644 --- a/video/win32_v.c +++ b/video/win32_v.c @@ -24,7 +24,6 @@ static struct { int height; int width_org; int height_org; - bool minimized; bool fullscreen; bool double_size; bool has_focus; @@ -512,8 +511,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP break; case WM_SIZE: - _wnd.minimized = (wParam == SIZE_MINIMIZED); - if (!_wnd.minimized) { + if (wParam != SIZE_MINIMIZED) { /* Set maximized flag when we maximize (obviously), but also when we * switched to fullscreen from a maximized state */ _window_maximize = (wParam == SIZE_MAXIMIZED || (_window_maximize && _fullscreen)); @@ -611,23 +609,34 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP return 0; } - case WM_ACTIVATEAPP: - _wnd.has_focus = (wParam != 0); + case WM_SETFOCUS: + _wnd.has_focus = true; + break; + + case WM_KILLFOCUS: + _wnd.has_focus = false; + break; + #if !defined(WINCE) + case WM_ACTIVATE: { + bool active = (LOWORD(wParam) != WA_INACTIVE); + bool minimized = (HIWORD(wParam) != 0); if (_wnd.fullscreen) { - if (_wnd.has_focus && _wnd.minimized) { + if (active && minimized) { /* Restore the game window */ ShowWindow(hwnd, SW_RESTORE); MakeWindow(true); - } else if (!_wnd.has_focus && !_wnd.minimized) { + } else if (!active && !minimized) { /* Minimise the window and restore desktop */ ShowWindow(hwnd, SW_MINIMIZE); ChangeDisplaySettings(NULL, 0); } } -#endif break; + } } +#endif + return DefWindowProc(hwnd, msg, wParam, lParam); }