If there isn't a GetGlobalMouseState() implementation, fall back to the normal one.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index 5d6f7dc..03bae6b 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -722,23 +722,24 @@ Uint32
SDL_GetGlobalMouseState(int *x, int *y)
{
SDL_Mouse *mouse = SDL_GetMouse();
- int tmpx, tmpy;
- /* make sure these are never NULL for the backend implementations... */
- if (!x) {
- x = &tmpx;
- }
- if (!y) {
- y = &tmpy;
- }
+ if (mouse->GetGlobalMouseState) {
+ int tmpx, tmpy;
+
+ /* make sure these are never NULL for the backend implementations... */
+ if (!x) {
+ x = &tmpx;
+ }
+ if (!y) {
+ y = &tmpy;
+ }
- *x = *y = 0;
+ *x = *y = 0;
- if (!mouse->GetGlobalMouseState) {
- return 0;
+ return mouse->GetGlobalMouseState(x, y);
+ } else {
+ return SDL_GetMouseState(x, y);
}
-
- return mouse->GetGlobalMouseState(x, y);
}
void
diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c
index abef62c..8de6291 100644
--- a/src/video/kmsdrm/SDL_kmsdrmmouse.c
+++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c
@@ -466,8 +466,6 @@ KMSDRM_InitMouse(_THIS)
mouse->FreeCursor = KMSDRM_FreeCursor;
mouse->WarpMouse = KMSDRM_WarpMouse;
mouse->WarpMouseGlobal = KMSDRM_WarpMouseGlobal;
- /* No desktop on KMSDRM, so just return the normal mouse state. */
- mouse->GetGlobalMouseState = SDL_GetMouseState;
SDL_SetDefaultCursor(KMSDRM_CreateDefaultCursor());
}
diff --git a/src/video/offscreen/SDL_offscreenvideo.c b/src/video/offscreen/SDL_offscreenvideo.c
index 811eb4a..66c4300 100644
--- a/src/video/offscreen/SDL_offscreenvideo.c
+++ b/src/video/offscreen/SDL_offscreenvideo.c
@@ -109,19 +109,6 @@ VideoBootStrap OFFSCREEN_bootstrap = {
OFFSCREEN_Available, OFFSCREEN_CreateDevice
};
-static Uint32
-OFFSCREEN_GetGlobalMouseState(int *x, int *y)
-{
- if (x) {
- *x = 0;
- }
-
- if (y) {
- *y = 0;
- }
- return 0;
-}
-
int
OFFSCREEN_VideoInit(_THIS)
{
@@ -141,11 +128,6 @@ OFFSCREEN_VideoInit(_THIS)
SDL_zero(mode);
SDL_AddDisplayMode(&_this->displays[0], &mode);
- /* Init mouse */
- mouse = SDL_GetMouse();
- /* This function needs to be implemented by every driver */
- mouse->GetGlobalMouseState = OFFSCREEN_GetGlobalMouseState;
-
/* We're done! */
return 0;
}