Commit 629e9f820a3ab80e7671ab3133a448f56252f1da

Sam Lantinga 2021-08-13T11:06:43

Fixed return value of SDL_GetGrabbedWindow() when we have an internal grab because of mouse relative mode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 38e6030..160190d 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -2809,10 +2809,12 @@ SDL_GetWindowMouseGrab(SDL_Window * window)
 SDL_Window *
 SDL_GetGrabbedWindow(void)
 {
-    SDL_assert(!_this->grabbed_window ||
-               ((_this->grabbed_window->flags & SDL_WINDOW_MOUSE_GRABBED) != 0) ||
-               ((_this->grabbed_window->flags & SDL_WINDOW_KEYBOARD_GRABBED) != 0));
-    return _this->grabbed_window;
+    if (_this->grabbed_window &&
+        (_this->grabbed_window->flags & (SDL_WINDOW_MOUSE_GRABBED|SDL_WINDOW_KEYBOARD_GRABBED)) != 0) {
+        return _this->grabbed_window;
+    } else {
+        return NULL;
+    }
 }
 
 int