From 60deaf5f0f8f52307cd764bfc25b1c5678a65817 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 30 Dec 2024 15:24:38 -0800 Subject: [PATCH] Send display mode change events when the orientation changes --- src/video/uikit/SDL_uikitmodes.m | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/video/uikit/SDL_uikitmodes.m b/src/video/uikit/SDL_uikitmodes.m index 8688dac1b3..029a2e1a6d 100644 --- a/src/video/uikit/SDL_uikitmodes.m +++ b/src/video/uikit/SDL_uikitmodes.m @@ -501,9 +501,15 @@ void SDL_OnApplicationDidChangeStatusBarOrientation(void) * fullscreen desktop keeps the window dimensions in the * correct orientation. */ if (isLandscape != (mode->w > mode->h)) { - int height = mode->w; - mode->w = mode->h; - mode->h = height; + SDL_DisplayMode new_mode; + SDL_copyp(&new_mode, mode); + new_mode.w = mode->h; + new_mode.h = mode->w; + + // Make sure we don't free the current display mode data + mode->internal = NULL; + + SDL_SetDesktopDisplayMode(display, &new_mode); } // Same deal with the fullscreen modes