[Video/KMSDRM] Manually re-show the cursor on window creation, if needed.
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
diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c
index e17c3c5..26a7dad 100644
--- a/src/video/kmsdrm/SDL_kmsdrmmouse.c
+++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c
@@ -179,6 +179,31 @@ cleanup:
return ret;
}
+/* When we create a window, we have to test if we have to show the cursor,
+ and explicily do so if necessary.
+ This is because when we destroy a window, we take the cursor away from the
+ cursor plane, and destroy the cusror GBM BO. So we have to re-show it,
+ so to say. */
+void
+KMSDRM_InitCursor()
+{
+ SDL_Mouse *mouse = NULL;
+ mouse = SDL_GetMouse();
+
+ if (!mouse) {
+ return;
+ }
+ if (!(mouse->cur_cursor)) {
+ return;
+ }
+
+ if (!(mouse->cursor_shown)) {
+ return;
+ }
+
+ KMSDRM_ShowCursor(mouse->cur_cursor);
+}
+
/* Show the specified cursor, or hide if cursor is NULL.
cur_cursor is the current cursor, and cursor is the new cursor.
A cursor is displayed on a display, so we have to add a pointer to dispdata
diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.h b/src/video/kmsdrm/SDL_kmsdrmmouse.h
index f44104e..8993a31 100644
--- a/src/video/kmsdrm/SDL_kmsdrmmouse.h
+++ b/src/video/kmsdrm/SDL_kmsdrmmouse.h
@@ -47,6 +47,8 @@ typedef struct _KMSDRM_CursorData
extern void KMSDRM_InitMouse(_THIS);
extern void KMSDRM_DeinitMouse(_THIS);
+extern void KMSDRM_InitCursor();
+
#endif /* SDL_KMSDRM_mouse_h_ */
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index 847f49d..678aefd 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -1748,9 +1748,14 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA);
}
- /* Can't init mouse sooner because planes are not ready.
- We do it along with the KMSDRM_GBMInit() call, so do this only when GBM is not init. */
+ /* Can't init mouse stuff sooner cursor plane is not ready. */
KMSDRM_InitMouse(_this);
+
+ /* Since we take cursor buffer way from the cursor plane and
+ destroy the cursor GBM BO when we destroy a window, we must
+ also manually re-show the cursor on screen, if necessary,
+ when we create a window. */
+ KMSDRM_InitCursor();
}
/* Allocate window internal data */