Windows: Alt-F4 hotkey should be checked on keydown, not keyup (thanks, Matt!).

Fixes Bugzilla #2780.
This commit is contained in:
Ryan C. Gordon 2015-05-26 20:40:00 -04:00
parent 72a244da41
commit 41908548b9
1 changed files with 10 additions and 8 deletions

View File

@ -549,6 +549,16 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_SYSKEYDOWN: case WM_SYSKEYDOWN:
{ {
SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam); SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam);
const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);
/* Detect relevant keyboard shortcuts */
if (keyboardState[SDL_SCANCODE_LALT] == SDL_PRESSED || keyboardState[SDL_SCANCODE_RALT] == SDL_PRESSED) {
/* ALT+F4: Close window */
if (code == SDL_SCANCODE_F4) {
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0);
}
}
if (code != SDL_SCANCODE_UNKNOWN) { if (code != SDL_SCANCODE_UNKNOWN) {
SDL_SendKeyboardKey(SDL_PRESSED, code); SDL_SendKeyboardKey(SDL_PRESSED, code);
} }
@ -577,14 +587,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam); SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam);
const Uint8 *keyboardState = SDL_GetKeyboardState(NULL); const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);
/* Detect relevant keyboard shortcuts */
if (keyboardState[SDL_SCANCODE_LALT] == SDL_PRESSED || keyboardState[SDL_SCANCODE_RALT] == SDL_PRESSED) {
/* ALT+F4: Close window */
if (code == SDL_SCANCODE_F4) {
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0);
}
}
if (code != SDL_SCANCODE_UNKNOWN) { if (code != SDL_SCANCODE_UNKNOWN) {
if (code == SDL_SCANCODE_PRINTSCREEN && if (code == SDL_SCANCODE_PRINTSCREEN &&
keyboardState[code] == SDL_RELEASED) { keyboardState[code] == SDL_RELEASED) {