[KMS/DRM] Restore hacky code to point to TTY buffer on surface destruction b/c I lack alternatives.
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 63 64 65 66 67 68 69 70 71
diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c
index 26a7dad..c472fc4 100644
--- a/src/video/kmsdrm/SDL_kmsdrmmouse.c
+++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c
@@ -409,7 +409,6 @@ KMSDRM_InitMouse(_THIS)
SDL_VideoData *viddata = ((SDL_VideoData *)dev->driverdata);
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
SDL_Mouse *mouse = SDL_GetMouse();
- uint64_t usable_cursor_w, usable_cursor_h;
mouse->CreateCursor = KMSDRM_CreateCursor;
mouse->ShowCursor = KMSDRM_ShowCursor;
@@ -439,23 +438,20 @@ KMSDRM_InitMouse(_THIS)
return;
}
- if (KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_WIDTH, &usable_cursor_w) ||
- KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT, &usable_cursor_h))
+ if (KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_WIDTH, &dispdata->cursor_w) ||
+ KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT, &dispdata->cursor_h))
{
SDL_SetError("Could not get the recommended GBM cursor size");
goto cleanup;
}
- if (usable_cursor_w == 0 || usable_cursor_h == 0) {
+ if (dispdata->cursor_w == 0 || dispdata->cursor_h == 0) {
SDL_SetError("Could not get an usable GBM cursor size");
goto cleanup;
}
- dispdata->cursor_w = usable_cursor_w;
- dispdata->cursor_h = usable_cursor_h;
-
dispdata->cursor_bo = KMSDRM_gbm_bo_create(viddata->gbm_dev,
- usable_cursor_w, usable_cursor_h,
+ dispdata->cursor_w, dispdata->cursor_h,
GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
if (!dispdata->cursor_bo) {
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index 57fced5..ff235b1 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -1323,6 +1323,26 @@ void
KMSDRM_DestroySurfaces(_THIS, SDL_Window *window)
{
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
+ SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
+ KMSDRM_PlaneInfo plane_info = {0};
+
+ /************************************************************/
+ /* Make the display plane point to the original TTY buffer. */
+ /************************************************************/
+
+ plane_info.plane = dispdata->display_plane;
+ plane_info.crtc_id = dispdata->crtc->crtc->crtc_id;
+ plane_info.fb_id = dispdata->crtc->crtc->buffer_id;
+ plane_info.src_w = dispdata->mode.hdisplay;
+ plane_info.src_h = dispdata->mode.vdisplay;
+ plane_info.crtc_w = dispdata->mode.hdisplay;
+ plane_info.crtc_h = dispdata->mode.vdisplay;
+
+ drm_atomic_set_plane_props(&plane_info);
+
+ if (drm_atomic_commit(_this, SDL_TRUE)) {
+ SDL_SetError("Failed to issue atomic commit on surfaces destruction.");
+ }
/***************************/
/* Destroy the EGL surface */