diff --git a/src/video/uikit/SDL_uikitviewcontroller.h b/src/video/uikit/SDL_uikitviewcontroller.h index d5551ed81..a5a90428d 100755 --- a/src/video/uikit/SDL_uikitviewcontroller.h +++ b/src/video/uikit/SDL_uikitviewcontroller.h @@ -31,8 +31,10 @@ @property (readwrite) SDL_Window *window; - (id)initWithSDLWindow:(SDL_Window *)_window; -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient; - (void)loadView; +- (void)statusBarFrameChanged:(NSNotification*)notification; +- (void)onWindowSizeChanged; +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient; - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation; @end diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m index b42c09a97..be508b40c 100755 --- a/src/video/uikit/SDL_uikitviewcontroller.m +++ b/src/video/uikit/SDL_uikitviewcontroller.m @@ -43,9 +43,39 @@ return nil; } self.window = _window; + + // Register for notification when the status bar size changes + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameChanged:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil]; + return self; } +- (void)loadView +{ + // do nothing. +} + +- (void)statusBarFrameChanged:(NSNotification*)notification +{ + [self onWindowSizeChanged]; +} + +- (void)onWindowSizeChanged +{ + if (self->window->flags & SDL_WINDOW_RESIZABLE) { + SDL_WindowData *data = self->window->driverdata; + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(self->window); + SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata; + const CGSize size = data->view.bounds.size; + int w, h; + + w = (int)(size.width * displaymodedata->scale); + h = (int)(size.height * displaymodedata->scale); + + SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h); + } +} + - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient { // Don't allow upside-down orientation on the phone, so answering calls is in the natural orientation @@ -108,27 +138,14 @@ return NO; // Nothing else is acceptable. } -- (void)loadView -{ - // do nothing. -} - // Send a resized event when the orientation changes. - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { - const UIInterfaceOrientation toInterfaceOrientation = [self interfaceOrientation]; - SDL_WindowData *data = self->window->driverdata; - SDL_VideoDisplay *display = SDL_GetDisplayForWindow(self->window); - SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata; - const CGSize size = data->view.bounds.size; - int w, h; - - w = (int)(size.width * displaymodedata->scale); - h = (int)(size.height * displaymodedata->scale); - - SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h); + [self onWindowSizeChanged]; } #endif /* SDL_VIDEO_DRIVER_UIKIT */ @end + +/* vi: set ts=4 sw=4 expandtab: */