From 147e5dceffc60c39df91542e72810d2eb05215ca Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 16 Jul 2024 05:08:13 +0300 Subject: [PATCH] engine: request SDL to ungrab mouse before signaling debugger to stop --- engine/common/system.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/engine/common/system.c b/engine/common/system.c index 0c967aeb..798aefd7 100644 --- a/engine/common/system.c +++ b/engine/common/system.c @@ -72,15 +72,28 @@ Sys_DebugBreak */ void Sys_DebugBreak( void ) { +#if XASH_SDL + int was_grabbed = host.hWnd != NULL && SDL_GetWindowGrab( host.hWnd ); +#endif + + if( !Sys_DebuggerPresent( )) + return; + +#if XASH_SDL + if( was_grabbed ) // so annoying... + SDL_SetWindowGrab( host.hWnd, SDL_FALSE ); +#endif // XASH_SDL + #if _MSC_VER - if( Sys_DebuggerPresent( )) - __debugbreak(); + __debugbreak(); #else // !_MSC_VER - if( Sys_DebuggerPresent( )) - { - INLINE_RAISE( SIGINT ); - INLINE_NANOSLEEP1(); // sometimes signal comes with delay, let it interrupt nanosleep - } + INLINE_RAISE( SIGINT ); + INLINE_NANOSLEEP1(); // sometimes signal comes with delay, let it interrupt nanosleep +#endif // !_MSC_VER + +#if XASH_SDL + if( was_grabbed ) + SDL_SetWindowGrab( host.hWnd, SDL_TRUE ); #endif }