Skip to content

Commit

Permalink
desktop: Add Alt+Enter back as a hidden shortcut on Windows
Browse files Browse the repository at this point in the history
Previously Alt+Enter was a hidden shortcut that was used to toggle
full screen, and it is used by Flash Player to toggle full screen
on Windows too.

As Windows users sometimes expect this shortcut to work, this
patch brings it back as a hidden shortcut (until we add some kind of preferences).
  • Loading branch information
kjarosh authored and torokati44 committed Sep 24, 2024
1 parent b6b9b03 commit 1ee5db4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion desktop/src/gui/menu_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub struct MenuBar {

impl MenuBar {
const SHORTCUT_FULLSCREEN: KeyboardShortcut = KeyboardShortcut::new(Modifiers::NONE, Key::F11);
const SHORTCUT_FULLSCREEN_WINDOWS: KeyboardShortcut =
KeyboardShortcut::new(Modifiers::ALT, Key::Enter);
const SHORTCUT_OPEN: KeyboardShortcut = KeyboardShortcut::new(Modifiers::COMMAND, Key::O);
const SHORTCUT_OPEN_ADVANCED: KeyboardShortcut =
KeyboardShortcut::new(Modifiers::COMMAND.plus(Modifiers::SHIFT), Key::O);
Expand Down Expand Up @@ -64,7 +66,14 @@ impl MenuBar {
player.set_is_playing(!player.is_playing());
}
}
if egui_ctx.input_mut(|input| input.consume_shortcut(&Self::SHORTCUT_FULLSCREEN)) {
let mut fullscreen_pressed =
egui_ctx.input_mut(|input| input.consume_shortcut(&Self::SHORTCUT_FULLSCREEN));
if cfg!(windows) && !fullscreen_pressed {
// TODO We can remove this shortcut when we add some kind of preferences.
fullscreen_pressed = egui_ctx
.input_mut(|input| input.consume_shortcut(&Self::SHORTCUT_FULLSCREEN_WINDOWS));
}
if fullscreen_pressed {
if let Some(player) = &mut player {
let is_fullscreen = player.is_fullscreen();
player.set_fullscreen(!is_fullscreen);
Expand Down

0 comments on commit 1ee5db4

Please sign in to comment.