kmsdrm: defer surface recreation inside of KMSDRM_SetWindowSize and KMSDRM_SetWindowFullscreen as is done in KMSDRM_SetWindowDisplayMode
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
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index 094558d..f44a9b4 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -920,6 +920,22 @@ KMSDRM_GetModeToSet(SDL_Window *window, drmModeModeInfo *out_mode) {
}
}
+static void
+KMSDRM_DirtySurfaces(SDL_Window *window) {
+ SDL_WindowData *windata = (SDL_WindowData *)window->driverdata;
+ drmModeModeInfo mode;
+
+ /* Can't recreate EGL surfaces right now, need to wait until SwapWindow
+ so the correct thread-local surface and context state are available */
+ windata->egl_surface_dirty = SDL_TRUE;
+
+ /* The app may be waiting for the resize event after calling SetWindowSize
+ or SetWindowFullscreen, send a fake event for now since the actual
+ recreation is deferred */
+ KMSDRM_GetModeToSet(window, &mode);
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, mode.hdisplay, mode.vdisplay);
+}
+
/* This determines the size of the fb, which comes from the GBM surface
that we create here. */
int
@@ -1098,15 +1114,7 @@ KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
dispdata->fullscreen_mode = conn->modes[modedata->mode_index];
for (i = 0; i < viddata->num_windows; i++) {
- SDL_Window *window = viddata->windows[i];
- SDL_WindowData *windata = (SDL_WindowData *)window->driverdata;
-
- /* Can't recreate EGL surfaces right now, need to wait until SwapWindow
- so the correct thread-local surface and context state are available */
- windata->egl_surface_dirty = SDL_TRUE;
-
- /* Tell app about the window resize */
- SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, mode->w, mode->h);
+ KMSDRM_DirtySurfaces(viddata->windows[i]);
}
return 0;
@@ -1376,7 +1384,7 @@ KMSDRM_SetWindowSize(_THIS, SDL_Window * window)
{
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
if (!viddata->vulkan_mode) {
- KMSDRM_CreateSurfaces(_this, window);
+ KMSDRM_DirtySurfaces(window);
}
}
void
@@ -1385,7 +1393,7 @@ KMSDRM_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * displa
{
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
if (!viddata->vulkan_mode) {
- KMSDRM_CreateSurfaces(_this, window);
+ KMSDRM_DirtySurfaces(window);
}
}
void