diff options
author | Manuel Alfayate Corchete <redwindwanderer@gmail.com> | 2021-01-29 23:32:42 +0100 |
---|---|---|
committer | Manuel Alfayate Corchete <redwindwanderer@gmail.com> | 2021-01-29 23:32:42 +0100 |
commit | 4837fd31d11e7869b3cdee4084d69841453501a7 (patch) | |
tree | e91863107f58581ac767ad5604420eff8be54427 | |
parent | abee814d67613e5365e718886e4aa13e71366928 (diff) | |
download | sdl-4837fd31d11e7869b3cdee4084d69841453501a7.tar.gz |
[KMS/DRM] Correct small omission on bugfix #5513: y-coord correction has to be done on WarpMouseGlobal, too.
-rw-r--r-- | src/video/kmsdrm/SDL_kmsdrmmouse.c | 15 | ||||
-rw-r--r-- | src/video/kmsdrm/SDL_kmsdrmvideo.c | 4 |
2 files changed, 12 insertions, 7 deletions
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 |