Fixed SDL_SetWindowFullscreen on iOS to properly update the view's frame.
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
diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m
index f25479b..275579a 100644
--- a/src/video/uikit/SDL_uikitwindow.m
+++ b/src/video/uikit/SDL_uikitwindow.m
@@ -240,6 +240,7 @@ UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
SDL_uikitviewcontroller *viewcontroller = windowdata->viewcontroller;
UIWindow *uiwindow = windowdata->uiwindow;
+ CGRect bounds;
if (fullscreen || (window->flags & SDL_WINDOW_BORDERLESS)) {
[UIApplication sharedApplication].statusBarHidden = YES;
@@ -253,13 +254,17 @@ UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
}
#endif
- CGRect bounds;
- if (fullscreen) {
+ if (fullscreen || (window->flags & SDL_WINDOW_BORDERLESS)) {
bounds = [displaydata->uiscreen bounds];
} else {
bounds = [displaydata->uiscreen applicationFrame];
}
+ /* Update the view's frame to account for the status bar change. */
+ windowdata->view.frame = bounds;
+ [windowdata->view setNeedsLayout];
+ [windowdata->view layoutIfNeeded];
+
/* Get frame dimensions */
int width = (int) bounds.size.width;
int height = (int) bounds.size.height;
@@ -268,21 +273,11 @@ UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
screen to match, so we pick the closest to what we wanted.
*/
if (window->w >= window->h) {
- if (width > height) {
- window->w = width;
- window->h = height;
- } else {
- window->w = height;
- window->h = width;
- }
+ window->w = SDL_max(width, height);
+ window->h = SDL_min(width, height);
} else {
- if (width > height) {
- window->w = height;
- window->h = width;
- } else {
- window->w = width;
- window->h = height;
- }
+ window->w = SDL_min(width, height);
+ window->h = SDL_max(width, height);
}
}