From 62affaa01b7e3785a5ab0654d450fde0f1973724 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 29 Jun 2025 08:34:30 +0000 Subject: [PATCH] feat: Add F11 as an additional shortcut for fullscreen toggle This change allows users to toggle fullscreen mode using the F11 key, in addition to the existing MOD+f shortcut. The F11 shortcut works when pressed without other major modifiers (Ctrl, Shift, Alt, GUI). --- app/src/input_manager.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/src/input_manager.c b/app/src/input_manager.c index 3e4dd0f3..9874c510 100644 --- a/app/src/input_manager.c +++ b/app/src/input_manager.c @@ -386,8 +386,11 @@ sc_input_manager_process_key(struct sc_input_manager *im, // The second condition is necessary to ignore the release of the modifier // key (because in this case mod is 0). uint16_t mods = im->sdl_shortcut_mods; - bool is_shortcut = sc_shortcut_mods_is_shortcut_mod(mods, mod) - || sc_shortcut_mods_is_shortcut_key(mods, sdl_keycode); + bool is_shortcut_modifier_pressed = + sc_shortcut_mods_is_shortcut_mod(mods, mod); + bool is_key_a_shortcut_modifier = + sc_shortcut_mods_is_shortcut_key(mods, sdl_keycode); + bool is_shortcut = is_shortcut_modifier_pressed || is_key_a_shortcut_modifier; if (down && !repeat) { if (sdl_keycode == im->last_keycode && mod == im->last_mod) { @@ -399,6 +402,17 @@ sc_input_manager_process_key(struct sc_input_manager *im, } } + // Handle F11 for fullscreen (no modifiers needed) + if (sdl_keycode == SDLK_F11 && video && !repeat && down) { + // Ensure no other modifiers like Shift, Ctrl, Alt, GUI are pressed with F11 + // (KMOD_NUM, KMOD_CAPS, KMOD_MODE, KMOD_SCROLL are generally ok) + uint16_t problematic_mods = KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_GUI; + if (!(mod & problematic_mods)) { + sc_screen_toggle_fullscreen(im->screen); + return; // F11 handled, consume the event + } + } + if (is_shortcut) { enum sc_action action = down ? SC_ACTION_DOWN : SC_ACTION_UP; switch (sdl_keycode) { @@ -506,6 +520,7 @@ sc_input_manager_process_key(struct sc_input_manager *im, } return; case SDLK_f: + // This is part of `is_shortcut`, so a modifier (Alt/Super) must be pressed. if (video && !shift && !repeat && down) { sc_screen_toggle_fullscreen(im->screen); }