Moved display orientation handling on iOS out to a separate function for Qt apps
parent
f225af0c1e
commit
088070e5a8
|
@ -445,51 +445,7 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
|
||||||
#if !TARGET_OS_TV
|
#if !TARGET_OS_TV
|
||||||
- (void)application:(UIApplication *)application didChangeStatusBarOrientation:(UIInterfaceOrientation)oldStatusBarOrientation
|
- (void)application:(UIApplication *)application didChangeStatusBarOrientation:(UIInterfaceOrientation)oldStatusBarOrientation
|
||||||
{
|
{
|
||||||
BOOL isLandscape = UIInterfaceOrientationIsLandscape(application.statusBarOrientation);
|
SDL_OnApplicationDidChangeStatusBarOrientation();
|
||||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
|
||||||
|
|
||||||
if (_this && _this->num_displays > 0) {
|
|
||||||
SDL_DisplayMode *desktopmode = &_this->displays[0].desktop_mode;
|
|
||||||
SDL_DisplayMode *currentmode = &_this->displays[0].current_mode;
|
|
||||||
SDL_DisplayOrientation orientation = SDL_ORIENTATION_UNKNOWN;
|
|
||||||
|
|
||||||
/* The desktop display mode should be kept in sync with the screen
|
|
||||||
* orientation so that updating a window's fullscreen state to
|
|
||||||
* SDL_WINDOW_FULLSCREEN_DESKTOP keeps the window dimensions in the
|
|
||||||
* correct orientation. */
|
|
||||||
if (isLandscape != (desktopmode->w > desktopmode->h)) {
|
|
||||||
int height = desktopmode->w;
|
|
||||||
desktopmode->w = desktopmode->h;
|
|
||||||
desktopmode->h = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Same deal with the current mode + SDL_GetCurrentDisplayMode. */
|
|
||||||
if (isLandscape != (currentmode->w > currentmode->h)) {
|
|
||||||
int height = currentmode->w;
|
|
||||||
currentmode->w = currentmode->h;
|
|
||||||
currentmode->h = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (application.statusBarOrientation) {
|
|
||||||
case UIInterfaceOrientationPortrait:
|
|
||||||
orientation = SDL_ORIENTATION_PORTRAIT;
|
|
||||||
break;
|
|
||||||
case UIInterfaceOrientationPortraitUpsideDown:
|
|
||||||
orientation = SDL_ORIENTATION_PORTRAIT_FLIPPED;
|
|
||||||
break;
|
|
||||||
case UIInterfaceOrientationLandscapeLeft:
|
|
||||||
/* Bug: UIInterfaceOrientationLandscapeLeft/Right are reversed - http://openradar.appspot.com/7216046 */
|
|
||||||
orientation = SDL_ORIENTATION_LANDSCAPE_FLIPPED;
|
|
||||||
break;
|
|
||||||
case UIInterfaceOrientationLandscapeRight:
|
|
||||||
/* Bug: UIInterfaceOrientationLandscapeLeft/Right are reversed - http://openradar.appspot.com/7216046 */
|
|
||||||
orientation = SDL_ORIENTATION_LANDSCAPE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SDL_SendDisplayEvent(&_this->displays[0], SDL_DISPLAYEVENT_ORIENTATION, orientation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,10 @@ extern int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMo
|
||||||
extern void UIKit_QuitModes(_THIS);
|
extern void UIKit_QuitModes(_THIS);
|
||||||
extern int UIKit_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
|
extern int UIKit_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
|
||||||
|
|
||||||
|
#if !TARGET_OS_TV
|
||||||
|
extern void SDL_OnApplicationDidChangeStatusBarOrientation(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* SDL_uikitmodes_h_ */
|
#endif /* SDL_uikitmodes_h_ */
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#include "SDL_assert.h"
|
#include "SDL_assert.h"
|
||||||
#include "SDL_uikitmodes.h"
|
#include "SDL_uikitmodes.h"
|
||||||
|
|
||||||
|
#include "../../events/SDL_events_c.h"
|
||||||
|
|
||||||
@implementation SDL_DisplayData
|
@implementation SDL_DisplayData
|
||||||
|
|
||||||
@synthesize uiscreen;
|
@synthesize uiscreen;
|
||||||
|
@ -188,6 +190,9 @@ UIKit_InitModes(_THIS)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if !TARGET_OS_TV
|
||||||
|
SDL_OnApplicationDidChangeStatusBarOrientation();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -319,6 +324,55 @@ UIKit_QuitModes(_THIS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDL_OnApplicationDidChangeStatusBarOrientation()
|
||||||
|
{
|
||||||
|
BOOL isLandscape = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
|
||||||
|
SDL_VideoDisplay *display = SDL_GetDisplay(0);
|
||||||
|
|
||||||
|
if (display) {
|
||||||
|
SDL_DisplayMode *desktopmode = &display->desktop_mode;
|
||||||
|
SDL_DisplayMode *currentmode = &display->current_mode;
|
||||||
|
SDL_DisplayOrientation orientation = SDL_ORIENTATION_UNKNOWN;
|
||||||
|
|
||||||
|
/* The desktop display mode should be kept in sync with the screen
|
||||||
|
* orientation so that updating a window's fullscreen state to
|
||||||
|
* SDL_WINDOW_FULLSCREEN_DESKTOP keeps the window dimensions in the
|
||||||
|
* correct orientation. */
|
||||||
|
if (isLandscape != (desktopmode->w > desktopmode->h)) {
|
||||||
|
int height = desktopmode->w;
|
||||||
|
desktopmode->w = desktopmode->h;
|
||||||
|
desktopmode->h = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Same deal with the current mode + SDL_GetCurrentDisplayMode. */
|
||||||
|
if (isLandscape != (currentmode->w > currentmode->h)) {
|
||||||
|
int height = currentmode->w;
|
||||||
|
currentmode->w = currentmode->h;
|
||||||
|
currentmode->h = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ([UIApplication sharedApplication].statusBarOrientation) {
|
||||||
|
case UIInterfaceOrientationPortrait:
|
||||||
|
orientation = SDL_ORIENTATION_PORTRAIT;
|
||||||
|
break;
|
||||||
|
case UIInterfaceOrientationPortraitUpsideDown:
|
||||||
|
orientation = SDL_ORIENTATION_PORTRAIT_FLIPPED;
|
||||||
|
break;
|
||||||
|
case UIInterfaceOrientationLandscapeLeft:
|
||||||
|
/* Bug: UIInterfaceOrientationLandscapeLeft/Right are reversed - http://openradar.appspot.com/7216046 */
|
||||||
|
orientation = SDL_ORIENTATION_LANDSCAPE_FLIPPED;
|
||||||
|
break;
|
||||||
|
case UIInterfaceOrientationLandscapeRight:
|
||||||
|
/* Bug: UIInterfaceOrientationLandscapeLeft/Right are reversed - http://openradar.appspot.com/7216046 */
|
||||||
|
orientation = SDL_ORIENTATION_LANDSCAPE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
SDL_SendDisplayEvent(display, SDL_DISPLAYEVENT_ORIENTATION, orientation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* SDL_VIDEO_DRIVER_UIKIT */
|
#endif /* SDL_VIDEO_DRIVER_UIKIT */
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
Loading…
Reference in New Issue