Fixed 3149 - Mouse Pointer Raspberry Pi corrupt when moving over screen edges

Patrick Gutlich

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.
This commit is contained in:
Sam Lantinga 2016-10-01 13:59:59 -07:00
parent 1a31bbe2c8
commit da6197c5a8

View File

@ -230,35 +230,47 @@ RPI_WarpMouseGlobal(int x, int y)
{ {
RPI_CursorData *curdata; RPI_CursorData *curdata;
DISPMANX_UPDATE_HANDLE_T update; DISPMANX_UPDATE_HANDLE_T update;
int ret;
VC_RECT_T dst_rect; VC_RECT_T dst_rect;
VC_RECT_T src_rect;
SDL_Mouse *mouse = SDL_GetMouse(); SDL_Mouse *mouse = SDL_GetMouse();
if (mouse != NULL && mouse->cur_cursor != NULL && mouse->cur_cursor->driverdata != NULL) { if (mouse != NULL && mouse->cur_cursor != NULL && mouse->cur_cursor->driverdata != NULL) {
curdata = (RPI_CursorData *) mouse->cur_cursor->driverdata; curdata = (RPI_CursorData *) mouse->cur_cursor->driverdata;
if (curdata->element != DISPMANX_NO_HANDLE) { if (curdata->element != DISPMANX_NO_HANDLE) {
int ret;
update = vc_dispmanx_update_start( 10 ); update = vc_dispmanx_update_start( 10 );
SDL_assert( update ); SDL_assert( update );
vc_dispmanx_rect_set( &dst_rect, x, y, curdata->w, curdata->h); 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( ret = vc_dispmanx_element_change_attributes(
update, update,
curdata->element, curdata->element,
ELEMENT_CHANGE_DEST_RECT, 0,
0, 0,
0, 0,
&dst_rect, &dst_rect,
NULL, &src_rect,
DISPMANX_NO_HANDLE, DISPMANX_NO_HANDLE,
DISPMANX_NO_ROTATE); DISPMANX_NO_ROTATE);
SDL_assert( ret == DISPMANX_SUCCESS ); if (ret != DISPMANX_SUCCESS ) {
/* Submit asynchronously, otherwise the peformance suffers a lot */ return SDL_SetError("vc_dispmanx_element_change_attributes() failed");
ret = vc_dispmanx_update_submit( update, 0, NULL );
SDL_assert( ret == DISPMANX_SUCCESS );
return (ret == DISPMANX_SUCCESS) ? 0 : -1;
}
} }
return -1; /* !!! FIXME: this should SDL_SetError() somewhere. */ /* Submit asynchronously, otherwise the peformance suffers a lot */
ret = vc_dispmanx_update_submit( update, 0, NULL );
if (ret != DISPMANX_SUCCESS ) {
return SDL_SetError("vc_dispmanx_update_submit() failed");
}
}
}
return 0;
} }
void void