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.
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
diff --git a/src/video/raspberry/SDL_rpimouse.c b/src/video/raspberry/SDL_rpimouse.c
index 065f209..64b986b 100644
--- a/src/video/raspberry/SDL_rpimouse.c
+++ b/src/video/raspberry/SDL_rpimouse.c
@@ -230,35 +230,47 @@ 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) {
- int ret;
update = vc_dispmanx_update_start( 10 );
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(
update,
curdata->element,
- ELEMENT_CHANGE_DEST_RECT,
+ 0,
0,
0,
&dst_rect,
- NULL,
+ &src_rect,
DISPMANX_NO_HANDLE,
DISPMANX_NO_ROTATE);
- SDL_assert( ret == DISPMANX_SUCCESS );
+ if (ret != DISPMANX_SUCCESS ) {
+ return SDL_SetError("vc_dispmanx_element_change_attributes() failed");
+ }
+
/* Submit asynchronously, otherwise the peformance suffers a lot */
ret = vc_dispmanx_update_submit( update, 0, NULL );
- SDL_assert( ret == DISPMANX_SUCCESS );
- return (ret == DISPMANX_SUCCESS) ? 0 : -1;
+ if (ret != DISPMANX_SUCCESS ) {
+ return SDL_SetError("vc_dispmanx_update_submit() failed");
+ }
}
- }
-
- return -1; /* !!! FIXME: this should SDL_SetError() somewhere. */
+ }
+ return 0;
}
void