port: add maximize window option to extended menu

This commit is contained in:
Dominic Della Valle committed 2023-12-16 11:56:39 -05:00
1 parent 28218b26c2
commit 0221839699
4 files changed
+55 -4

No files matched your search

+20 -4
View File
@@ -36,6 +36,7 @@ static bool vsync_enabled = true;
static int window_width = DESIRED_SCREEN_WIDTH;
static int window_height = DESIRED_SCREEN_HEIGHT;
static bool fullscreen_state;
static bool maximized_state;
static bool is_running = true;
static void (*on_fullscreen_changed_callback)(bool is_now_fullscreen);
@@ -76,6 +77,18 @@ static void set_fullscreen(bool on, bool call_callback) {
}
}
static void set_maximize_window(bool on) {
if (maximized_state == on) {
return;
}
maximized_state = on;
if (on) {
SDL_MaximizeWindow(wnd);
} else {
SDL_RestoreWindow (wnd);
}
}
static void gfx_sdl_get_active_window_refresh_rate(uint32_t* refresh_rate) {
int display_in_use = SDL_GetWindowDisplayIndex(wnd);
@@ -110,10 +123,7 @@ static void gfx_sdl_init(const char* game_name, const char* gfx_api_name, bool s
posY = 100;
}
Uint32 flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_OPENGL;
if (start_maximized) {
flags |= SDL_WINDOW_MAXIMIZED;
}
const Uint32 flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_OPENGL;
wnd = SDL_CreateWindow(title, posX, posY, window_width, window_height, flags);
if (!wnd) {
@@ -185,6 +195,7 @@ static void gfx_sdl_init(const char* game_name, const char* gfx_api_name, bool s
}
#endif
set_maximize_window(start_maximized);
set_fullscreen(start_in_fullscreen, false);
}
@@ -200,6 +211,10 @@ static void gfx_sdl_set_fullscreen(bool enable) {
set_fullscreen(enable, true);
}
static void gfx_sdl_set_maximize_window(bool enable) {
set_maximize_window(enable);
}
static void gfx_sdl_set_cursor_visibility(bool visible) {
if (visible) {
SDL_ShowCursor(SDL_ENABLE);
@@ -320,6 +335,7 @@ struct GfxWindowManagerAPI gfx_sdl = {
gfx_sdl_close,
gfx_sdl_set_fullscreen_changed_callback,
gfx_sdl_set_fullscreen,
gfx_sdl_set_maximize_window,
gfx_sdl_get_active_window_refresh_rate,
gfx_sdl_set_cursor_visibility,
gfx_sdl_get_dimensions,