Skip to content

Commit

Permalink
port: make alt-enter go into fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsfdsfgs committed Aug 14, 2023
1 parent 7666ccf commit 20fd3a8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions port/fast3d/gfx_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ static void set_fullscreen(bool on, bool call_callback) {
return;
}
fullscreen_state = on;
SDL_SetWindowFullscreen(wnd, on ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
if (call_callback && on_fullscreen_changed_callback) {
on_fullscreen_changed_callback(on);
}
}

static void gfx_sdl_get_active_window_refresh_rate(uint32_t* refresh_rate) {
Expand Down Expand Up @@ -101,6 +105,8 @@ static void gfx_sdl_init(const char* game_name, const char* gfx_api_name, bool s
}

qpc_freq = SDL_GetPerformanceFrequency();

set_fullscreen(start_in_fullscreen, false);
}

static void gfx_sdl_close(void) {
Expand Down Expand Up @@ -132,6 +138,12 @@ static void gfx_sdl_handle_events(void) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
if (event.key.keysym.sym == SDLK_RETURN && (event.key.keysym.mod & KMOD_ALT)) {
// alt-enter received, switch fullscreen state
set_fullscreen(!fullscreen_state, true);
}
break;
case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
SDL_GL_GetDrawableSize(wnd, &window_width, &window_height);
Expand Down

0 comments on commit 20fd3a8

Please sign in to comment.