Skip to content

Commit

Permalink
Cleaned up Alt-Enter/Ctrl-Enter fullscreen toggle logic
Browse files Browse the repository at this point in the history
Alt-Enter will go from the current state to fullscreen desktop, or if already there, will leave fullscreen mode.
Ctrl-Enter will go from the current state to exclusive fullscreen mode, or if already there, will leave fullscreen mode.
  • Loading branch information
slouken committed Jun 4, 2023
1 parent 052a9d3 commit d406951
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/test/SDL_test_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2186,34 +2186,26 @@ void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done
SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
if (window) {
Uint32 flags = SDL_GetWindowFlags(window);
if (flags & SDL_WINDOW_FULLSCREEN) {
SDL_SetWindowFullscreen(window, SDL_FALSE);
} else {
if (!(flags & SDL_WINDOW_FULLSCREEN) ||
!SDL_GetWindowFullscreenMode(window)) {
SDL_SetWindowFullscreenMode(window, &state->fullscreen_mode);
SDL_SetWindowFullscreen(window, SDL_TRUE);
} else {
SDL_SetWindowFullscreen(window, SDL_FALSE);
}
}
} else if (withAlt) {
/* Alt-Enter toggle fullscreen desktop */
SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
if (window) {
Uint32 flags = SDL_GetWindowFlags(window);
if (flags & SDL_WINDOW_FULLSCREEN) {
SDL_SetWindowFullscreen(window, SDL_FALSE);
} else {
if (!(flags & SDL_WINDOW_FULLSCREEN) ||
SDL_GetWindowFullscreenMode(window)) {
SDL_SetWindowFullscreenMode(window, NULL);
SDL_SetWindowFullscreen(window, SDL_TRUE);
}
}
} else if (withShift) {
/* Shift-Enter toggle fullscreen desktop / fullscreen */
SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
if (window) {
if (SDL_GetWindowFullscreenMode(window)) {
SDL_SetWindowFullscreenMode(window, NULL);
} else {
SDL_SetWindowFullscreenMode(window, &state->fullscreen_mode);
SDL_SetWindowFullscreen(window, SDL_FALSE);
}
SDL_SetWindowFullscreen(window, SDL_TRUE);
}
}

Expand Down

0 comments on commit d406951

Please sign in to comment.