Fixed bug 4000 - SDL2 on raspberry: mouse displayed at 0,0 after SDL_ShowCursor
authorSam Lantinga <slouken@libsdl.org>
Tue, 19 Dec 2017 11:17:37 -0800
changeset 117843ec03f35f3b9
parent 11783 c7577c45151a
child 11785 6d85907059ff
Fixed bug 4000 - SDL2 on raspberry: mouse displayed at 0,0 after SDL_ShowCursor

Laurent Merckx

I have a problem with the SDL_ShowCursor method on Raspberry.

Depending on the context, my application hides or show the mouse cursor with SDL_ShowCursor.
But when calling SDL_ShowCursor(true), the cursor is displayed at 0,0 (and not at last position).

After debugging sources by myself, it seems that the problem is in SDL_rpimouse.c - RPI_ShowCursor:

vc_dispmanx_rect_set( &dst_rect, 0, 0, curdata->w, curdata->h);
should be
vc_dispmanx_rect_set( &dst_rect, mouse->x, mouse->y, curdata->w, curdata->h);

For me, it solves the problem.
src/video/raspberry/SDL_rpimouse.c
     1.1 --- a/src/video/raspberry/SDL_rpimouse.c	Tue Dec 19 11:14:06 2017 -0800
     1.2 +++ b/src/video/raspberry/SDL_rpimouse.c	Tue Dec 19 11:17:37 2017 -0800
     1.3 @@ -165,7 +165,7 @@
     1.4      
     1.5      if (curdata->element == DISPMANX_NO_HANDLE) {
     1.6          vc_dispmanx_rect_set(&src_rect, 0, 0, curdata->w << 16, curdata->h << 16);
     1.7 -        vc_dispmanx_rect_set(&dst_rect, 0, 0, curdata->w, curdata->h);
     1.8 +        vc_dispmanx_rect_set(&dst_rect, mouse->x, mouse->y, curdata->w, curdata->h);
     1.9          
    1.10          update = vc_dispmanx_update_start(10);
    1.11          SDL_assert(update);