[KMS/DRM] Correct small omission on bugfix #5513: y-coord correction has to be done on WarpMouseGlobal, too.
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
diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c
index e66953a..f296478 100644
--- a/src/video/kmsdrm/SDL_kmsdrmmouse.c
+++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c
@@ -442,10 +442,14 @@ KMSDRM_WarpMouseGlobal(int x, int y)
/* And now update the cursor graphic position on screen. */
if (dispdata->cursor_bo) {
- int ret, drm_fd;
- drm_fd = KMSDRM_gbm_device_get_fd(
- KMSDRM_gbm_bo_get_device(dispdata->cursor_bo));
- ret = KMSDRM_drmModeMoveCursor(drm_fd, dispdata->crtc->crtc_id, x, y);
+ int drm_fd, screen_y;
+ int ret = 0;
+
+ /* Correct the Y coordinate, because DRM mouse coordinates start on screen top. */
+ screen_y = dispdata->mode.vdisplay - window->h + mouse->y;
+
+ drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(dispdata->cursor_bo));
+ ret = KMSDRM_drmModeMoveCursor(drm_fd, dispdata->crtc->crtc_id, x, screen_y);
if (ret) {
SDL_SetError("drmModeMoveCursor() failed.");
@@ -500,7 +504,8 @@ static void
KMSDRM_MoveCursor(SDL_Cursor * cursor)
{
SDL_Mouse *mouse = SDL_GetMouse();
- int drm_fd, ret, screen_y;
+ int drm_fd, screen_y;
+ int ret = 0;
/* We must NOT call SDL_SendMouseMotion() here or we will enter recursivity!
That's why we move the cursor graphic ONLY. */
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index 79e2a77..78ed3b2 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -1164,8 +1164,8 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
now that we know this is not a VK window. */
KMSDRM_CreateCursorBO(display);
- /* Init mouse (=create and set the default cursor),
- now that we know this is not a VK window. */
+ /* Create and set the default cursor now that we know
+ this is not a VK window. */
KMSDRM_InitMouse(_this, display);
/* When we destroy a window, we remove the cursor buffer from