Updated support for external video output on the iPad
authorSam Lantinga
Sat, 29 Sep 2012 00:17:34 -0700
changeset 651141253d43a2cf
parent 6510 32432af683cf
child 6512 4beb596ccfae
Updated support for external video output on the iPad
src/video/uikit/SDL_uikitwindow.m
     1.1 --- a/src/video/uikit/SDL_uikitwindow.m	Sat Sep 29 00:01:32 2012 -0700
     1.2 +++ b/src/video/uikit/SDL_uikitwindow.m	Sat Sep 29 00:17:34 2012 -0700
     1.3 @@ -75,26 +75,31 @@
     1.4          /* Get frame dimensions in pixels */
     1.5          int width = (int)(bounds.size.width * displaymodedata->scale);
     1.6          int height = (int)(bounds.size.height * displaymodedata->scale);
     1.7 -
     1.8 -        /* We can pick either width or height here and we'll rotate the
     1.9 -           screen to match, so we pick the closest to what we wanted.
    1.10 -         */
    1.11 -        if (window->w >= window->h) {
    1.12 -            if (width > height) {
    1.13 -                window->w = width;
    1.14 -                window->h = height;
    1.15 +        
    1.16 +        if ([UIScreen mainScreen] == displaydata->uiscreen) {
    1.17 +            /* We can pick either width or height here and we'll rotate the
    1.18 +             screen to match, so we pick the closest to what we wanted.
    1.19 +             */
    1.20 +            if (window->w >= window->h) {
    1.21 +                if (width > height) {
    1.22 +                    window->w = width;
    1.23 +                    window->h = height;
    1.24 +                } else {
    1.25 +                    window->w = height;
    1.26 +                    window->h = width;
    1.27 +                }
    1.28              } else {
    1.29 -                window->w = height;
    1.30 -                window->h = width;
    1.31 +                if (width > height) {
    1.32 +                    window->w = height;
    1.33 +                    window->h = width;
    1.34 +                } else {
    1.35 +                    window->w = width;
    1.36 +                    window->h = height;
    1.37 +                }
    1.38              }
    1.39          } else {
    1.40 -            if (width > height) {
    1.41 -                window->w = height;
    1.42 -                window->h = width;
    1.43 -            } else {
    1.44 -                window->w = width;
    1.45 -                window->h = height;
    1.46 -            }
    1.47 +            window->w = width;
    1.48 +            window->h = height;
    1.49          }
    1.50      }
    1.51  
    1.52 @@ -106,27 +111,27 @@
    1.53      // SDL_WINDOW_BORDERLESS controls whether status bar is hidden.
    1.54      // This is only set if the window is on the main screen. Other screens
    1.55      //  just force the window to have the borderless flag.
    1.56 -    if ([UIScreen mainScreen] != displaydata->uiscreen) {
    1.57 -        window->flags &= ~SDL_WINDOW_RESIZABLE;  // window is NEVER resizeable
    1.58 -        window->flags &= ~SDL_WINDOW_INPUT_FOCUS;  // never has input focus
    1.59 -        window->flags |= SDL_WINDOW_BORDERLESS;  // never has a status bar.
    1.60 -    } else {
    1.61 +    if ([UIScreen mainScreen] == displaydata->uiscreen) {
    1.62          window->flags |= SDL_WINDOW_INPUT_FOCUS;  // always has input focus
    1.63 -
    1.64 +        
    1.65          if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
    1.66              [UIApplication sharedApplication].statusBarHidden = YES;
    1.67          } else {
    1.68              [UIApplication sharedApplication].statusBarHidden = NO;
    1.69          }
    1.70 +    } else {
    1.71 +        window->flags &= ~SDL_WINDOW_RESIZABLE;  // window is NEVER resizeable
    1.72 +        window->flags &= ~SDL_WINDOW_INPUT_FOCUS;  // never has input focus
    1.73 +        window->flags |= SDL_WINDOW_BORDERLESS;  // never has a status bar.
    1.74 +    }
    1.75  
    1.76 -        // The View Controller will handle rotating the view when the
    1.77 -        //  device orientation changes. This will trigger resize events, if
    1.78 -        //  appropriate.
    1.79 -        SDL_uikitviewcontroller *controller;
    1.80 -        controller = [SDL_uikitviewcontroller alloc];
    1.81 -        data->viewcontroller = [controller initWithSDLWindow:window];
    1.82 -        [data->viewcontroller setTitle:@"SDL App"];  // !!! FIXME: hook up SDL_SetWindowTitle()
    1.83 -    }
    1.84 +    // The View Controller will handle rotating the view when the
    1.85 +    //  device orientation changes. This will trigger resize events, if
    1.86 +    //  appropriate.
    1.87 +    SDL_uikitviewcontroller *controller;
    1.88 +    controller = [SDL_uikitviewcontroller alloc];
    1.89 +    data->viewcontroller = [controller initWithSDLWindow:window];
    1.90 +    [data->viewcontroller setTitle:@"SDL App"];  // !!! FIXME: hook up SDL_SetWindowTitle()
    1.91  
    1.92      return 0;
    1.93  }
    1.94 @@ -147,13 +152,6 @@
    1.95          return -1;
    1.96      }
    1.97  
    1.98 -    // Non-mainscreen windows must be force to borderless, as there's no
    1.99 -    //  status bar there, and we want to get the right dimensions later in
   1.100 -    //  this function.
   1.101 -    if (external) {
   1.102 -        window->flags |= SDL_WINDOW_BORDERLESS;
   1.103 -    }
   1.104 -
   1.105      // If monitor has a resolution of 0x0 (hasn't been explicitly set by the
   1.106      //  user, so it's in standby), try to force the display to a resolution
   1.107      //  that most closely matches the desired window size.