From d26be9417121363a59874d3e0b015942b2d866ed Mon Sep 17 00:00:00 2001 From: Christopher Whitley <103014489+AristurtleDev@users.noreply.github.com> Date: Sat, 18 May 2024 04:50:16 -0400 Subject: [PATCH] Respect Window.AllowAltF4 For SDLGamePlatform (#8248) When checking the exit condition of `_isExiting > 0` an additional check is now made to determine if the exit should occur. This check for the ALT+F4 keyboard combination, and if found, returns the state of `Window.AllowAltF4`; otherwise it return `true`. --- .../Platform/SDL/SDLGamePlatform.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/MonoGame.Framework/Platform/SDL/SDLGamePlatform.cs b/MonoGame.Framework/Platform/SDL/SDLGamePlatform.cs index 5fcc679142f..25495c4cf9b 100644 --- a/MonoGame.Framework/Platform/SDL/SDLGamePlatform.cs +++ b/MonoGame.Framework/Platform/SDL/SDLGamePlatform.cs @@ -93,11 +93,27 @@ public override void RunLoop() Threading.Run(); GraphicsDevice.DisposeContexts(); - if (_isExiting > 0) + if (_isExiting > 0 && ShouldExit()) + { break; + } + else + { + _isExiting = 0; + } } } + private bool ShouldExit() + { + if(_keys.Contains(Keys.F4) && (_keys.Contains(Keys.LeftAlt) || _keys.Contains(Keys.RightAlt))) + { + return Window.AllowAltF4; + } + + return true; + } + private void SdlRunLoop() { Sdl.Event ev;