Skip to content

Commit

Permalink
We don't need to pull scancode state to see if ALT is held down
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jun 29, 2024
1 parent 017a103 commit b72c223
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/video/windows/SDL_windowsevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -1239,12 +1239,11 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
SDL_bool virtual_key = SDL_FALSE;
Uint16 rawcode = 0;
SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam, &rawcode, &virtual_key);
const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);

/* Detect relevant keyboard shortcuts */
if (keyboardState[SDL_SCANCODE_LALT] == SDL_PRESSED || keyboardState[SDL_SCANCODE_RALT] == SDL_PRESSED) {
if (code == SDL_SCANCODE_F4 && (SDL_GetModState() & SDL_KMOD_ALT)) {
/* ALT+F4: Close window */
if (code == SDL_SCANCODE_F4 && ShouldGenerateWindowCloseOnAltF4()) {
if (ShouldGenerateWindowCloseOnAltF4()) {
SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_CLOSE_REQUESTED, 0, 0);
}
}
Expand Down

0 comments on commit b72c223

Please sign in to comment.