SDL_WarpMouseGlobal() should return non-void.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 17 Jul 2015 21:03:58 -0400
changeset 980757b448735f48
parent 9806 2deeef7b793c
child 9808 64c8ca7fcf16
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.
include/SDL_mouse.h
src/dynapi/SDL_dynapi_procs.h
src/events/SDL_mouse.c
src/events/SDL_mouse_c.h
src/video/cocoa/SDL_cocoamouse.m
src/video/mir/SDL_mirmouse.c
src/video/raspberry/SDL_rpimouse.c
src/video/wayland/SDL_waylandmouse.c
src/video/windows/SDL_windowsmouse.c
src/video/x11/SDL_x11mouse.c
     1.1 --- a/include/SDL_mouse.h	Thu Jul 16 21:48:35 2015 +0200
     1.2 +++ b/include/SDL_mouse.h	Fri Jul 17 21:03:58 2015 -0400
     1.3 @@ -137,10 +137,11 @@
     1.4   *
     1.5   *  \param x The x coordinate
     1.6   *  \param y The y coordinate
     1.7 + *  \return 0 on success, -1 on error (usually: unsupported by a platform).
     1.8   *
     1.9   *  \note This function generates a mouse motion event
    1.10   */
    1.11 -extern DECLSPEC void SDLCALL SDL_WarpMouseGlobal(int x, int y);
    1.12 +extern DECLSPEC int SDLCALL SDL_WarpMouseGlobal(int x, int y);
    1.13  
    1.14  /**
    1.15   *  \brief Set relative mouse mode.
     2.1 --- a/src/dynapi/SDL_dynapi_procs.h	Thu Jul 16 21:48:35 2015 +0200
     2.2 +++ b/src/dynapi/SDL_dynapi_procs.h	Fri Jul 17 21:03:58 2015 -0400
     2.3 @@ -612,7 +612,7 @@
     2.4  SDL_DYNAPI_PROC(const wchar_t*,SDL_WinRTGetFSPathUNICODE,(SDL_WinRT_Path a),(a),return)
     2.5  SDL_DYNAPI_PROC(const char*,SDL_WinRTGetFSPathUTF8,(SDL_WinRT_Path a),(a),return)
     2.6  #endif
     2.7 -SDL_DYNAPI_PROC(void,SDL_WarpMouseGlobal,(int a, int b),(a,b),)
     2.8 +SDL_DYNAPI_PROC(int,SDL_WarpMouseGlobal,(int a, int b),(a,b),)
     2.9  SDL_DYNAPI_PROC(float,SDL_sqrtf,(float a),(a),return)
    2.10  SDL_DYNAPI_PROC(double,SDL_tan,(double a),(a),return)
    2.11  SDL_DYNAPI_PROC(float,SDL_tanf,(float a),(a),return)
     3.1 --- a/src/events/SDL_mouse.c	Thu Jul 16 21:48:35 2015 +0200
     3.2 +++ b/src/events/SDL_mouse.c	Fri Jul 17 21:03:58 2015 -0400
     3.3 @@ -535,14 +535,16 @@
     3.4      }
     3.5  }
     3.6  
     3.7 -void
     3.8 +int
     3.9  SDL_WarpMouseGlobal(int x, int y)
    3.10  {
    3.11      SDL_Mouse *mouse = SDL_GetMouse();
    3.12  
    3.13      if (mouse->WarpMouseGlobal) {
    3.14 -        mouse->WarpMouseGlobal(x, y);
    3.15 +        return mouse->WarpMouseGlobal(x, y);
    3.16      }
    3.17 +
    3.18 +    return SDL_Unsupported();
    3.19  }
    3.20  
    3.21  static SDL_bool
     4.1 --- a/src/events/SDL_mouse_c.h	Thu Jul 16 21:48:35 2015 +0200
     4.2 +++ b/src/events/SDL_mouse_c.h	Fri Jul 17 21:03:58 2015 -0400
     4.3 @@ -61,7 +61,7 @@
     4.4      void (*WarpMouse) (SDL_Window * window, int x, int y);
     4.5  
     4.6      /* Warp the mouse to (x,y) in screen space */
     4.7 -    void (*WarpMouseGlobal) (int x, int y);
     4.8 +    int (*WarpMouseGlobal) (int x, int y);
     4.9  
    4.10      /* Set relative mode */
    4.11      int (*SetRelativeMouseMode) (SDL_bool enabled);
     5.1 --- a/src/video/cocoa/SDL_cocoamouse.m	Thu Jul 16 21:48:35 2015 +0200
     5.2 +++ b/src/video/cocoa/SDL_cocoamouse.m	Fri Jul 17 21:03:58 2015 -0400
     5.3 @@ -210,7 +210,7 @@
     5.4      return NULL;
     5.5  }
     5.6  
     5.7 -static void
     5.8 +static int
     5.9  Cocoa_WarpMouseGlobal(int x, int y)
    5.10  {
    5.11      SDL_Mouse *mouse = SDL_GetMouse();
    5.12 @@ -219,7 +219,7 @@
    5.13          if ([data->listener isMoving]) {
    5.14              DLog("Postponing warp, window being moved.");
    5.15              [data->listener setPendingMoveX:x Y:y];
    5.16 -            return;
    5.17 +            return 0;
    5.18          }
    5.19      }
    5.20      const CGPoint point = CGPointMake((float)x, (float)y);
    5.21 @@ -245,6 +245,8 @@
    5.22              SDL_SendMouseMotion(win, mouse->mouseID, 0, x - win->x, y - win->y);
    5.23          }
    5.24      }
    5.25 +
    5.26 +    return 0;
    5.27  }
    5.28  
    5.29  static void
     6.1 --- a/src/video/mir/SDL_mirmouse.c	Thu Jul 16 21:48:35 2015 +0200
     6.2 +++ b/src/video/mir/SDL_mirmouse.c	Fri Jul 17 21:03:58 2015 -0400
     6.3 @@ -110,10 +110,10 @@
     6.4      SDL_Unsupported();
     6.5  }
     6.6  
     6.7 -static void
     6.8 +static int
     6.9  MIR_WarpMouseGlobal(int x, int y)
    6.10  {
    6.11 -    SDL_Unsupported();
    6.12 +    return SDL_Unsupported();
    6.13  }
    6.14  
    6.15  static int
     7.1 --- a/src/video/raspberry/SDL_rpimouse.c	Thu Jul 16 21:48:35 2015 +0200
     7.2 +++ b/src/video/raspberry/SDL_rpimouse.c	Fri Jul 17 21:03:58 2015 -0400
     7.3 @@ -216,18 +216,18 @@
     7.4  }
     7.5  
     7.6  /* Warp the mouse to (x,y) */
     7.7 -static void
     7.8 +static int
     7.9  RPI_WarpMouseGlobal(int x, int y)
    7.10  {
    7.11      RPI_CursorData *curdata;
    7.12      DISPMANX_UPDATE_HANDLE_T update;
    7.13 -    int ret;
    7.14      VC_RECT_T dst_rect;
    7.15      SDL_Mouse *mouse = SDL_GetMouse();
    7.16      
    7.17      if (mouse != NULL && mouse->cur_cursor != NULL && mouse->cur_cursor->driverdata != NULL) {
    7.18          curdata = (RPI_CursorData *) mouse->cur_cursor->driverdata;
    7.19          if (curdata->element != DISPMANX_NO_HANDLE) {
    7.20 +            int ret;
    7.21              update = vc_dispmanx_update_start( 10 );
    7.22              SDL_assert( update );
    7.23              vc_dispmanx_rect_set( &dst_rect, x, y, curdata->w, curdata->h);
    7.24 @@ -245,8 +245,11 @@
    7.25              /* Submit asynchronously, otherwise the peformance suffers a lot */
    7.26              ret = vc_dispmanx_update_submit( update, 0, NULL );
    7.27              SDL_assert( ret == DISPMANX_SUCCESS );
    7.28 +            return (ret == DISPMANX_SUCCESS) ? 0 : -1;
    7.29          }
    7.30      }    
    7.31 +
    7.32 +    return -1;  /* !!! FIXME: this should SDL_SetError() somewhere. */
    7.33  }
    7.34  
    7.35  void
     8.1 --- a/src/video/wayland/SDL_waylandmouse.c	Thu Jul 16 21:48:35 2015 +0200
     8.2 +++ b/src/video/wayland/SDL_waylandmouse.c	Fri Jul 17 21:03:58 2015 -0400
     8.3 @@ -347,10 +347,10 @@
     8.4      SDL_Unsupported();
     8.5  }
     8.6  
     8.7 -static void
     8.8 +static int
     8.9  Wayland_WarpMouseGlobal(int x, int y)
    8.10  {
    8.11 -    SDL_Unsupported();
    8.12 +    return SDL_Unsupported();
    8.13  }
    8.14  
    8.15  static int
     9.1 --- a/src/video/windows/SDL_windowsmouse.c	Thu Jul 16 21:48:35 2015 +0200
     9.2 +++ b/src/video/windows/SDL_windowsmouse.c	Fri Jul 17 21:03:58 2015 -0400
     9.3 @@ -236,7 +236,7 @@
     9.4      SetCursorPos(pt.x, pt.y);
     9.5  }
     9.6  
     9.7 -static void
     9.8 +static int
     9.9  WIN_WarpMouseGlobal(int x, int y)
    9.10  {
    9.11      POINT pt;
    9.12 @@ -244,6 +244,7 @@
    9.13      pt.x = x;
    9.14      pt.y = y;
    9.15      SetCursorPos(pt.x, pt.y);
    9.16 +    return 0;
    9.17  }
    9.18  
    9.19  static int
    10.1 --- a/src/video/x11/SDL_x11mouse.c	Thu Jul 16 21:48:35 2015 +0200
    10.2 +++ b/src/video/x11/SDL_x11mouse.c	Fri Jul 17 21:03:58 2015 -0400
    10.3 @@ -318,13 +318,14 @@
    10.4      X11_XSync(display, False);
    10.5  }
    10.6  
    10.7 -static void
    10.8 +static int
    10.9  X11_WarpMouseGlobal(int x, int y)
   10.10  {
   10.11      Display *display = GetDisplay();
   10.12  
   10.13      X11_XWarpPointer(display, None, DefaultRootWindow(display), 0, 0, 0, 0, x, y);
   10.14      X11_XSync(display, False);
   10.15 +    return 0;
   10.16  }
   10.17  
   10.18  static int