From d2fca37716ee6eb1c3b073a9d74b223d1cff2de1 Mon Sep 17 00:00:00 2001 From: RedBlackAka <140876408+RedBlackAka@users.noreply.github.com> Date: Sun, 12 Jul 2026 11:54:37 +0200 Subject: [PATCH] [GUI] Basic hotkey and full-screen support (#75) --- src/SharpEmu.GUI/MainWindow.axaml | 3 ++- src/SharpEmu.GUI/MainWindow.axaml.cs | 29 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/SharpEmu.GUI/MainWindow.axaml b/src/SharpEmu.GUI/MainWindow.axaml index dde0c38..53b6871 100644 --- a/src/SharpEmu.GUI/MainWindow.axaml +++ b/src/SharpEmu.GUI/MainWindow.axaml @@ -14,7 +14,8 @@ SPDX-License-Identifier: GPL-2.0-or-later ExtendClientAreaToDecorationsHint="True" ExtendClientAreaChromeHints="PreferSystemChrome" ExtendClientAreaTitleBarHeightHint="44" - Icon="avares://SharpEmu.GUI/Assets/SharpEmu.ico"> + Icon="avares://SharpEmu.GUI/Assets/SharpEmu.ico" + KeyDown="OnKeyDown"> diff --git a/src/SharpEmu.GUI/MainWindow.axaml.cs b/src/SharpEmu.GUI/MainWindow.axaml.cs index bad8189..638b4b4 100644 --- a/src/SharpEmu.GUI/MainWindow.axaml.cs +++ b/src/SharpEmu.GUI/MainWindow.axaml.cs @@ -8,6 +8,7 @@ using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.Media; using Avalonia.Media.Imaging; +using Avalonia.Platform; using Avalonia.Platform.Storage; using Avalonia.Threading; using Avalonia.VisualTree; @@ -292,6 +293,34 @@ public partial class MainWindow : Window } } + private void OnKeyDown(object sender, KeyEventArgs args) + { + args.Handled = true; + switch (args.Key) + { + case Key.F11: + OnWindowFullScreen(this, new RoutedEventArgs()); + break; + default: + args.Handled = false; + break; + } + } + + private void OnWindowFullScreen(object sender, RoutedEventArgs args) + { + if (WindowState == WindowState.FullScreen) + { + WindowState = WindowState.Normal; + ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.PreferSystemChrome; + } + else + { + WindowState = WindowState.FullScreen; + ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.NoChrome; + } + } + private void OnWindowClosing() { ReadControlsIntoSettings();