diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c index e66953ad9..f2964782a 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 79e2a7748..78ed3b2ce 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