From 57d5fd0e6296eab8ca497cba73b1e8efe806667a Mon Sep 17 00:00:00 2001 From: Bubio <78299054+bubio@users.noreply.github.com> Date: Sat, 2 Apr 2022 20:32:32 +0900 Subject: [PATCH] Fix #4251 macOS mouse grab issue (#4298) --- Source/utils/display.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Source/utils/display.cpp b/Source/utils/display.cpp index 520faa09e..9958b49f6 100644 --- a/Source/utils/display.cpp +++ b/Source/utils/display.cpp @@ -243,11 +243,14 @@ bool SpawnWindow(const char *lpWindowName) flags |= SDL_WINDOW_FULLSCREEN; } - if (*sgOptions.Gameplay.grabInput) { - flags |= SDL_WINDOW_INPUT_GRABBED; - } - ghMainWnd = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, windowSize.width, windowSize.height, flags); + + // Note: https://github.com/libsdl-org/SDL/issues/962 + // This is a solution to a problem related to SDL mouse grab. + // See https://github.com/diasurgical/devilutionX/issues/4251 + if (ghMainWnd != nullptr) + SDL_SetWindowGrab(ghMainWnd, *sgOptions.Gameplay.grabInput ? SDL_TRUE : SDL_FALSE); + #endif if (ghMainWnd == nullptr) { ErrSdl();