Fixed bug changing cursors on Raspberry Pi
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
diff --git a/src/video/raspberry/SDL_rpimouse.c b/src/video/raspberry/SDL_rpimouse.c
index 4ea976b..650b1f3 100644
--- a/src/video/raspberry/SDL_rpimouse.c
+++ b/src/video/raspberry/SDL_rpimouse.c
@@ -51,6 +51,8 @@ static void RPI_FreeCursor(SDL_Cursor * cursor);
static void RPI_WarpMouse(SDL_Window * window, int x, int y);
static int RPI_WarpMouseGlobal(int x, int y);
+static SDL_Cursor *global_cursor;
+
static SDL_Cursor *
RPI_CreateDefaultCursor(void)
{
@@ -126,21 +128,25 @@ RPI_ShowCursor(SDL_Cursor * cursor)
return -1;
}
- if (cursor == NULL) {
- /* FIXME: We hide the current mouse's cursor, what we actually need is *_HideCursor */
+ if (cursor == global_cursor) {
+ return 0;
+ }
- if (mouse->cur_cursor != NULL && mouse->cur_cursor->driverdata != NULL) {
- curdata = (RPI_CursorData *) mouse->cur_cursor->driverdata;
- if (curdata->element > DISPMANX_NO_HANDLE) {
- update = vc_dispmanx_update_start(10);
- SDL_assert(update);
- ret = vc_dispmanx_element_remove(update, curdata->element);
- SDL_assert(ret == DISPMANX_SUCCESS);
- ret = vc_dispmanx_update_submit_sync(update);
- SDL_assert(ret == DISPMANX_SUCCESS);
- curdata->element = DISPMANX_NO_HANDLE;
- }
+ if (global_cursor != NULL) {
+ curdata = (RPI_CursorData *) global_cursor->driverdata;
+ if (curdata && curdata->element > DISPMANX_NO_HANDLE) {
+ update = vc_dispmanx_update_start(0);
+ SDL_assert(update);
+ ret = vc_dispmanx_element_remove(update, curdata->element);
+ SDL_assert(ret == DISPMANX_SUCCESS);
+ ret = vc_dispmanx_update_submit_sync(update);
+ SDL_assert(ret == DISPMANX_SUCCESS);
+ curdata->element = DISPMANX_NO_HANDLE;
}
+ }
+ global_cursor = cursor;
+
+ if (cursor == NULL) {
return 0;
}
@@ -152,7 +158,7 @@ RPI_ShowCursor(SDL_Cursor * cursor)
if (mouse->focus == NULL) {
return -1;
}
-
+
display = SDL_GetDisplayForWindow(mouse->focus);
if (display == NULL) {
return -1;
@@ -167,7 +173,7 @@ RPI_ShowCursor(SDL_Cursor * cursor)
vc_dispmanx_rect_set(&src_rect, 0, 0, curdata->w << 16, curdata->h << 16);
vc_dispmanx_rect_set(&dst_rect, mouse->x, mouse->y, curdata->w, curdata->h);
- update = vc_dispmanx_update_start(10);
+ update = vc_dispmanx_update_start(0);
SDL_assert(update);
env = SDL_GetHint(SDL_HINT_RPI_VIDEO_LAYER);
@@ -206,7 +212,7 @@ RPI_FreeCursor(SDL_Cursor * cursor)
if (curdata != NULL) {
if (curdata->element != DISPMANX_NO_HANDLE) {
- update = vc_dispmanx_update_start(10);
+ update = vc_dispmanx_update_start(0);
SDL_assert(update);
ret = vc_dispmanx_element_remove(update, curdata->element);
SDL_assert(ret == DISPMANX_SUCCESS);
@@ -255,7 +261,7 @@ RPI_WarpMouseGlobal(int x, int y)
return 0;
}
- update = vc_dispmanx_update_start(10);
+ update = vc_dispmanx_update_start(0);
if (!update) {
return 0;
}
@@ -311,7 +317,7 @@ RPI_WarpMouseGlobalGraphicOnly(int x, int y)
return 0;
}
- update = vc_dispmanx_update_start(10);
+ update = vc_dispmanx_update_start(0);
if (!update) {
return 0;
}
@@ -368,7 +374,6 @@ RPI_InitMouse(_THIS)
void
RPI_QuitMouse(_THIS)
{
-
}
/* This is called when a mouse motion event occurs */