From ee2d66bbe27ad6647acd5956699a8b79fb2fbec6 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Mon, 14 Jan 2019 20:49:44 -0500 Subject: add ACTION_FULLSCREEN --- src/sdl/action.c | 2 ++ src/sdl/action.h | 1 + src/sdl/main.c | 10 ++++++++++ 3 files changed, 13 insertions(+) (limited to 'src') diff --git a/src/sdl/action.c b/src/sdl/action.c index 72b6fb2..09141a9 100644 --- a/src/sdl/action.c +++ b/src/sdl/action.c @@ -72,6 +72,8 @@ get_key_action( return (action_t) { .type = ACTION_ZOOM_IN, .data = 1 }; case SDLK_MINUS: return (action_t) { .type = ACTION_ZOOM_OUT, .data = -1 }; + case SDLK_F11: + return (action_t) { .type = ACTION_FULLSCREEN }; default: return (action_t) { .type = ACTION_NONE }; } diff --git a/src/sdl/action.h b/src/sdl/action.h index 4713f62..e28f9ce 100644 --- a/src/sdl/action.h +++ b/src/sdl/action.h @@ -17,6 +17,7 @@ typedef enum { ACTION_NEXT, ACTION_SOLVE, ACTION_RESET, + ACTION_FULLSCREEN, ACTION_LAST, } action_type_t; diff --git a/src/sdl/main.c b/src/sdl/main.c index 16f9a46..8d7fdff 100644 --- a/src/sdl/main.c +++ b/src/sdl/main.c @@ -141,6 +141,7 @@ int main(int argc, char *argv[]) { die("TTF_OpenFontIndex(): %s", TTF_GetError()); } + bool is_fullscreen = false; bool done = false; SDL_Event ev; while (!done) { @@ -231,6 +232,15 @@ int main(int argc, char *argv[]) { zoom--; } + break; + case ACTION_FULLSCREEN: + if (SDL_SetWindowFullscreen(win, is_fullscreen ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP)) { + die("SDL_SetWindowFullscreen(): %s", SDL_GetError()); + } + + // toggle flag + is_fullscreen = !is_fullscreen; + break; default: // ignore -- cgit v1.2.3