Move switch fullscreen logs
Logs were printed by the caller of switch_fullscreen(). Move them inside the function to simplify event handling code.
This commit is contained in:
parent
6fe7b84629
commit
f8ad007a28
1 changed files with 5 additions and 8 deletions
|
@ -217,14 +217,15 @@ static void render(SDL_Renderer *renderer, SDL_Texture *texture) {
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool switch_fullscreen(void) {
|
static void switch_fullscreen(void) {
|
||||||
if (!fullscreen) {
|
if (!fullscreen) {
|
||||||
// going to fullscreen, store the current windowed window size
|
// going to fullscreen, store the current windowed window size
|
||||||
windowed_window_size = get_window_size(window);
|
windowed_window_size = get_window_size(window);
|
||||||
}
|
}
|
||||||
Uint32 new_mode = fullscreen ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP;
|
Uint32 new_mode = fullscreen ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||||
if (SDL_SetWindowFullscreen(window, new_mode)) {
|
if (SDL_SetWindowFullscreen(window, new_mode)) {
|
||||||
return SDL_FALSE;
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Could not switch fullscreen mode: %s", SDL_GetError());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fullscreen = !fullscreen;
|
fullscreen = !fullscreen;
|
||||||
|
@ -233,8 +234,8 @@ static SDL_bool switch_fullscreen(void) {
|
||||||
SDL_SetWindowSize(window, windowed_window_size.width, windowed_window_size.height);
|
SDL_SetWindowSize(window, windowed_window_size.width, windowed_window_size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Switched to %s mode", fullscreen ? "fullscreen" : "windowed");
|
||||||
render(renderer, texture_empty ? NULL : texture);
|
render(renderer, texture_empty ? NULL : texture);
|
||||||
return SDL_TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wait_for_success(process_t proc, const char *name) {
|
static int wait_for_success(process_t proc, const char *name) {
|
||||||
|
@ -362,11 +363,7 @@ static void handle_key(const SDL_KeyboardEvent *event) {
|
||||||
|
|
||||||
// Ctrl+f: switch fullscreen
|
// Ctrl+f: switch fullscreen
|
||||||
if (keycode == SDLK_f && !shift) {
|
if (keycode == SDLK_f && !shift) {
|
||||||
if (switch_fullscreen()) {
|
switch_fullscreen();
|
||||||
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Switched to %s mode", fullscreen ? "fullscreen" : "windowed");
|
|
||||||
} else {
|
|
||||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Could not switch fullscreen mode: %s", SDL_GetError());
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue