mirror of https://github.com/OpenTTD/OpenTTD
(svn r10399) -Fix (FS#962): [Windows] _wnd.has_focus was not properly set after using ALT-TAB
parent
9043900ed6
commit
69586c94ae
|
@ -23,7 +23,6 @@ static struct {
|
||||||
int height;
|
int height;
|
||||||
int width_org;
|
int width_org;
|
||||||
int height_org;
|
int height_org;
|
||||||
bool minimized;
|
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
bool has_focus;
|
bool has_focus;
|
||||||
bool running;
|
bool running;
|
||||||
|
@ -508,8 +507,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
_wnd.minimized = (wParam == SIZE_MINIMIZED);
|
if (wParam != SIZE_MINIMIZED) {
|
||||||
if (!_wnd.minimized) {
|
|
||||||
/* Set maximized flag when we maximize (obviously), but also when we
|
/* Set maximized flag when we maximize (obviously), but also when we
|
||||||
* switched to fullscreen from a maximized state */
|
* switched to fullscreen from a maximized state */
|
||||||
_window_maximize = (wParam == SIZE_MAXIMIZED || (_window_maximize && _fullscreen));
|
_window_maximize = (wParam == SIZE_MAXIMIZED || (_window_maximize && _fullscreen));
|
||||||
|
@ -601,23 +599,34 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_ACTIVATEAPP:
|
case WM_SETFOCUS:
|
||||||
_wnd.has_focus = (wParam != 0);
|
_wnd.has_focus = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_KILLFOCUS:
|
||||||
|
_wnd.has_focus = false;
|
||||||
|
break;
|
||||||
|
|
||||||
#if !defined(WINCE)
|
#if !defined(WINCE)
|
||||||
|
case WM_ACTIVATE: {
|
||||||
|
bool active = (LOWORD(wParam) != WA_INACTIVE);
|
||||||
|
bool minimized = (HIWORD(wParam) != 0);
|
||||||
if (_wnd.fullscreen) {
|
if (_wnd.fullscreen) {
|
||||||
if (_wnd.has_focus && _wnd.minimized) {
|
if (active && minimized) {
|
||||||
/* Restore the game window */
|
/* Restore the game window */
|
||||||
ShowWindow(hwnd, SW_RESTORE);
|
ShowWindow(hwnd, SW_RESTORE);
|
||||||
MakeWindow(true);
|
MakeWindow(true);
|
||||||
} else if (!_wnd.has_focus && !_wnd.minimized) {
|
} else if (!active && !minimized) {
|
||||||
/* Minimise the window and restore desktop */
|
/* Minimise the window and restore desktop */
|
||||||
ShowWindow(hwnd, SW_MINIMIZE);
|
ShowWindow(hwnd, SW_MINIMIZE);
|
||||||
ChangeDisplaySettings(NULL, 0);
|
ChangeDisplaySettings(NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue