SDL_WarpMouseGlobal() should return non-void. There are platforms it isn't implemented on (and currently can't be implemented on!), and there's currently no way for an app to know this. This shouldn't break ABI on apps that moved to a revision between 2.0.3 and 2.0.4.
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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
diff --git a/include/SDL_mouse.h b/include/SDL_mouse.h
index 58f6de6..1ae3126 100644
--- a/include/SDL_mouse.h
+++ b/include/SDL_mouse.h
@@ -137,10 +137,11 @@ extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
*
* \param x The x coordinate
* \param y The y coordinate
+ * \return 0 on success, -1 on error (usually: unsupported by a platform).
*
* \note This function generates a mouse motion event
*/
-extern DECLSPEC void SDLCALL SDL_WarpMouseGlobal(int x, int y);
+extern DECLSPEC int SDLCALL SDL_WarpMouseGlobal(int x, int y);
/**
* \brief Set relative mouse mode.
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index 2174208..4ea5bbc 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -612,7 +612,7 @@ SDL_DYNAPI_PROC(int,SDL_WinRTRunApp,(int a, char **b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(const wchar_t*,SDL_WinRTGetFSPathUNICODE,(SDL_WinRT_Path a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_WinRTGetFSPathUTF8,(SDL_WinRT_Path a),(a),return)
#endif
-SDL_DYNAPI_PROC(void,SDL_WarpMouseGlobal,(int a, int b),(a,b),)
+SDL_DYNAPI_PROC(int,SDL_WarpMouseGlobal,(int a, int b),(a,b),)
SDL_DYNAPI_PROC(float,SDL_sqrtf,(float a),(a),return)
SDL_DYNAPI_PROC(double,SDL_tan,(double a),(a),return)
SDL_DYNAPI_PROC(float,SDL_tanf,(float a),(a),return)
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index 65faa52..716384a 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -535,14 +535,16 @@ SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
}
}
-void
+int
SDL_WarpMouseGlobal(int x, int y)
{
SDL_Mouse *mouse = SDL_GetMouse();
if (mouse->WarpMouseGlobal) {
- mouse->WarpMouseGlobal(x, y);
+ return mouse->WarpMouseGlobal(x, y);
}
+
+ return SDL_Unsupported();
}
static SDL_bool
diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h
index aefccf0..b12bec3 100644
--- a/src/events/SDL_mouse_c.h
+++ b/src/events/SDL_mouse_c.h
@@ -61,7 +61,7 @@ typedef struct
void (*WarpMouse) (SDL_Window * window, int x, int y);
/* Warp the mouse to (x,y) in screen space */
- void (*WarpMouseGlobal) (int x, int y);
+ int (*WarpMouseGlobal) (int x, int y);
/* Set relative mode */
int (*SetRelativeMouseMode) (SDL_bool enabled);
diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m
index 3c0c478..625d8f4 100644
--- a/src/video/cocoa/SDL_cocoamouse.m
+++ b/src/video/cocoa/SDL_cocoamouse.m
@@ -210,7 +210,7 @@ SDL_FindWindowAtPoint(const int x, const int y)
return NULL;
}
-static void
+static int
Cocoa_WarpMouseGlobal(int x, int y)
{
SDL_Mouse *mouse = SDL_GetMouse();
@@ -219,7 +219,7 @@ Cocoa_WarpMouseGlobal(int x, int y)
if ([data->listener isMoving]) {
DLog("Postponing warp, window being moved.");
[data->listener setPendingMoveX:x Y:y];
- return;
+ return 0;
}
}
const CGPoint point = CGPointMake((float)x, (float)y);
@@ -245,6 +245,8 @@ Cocoa_WarpMouseGlobal(int x, int y)
SDL_SendMouseMotion(win, mouse->mouseID, 0, x - win->x, y - win->y);
}
}
+
+ return 0;
}
static void
diff --git a/src/video/mir/SDL_mirmouse.c b/src/video/mir/SDL_mirmouse.c
index 0615137..740ac20 100644
--- a/src/video/mir/SDL_mirmouse.c
+++ b/src/video/mir/SDL_mirmouse.c
@@ -110,10 +110,10 @@ MIR_WarpMouse(SDL_Window* window, int x, int y)
SDL_Unsupported();
}
-static void
+static int
MIR_WarpMouseGlobal(int x, int y)
{
- SDL_Unsupported();
+ return SDL_Unsupported();
}
static int
diff --git a/src/video/raspberry/SDL_rpimouse.c b/src/video/raspberry/SDL_rpimouse.c
index 9336f45..838196e 100644
--- a/src/video/raspberry/SDL_rpimouse.c
+++ b/src/video/raspberry/SDL_rpimouse.c
@@ -216,18 +216,18 @@ RPI_WarpMouse(SDL_Window * window, int x, int y)
}
/* Warp the mouse to (x,y) */
-static void
+static int
RPI_WarpMouseGlobal(int x, int y)
{
RPI_CursorData *curdata;
DISPMANX_UPDATE_HANDLE_T update;
- int ret;
VC_RECT_T dst_rect;
SDL_Mouse *mouse = SDL_GetMouse();
if (mouse != NULL && mouse->cur_cursor != NULL && mouse->cur_cursor->driverdata != NULL) {
curdata = (RPI_CursorData *) mouse->cur_cursor->driverdata;
if (curdata->element != DISPMANX_NO_HANDLE) {
+ int ret;
update = vc_dispmanx_update_start( 10 );
SDL_assert( update );
vc_dispmanx_rect_set( &dst_rect, x, y, curdata->w, curdata->h);
@@ -245,8 +245,11 @@ RPI_WarpMouseGlobal(int x, int y)
/* Submit asynchronously, otherwise the peformance suffers a lot */
ret = vc_dispmanx_update_submit( update, 0, NULL );
SDL_assert( ret == DISPMANX_SUCCESS );
+ return (ret == DISPMANX_SUCCESS) ? 0 : -1;
}
}
+
+ return -1; /* !!! FIXME: this should SDL_SetError() somewhere. */
}
void
diff --git a/src/video/wayland/SDL_waylandmouse.c b/src/video/wayland/SDL_waylandmouse.c
index d77f99c..2d78ebb 100644
--- a/src/video/wayland/SDL_waylandmouse.c
+++ b/src/video/wayland/SDL_waylandmouse.c
@@ -347,10 +347,10 @@ Wayland_WarpMouse(SDL_Window *window, int x, int y)
SDL_Unsupported();
}
-static void
+static int
Wayland_WarpMouseGlobal(int x, int y)
{
- SDL_Unsupported();
+ return SDL_Unsupported();
}
static int
diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c
index 3c51648..69aa777 100644
--- a/src/video/windows/SDL_windowsmouse.c
+++ b/src/video/windows/SDL_windowsmouse.c
@@ -236,7 +236,7 @@ WIN_WarpMouse(SDL_Window * window, int x, int y)
SetCursorPos(pt.x, pt.y);
}
-static void
+static int
WIN_WarpMouseGlobal(int x, int y)
{
POINT pt;
@@ -244,6 +244,7 @@ WIN_WarpMouseGlobal(int x, int y)
pt.x = x;
pt.y = y;
SetCursorPos(pt.x, pt.y);
+ return 0;
}
static int
diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c
index 4d5d90a..6cef0a4 100644
--- a/src/video/x11/SDL_x11mouse.c
+++ b/src/video/x11/SDL_x11mouse.c
@@ -318,13 +318,14 @@ X11_WarpMouse(SDL_Window * window, int x, int y)
X11_XSync(display, False);
}
-static void
+static int
X11_WarpMouseGlobal(int x, int y)
{
Display *display = GetDisplay();
X11_XWarpPointer(display, None, DefaultRootWindow(display), 0, 0, 0, 0, x, y);
X11_XSync(display, False);
+ return 0;
}
static int