[Commits] SDL: SDL_WarpMouseGlobal() should return non-void.

libsdl.org revision control commits-owner at libsdl.org
Fri Jul 17 20:58:37 PDT 2015


details:   https://hg.libsdl.org/SDL/rev/57b448735f48
changeset: 9807:57b448735f48
user:      Ryan C. Gordon <icculus at icculus.org>
date:      Fri Jul 17 21:03:58 2015 -0400
description:
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.

diffstat:

 include/SDL_mouse.h                  |  3 ++-
 src/dynapi/SDL_dynapi_procs.h        |  2 +-
 src/events/SDL_mouse.c               |  6 ++++--
 src/events/SDL_mouse_c.h             |  2 +-
 src/video/cocoa/SDL_cocoamouse.m     |  6 ++++--
 src/video/mir/SDL_mirmouse.c         |  4 ++--
 src/video/raspberry/SDL_rpimouse.c   |  7 +++++--
 src/video/wayland/SDL_waylandmouse.c |  4 ++--
 src/video/windows/SDL_windowsmouse.c |  3 ++-
 src/video/x11/SDL_x11mouse.c         |  3 ++-
 10 files changed, 25 insertions(+), 15 deletions(-)

diffs (199 lines):

diff -r 2deeef7b793c -r 57b448735f48 include/SDL_mouse.h
--- a/include/SDL_mouse.h	Thu Jul 16 21:48:35 2015 +0200
+++ b/include/SDL_mouse.h	Fri Jul 17 21:03:58 2015 -0400
@@ -137,10 +137,11 @@
  *
  *  \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 -r 2deeef7b793c -r 57b448735f48 src/dynapi/SDL_dynapi_procs.h
--- a/src/dynapi/SDL_dynapi_procs.h	Thu Jul 16 21:48:35 2015 +0200
+++ b/src/dynapi/SDL_dynapi_procs.h	Fri Jul 17 21:03:58 2015 -0400
@@ -612,7 +612,7 @@
 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 -r 2deeef7b793c -r 57b448735f48 src/events/SDL_mouse.c
--- a/src/events/SDL_mouse.c	Thu Jul 16 21:48:35 2015 +0200
+++ b/src/events/SDL_mouse.c	Fri Jul 17 21:03:58 2015 -0400
@@ -535,14 +535,16 @@
     }
 }
 
-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 -r 2deeef7b793c -r 57b448735f48 src/events/SDL_mouse_c.h
--- a/src/events/SDL_mouse_c.h	Thu Jul 16 21:48:35 2015 +0200
+++ b/src/events/SDL_mouse_c.h	Fri Jul 17 21:03:58 2015 -0400
@@ -61,7 +61,7 @@
     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 -r 2deeef7b793c -r 57b448735f48 src/video/cocoa/SDL_cocoamouse.m
--- a/src/video/cocoa/SDL_cocoamouse.m	Thu Jul 16 21:48:35 2015 +0200
+++ b/src/video/cocoa/SDL_cocoamouse.m	Fri Jul 17 21:03:58 2015 -0400
@@ -210,7 +210,7 @@
     return NULL;
 }
 
-static void
+static int
 Cocoa_WarpMouseGlobal(int x, int y)
 {
     SDL_Mouse *mouse = SDL_GetMouse();
@@ -219,7 +219,7 @@
         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 @@
             SDL_SendMouseMotion(win, mouse->mouseID, 0, x - win->x, y - win->y);
         }
     }
+
+    return 0;
 }
 
 static void
diff -r 2deeef7b793c -r 57b448735f48 src/video/mir/SDL_mirmouse.c
--- a/src/video/mir/SDL_mirmouse.c	Thu Jul 16 21:48:35 2015 +0200
+++ b/src/video/mir/SDL_mirmouse.c	Fri Jul 17 21:03:58 2015 -0400
@@ -110,10 +110,10 @@
     SDL_Unsupported();
 }
 
-static void
+static int
 MIR_WarpMouseGlobal(int x, int y)
 {
-    SDL_Unsupported();
+    return SDL_Unsupported();
 }
 
 static int
diff -r 2deeef7b793c -r 57b448735f48 src/video/raspberry/SDL_rpimouse.c
--- a/src/video/raspberry/SDL_rpimouse.c	Thu Jul 16 21:48:35 2015 +0200
+++ b/src/video/raspberry/SDL_rpimouse.c	Fri Jul 17 21:03:58 2015 -0400
@@ -216,18 +216,18 @@
 }
 
 /* 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 @@
             /* 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 -r 2deeef7b793c -r 57b448735f48 src/video/wayland/SDL_waylandmouse.c
--- a/src/video/wayland/SDL_waylandmouse.c	Thu Jul 16 21:48:35 2015 +0200
+++ b/src/video/wayland/SDL_waylandmouse.c	Fri Jul 17 21:03:58 2015 -0400
@@ -347,10 +347,10 @@
     SDL_Unsupported();
 }
 
-static void
+static int
 Wayland_WarpMouseGlobal(int x, int y)
 {
-    SDL_Unsupported();
+    return SDL_Unsupported();
 }
 
 static int
diff -r 2deeef7b793c -r 57b448735f48 src/video/windows/SDL_windowsmouse.c
--- a/src/video/windows/SDL_windowsmouse.c	Thu Jul 16 21:48:35 2015 +0200
+++ b/src/video/windows/SDL_windowsmouse.c	Fri Jul 17 21:03:58 2015 -0400
@@ -236,7 +236,7 @@
     SetCursorPos(pt.x, pt.y);
 }
 
-static void
+static int
 WIN_WarpMouseGlobal(int x, int y)
 {
     POINT pt;
@@ -244,6 +244,7 @@
     pt.x = x;
     pt.y = y;
     SetCursorPos(pt.x, pt.y);
+    return 0;
 }
 
 static int
diff -r 2deeef7b793c -r 57b448735f48 src/video/x11/SDL_x11mouse.c
--- a/src/video/x11/SDL_x11mouse.c	Thu Jul 16 21:48:35 2015 +0200
+++ b/src/video/x11/SDL_x11mouse.c	Fri Jul 17 21:03:58 2015 -0400
@@ -318,13 +318,14 @@
     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


More information about the commits mailing list