[Windows] Fixes bug #1555, handle ALT+F4 on Windows
parent
f8e1d350a4
commit
5b8b403e3e
|
@ -535,9 +535,19 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
{
|
{
|
||||||
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 ) {
|
||||||
if (code == SDL_SCANCODE_PRINTSCREEN &&
|
if (code == SDL_SCANCODE_PRINTSCREEN &&
|
||||||
SDL_GetKeyboardState(NULL)[code] == SDL_RELEASED) {
|
keyboardState[code] == SDL_RELEASED) {
|
||||||
SDL_SendKeyboardKey(SDL_PRESSED, code);
|
SDL_SendKeyboardKey(SDL_PRESSED, code);
|
||||||
}
|
}
|
||||||
SDL_SendKeyboardKey(SDL_RELEASED, code);
|
SDL_SendKeyboardKey(SDL_RELEASED, code);
|
||||||
|
|
Loading…
Reference in New Issue