diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c index b45909027..231d5b1d6 100644 --- a/src/video/kmsdrm/SDL_kmsdrmmouse.c +++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c @@ -73,6 +73,7 @@ KMSDRM_DestroyCursorBO (_THIS, SDL_VideoDisplay *display) if (dispdata->cursor_bo) { KMSDRM_gbm_bo_destroy(dispdata->cursor_bo); dispdata->cursor_bo = NULL; + dispdata->cursor_bo_drm_fd = -1; } } @@ -116,6 +117,8 @@ KMSDRM_CreateCursorBO (SDL_VideoDisplay *display) { SDL_SetError("Could not create GBM cursor BO"); return; } + + dispdata->cursor_bo_drm_fd = viddata->drm_fd; } /* Remove a cursor buffer from a display's DRM cursor BO. */ @@ -384,11 +387,9 @@ KMSDRM_WarpMouseGlobal(int x, int y) /* And now update the cursor graphic position on screen. */ if (dispdata->cursor_bo) { - int drm_fd; int ret = 0; - 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); + ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, x, y); if (ret) { SDL_SetError("drmModeMoveCursor() failed."); @@ -437,7 +438,6 @@ static void KMSDRM_MoveCursor(SDL_Cursor * cursor) { SDL_Mouse *mouse = SDL_GetMouse(); - int drm_fd; int ret = 0; /* We must NOT call SDL_SendMouseMotion() here or we will enter recursivity! @@ -452,9 +452,7 @@ KMSDRM_MoveCursor(SDL_Cursor * cursor) return; } - drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(dispdata->cursor_bo)); - - ret = KMSDRM_drmModeMoveCursor(drm_fd, dispdata->crtc->crtc_id, mouse->x, mouse->y); + ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, mouse->x, mouse->y); if (ret) { SDL_SetError("drmModeMoveCursor() failed."); diff --git a/src/video/kmsdrm/SDL_kmsdrmsym.h b/src/video/kmsdrm/SDL_kmsdrmsym.h index 90d128582..e368c5d0d 100644 --- a/src/video/kmsdrm/SDL_kmsdrmsym.h +++ b/src/video/kmsdrm/SDL_kmsdrmsym.h @@ -95,7 +95,6 @@ SDL_KMSDRM_SYM(int,drmModeSetPlane,(int fd, uint32_t plane_id, uint32_t crtc_id, /* Planes stuff ends. */ SDL_KMSDRM_MODULE(GBM) -SDL_KMSDRM_SYM(int,gbm_device_get_fd,(struct gbm_device *gbm)) SDL_KMSDRM_SYM(int,gbm_device_is_format_supported,(struct gbm_device *gbm, uint32_t format, uint32_t usage)) SDL_KMSDRM_SYM(void,gbm_device_destroy,(struct gbm_device *gbm)) diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index dbc1b4455..3308dd963 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -555,6 +555,7 @@ KMSDRM_AddDisplay (_THIS, drmModeConnector *connector, drmModeRes *resources) { /* Initialize some of the members of the new display's driverdata to sane values. */ dispdata->cursor_bo = NULL; + dispdata->cursor_bo_drm_fd = -1; /* Since we create and show the default cursor on KMSDRM_InitMouse(), and we call KMSDRM_InitMouse() when we create a window, we have to know diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h index b172eb90f..566fc852d 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.h +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h @@ -77,6 +77,7 @@ typedef struct SDL_DisplayData where we may not have an SDL_Cursor at all (so no SDL_Cursor driverdata). There's only one cursor GBM BO because we only support one cursor. */ struct gbm_bo *cursor_bo; + int cursor_bo_drm_fd; uint64_t cursor_w, cursor_h; SDL_bool default_cursor_init;