We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3149

Summary: Mouse Pointer Raspberry Pi corrupt when moving over screen edges
Product: SDL Reporter: Patrick Gutlich <patrick>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: blocker    
Priority: P2    
Version: HG 2.0   
Hardware: ARM   
OS: Linux   

Description Patrick Gutlich 2015-10-12 18:56:09 UTC
The mouse cursor gets corrupted when the mouse moves over the screen edges (right and bottom) a weird type of scaling seems to occur and you end up with a blank square.

Suggested Fix for sdl_rpimouse.c:

/* Warp the mouse to (x,y) */
static int
RPI_WarpMouseGlobal(int x, int y)
{
    RPI_CursorData *curdata;
    DISPMANX_UPDATE_HANDLE_T update;
    int ret;
    VC_RECT_T dst_rect;
    VC_RECT_T src_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) {
            update = vc_dispmanx_update_start( 10 );
            SDL_assert( update );
            src_rect.x = 0;
            src_rect.y = 0;
            src_rect.width  = curdata->w << 16;
            src_rect.height = curdata->h << 16;
            dst_rect.x = x;
            dst_rect.y = y;
            dst_rect.width  = curdata->w;
            dst_rect.height = curdata->h;

            ret = vc_dispmanx_element_change_attributes(
                update,
                curdata->element,
                0,
                0,
                0,
                &dst_rect,
                &src_rect,
                DISPMANX_NO_HANDLE,
                DISPMANX_NO_ROTATE);
            SDL_assert( ret == DISPMANX_SUCCESS );
            /* Submit asynchronously, otherwise the peformance suffers a lot */
            ret = vc_dispmanx_update_submit( update, 0, NULL );
            SDL_assert( ret == DISPMANX_SUCCESS );
        }
    }   

    return -1;  /* !!! FIXME: this should SDL_SetError() somewhere. */
}
Comment 1 Sam Lantinga 2016-10-01 21:00:21 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/2b008531d078