From 603154899a25ad2dbafc0818e8afb6c1f6f4fde4 Mon Sep 17 00:00:00 2001 From: frosch Date: Sat, 23 Mar 2024 20:48:26 +0100 Subject: [PATCH] Add: [SDL2] Driver parameter 'no_mouse_capture' to ease interactive debugging (#12336) --- src/video/sdl2_v.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp index 4bbe30de66..585571385d 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -534,6 +534,15 @@ const char *VideoDriver_SDL_Base::Start(const StringList ¶m) const char *error = this->Initialize(); if (error != nullptr) return error; +#ifdef SDL_HINT_MOUSE_AUTO_CAPTURE + if (GetDriverParamBool(param, "no_mouse_capture")) { + /* By default SDL captures the mouse, while a button is pressed. + * This is annoying during debugging, when OpenTTD is suspended while the button was pressed. + */ + if (!SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0")) return SDL_GetError(); + } +#endif + this->startup_display = FindStartupDisplay(GetDriverParamInt(param, "display", -1)); if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height, false)) {