Fixed bug changing cursors on Raspberry Pi
authorSam Lantinga <slouken@libsdl.org>
Tue, 27 Nov 2018 10:20:29 -0800
changeset 12433fdddcd7d940d
parent 12432 defbd51902c3
child 12434 164473244292
Fixed bug changing cursors on Raspberry Pi
src/video/raspberry/SDL_rpimouse.c
     1.1 --- a/src/video/raspberry/SDL_rpimouse.c	Mon Nov 26 19:55:01 2018 +0300
     1.2 +++ b/src/video/raspberry/SDL_rpimouse.c	Tue Nov 27 10:20:29 2018 -0800
     1.3 @@ -51,6 +51,8 @@
     1.4  static void RPI_WarpMouse(SDL_Window * window, int x, int y);
     1.5  static int RPI_WarpMouseGlobal(int x, int y);
     1.6  
     1.7 +static SDL_Cursor *global_cursor;
     1.8 +
     1.9  static SDL_Cursor *
    1.10  RPI_CreateDefaultCursor(void)
    1.11  {
    1.12 @@ -126,21 +128,25 @@
    1.13          return -1;
    1.14      }
    1.15      
    1.16 +    if (cursor == global_cursor) {
    1.17 +        return 0;
    1.18 +    }
    1.19 +
    1.20 +    if (global_cursor != NULL) {
    1.21 +        curdata = (RPI_CursorData *) global_cursor->driverdata;
    1.22 +        if (curdata && curdata->element > DISPMANX_NO_HANDLE) {
    1.23 +            update = vc_dispmanx_update_start(0);
    1.24 +            SDL_assert(update);
    1.25 +            ret = vc_dispmanx_element_remove(update, curdata->element);
    1.26 +            SDL_assert(ret == DISPMANX_SUCCESS);
    1.27 +            ret = vc_dispmanx_update_submit_sync(update);
    1.28 +            SDL_assert(ret == DISPMANX_SUCCESS);
    1.29 +            curdata->element = DISPMANX_NO_HANDLE;
    1.30 +        }
    1.31 +    }
    1.32 +    global_cursor = cursor;
    1.33 +
    1.34      if (cursor == NULL) {
    1.35 -        /* FIXME: We hide the current mouse's cursor, what we actually need is *_HideCursor */
    1.36 -
    1.37 -        if (mouse->cur_cursor != NULL && mouse->cur_cursor->driverdata != NULL) {
    1.38 -            curdata = (RPI_CursorData *) mouse->cur_cursor->driverdata;
    1.39 -            if (curdata->element > DISPMANX_NO_HANDLE) {
    1.40 -                update = vc_dispmanx_update_start(10);
    1.41 -                SDL_assert(update);
    1.42 -                ret = vc_dispmanx_element_remove(update, curdata->element);
    1.43 -                SDL_assert(ret == DISPMANX_SUCCESS);
    1.44 -                ret = vc_dispmanx_update_submit_sync(update);
    1.45 -                SDL_assert(ret == DISPMANX_SUCCESS);
    1.46 -                curdata->element = DISPMANX_NO_HANDLE;
    1.47 -            }
    1.48 -        }
    1.49          return 0;
    1.50      }
    1.51      
    1.52 @@ -152,7 +158,7 @@
    1.53      if (mouse->focus == NULL) {
    1.54          return -1;
    1.55      }
    1.56 -    
    1.57 +
    1.58      display = SDL_GetDisplayForWindow(mouse->focus);
    1.59      if (display == NULL) {
    1.60          return -1;
    1.61 @@ -167,7 +173,7 @@
    1.62          vc_dispmanx_rect_set(&src_rect, 0, 0, curdata->w << 16, curdata->h << 16);
    1.63          vc_dispmanx_rect_set(&dst_rect, mouse->x, mouse->y, curdata->w, curdata->h);
    1.64          
    1.65 -        update = vc_dispmanx_update_start(10);
    1.66 +        update = vc_dispmanx_update_start(0);
    1.67          SDL_assert(update);
    1.68  
    1.69          env = SDL_GetHint(SDL_HINT_RPI_VIDEO_LAYER);
    1.70 @@ -206,7 +212,7 @@
    1.71          
    1.72          if (curdata != NULL) {
    1.73              if (curdata->element != DISPMANX_NO_HANDLE) {
    1.74 -                update = vc_dispmanx_update_start(10);
    1.75 +                update = vc_dispmanx_update_start(0);
    1.76                  SDL_assert(update);
    1.77                  ret = vc_dispmanx_element_remove(update, curdata->element);
    1.78                  SDL_assert(ret == DISPMANX_SUCCESS);
    1.79 @@ -255,7 +261,7 @@
    1.80          return 0;
    1.81      }
    1.82  
    1.83 -    update = vc_dispmanx_update_start(10);
    1.84 +    update = vc_dispmanx_update_start(0);
    1.85      if (!update) {
    1.86          return 0;
    1.87      }
    1.88 @@ -311,7 +317,7 @@
    1.89          return 0;
    1.90      }
    1.91  
    1.92 -    update = vc_dispmanx_update_start(10);
    1.93 +    update = vc_dispmanx_update_start(0);
    1.94      if (!update) {
    1.95          return 0;
    1.96      }
    1.97 @@ -368,7 +374,6 @@
    1.98  void
    1.99  RPI_QuitMouse(_THIS)
   1.100  {
   1.101 -    
   1.102  }
   1.103  
   1.104  /* This is called when a mouse motion event occurs */