Fixed touch coordinates with the new UI bounds calculation
authorSam Lantinga <slouken@libsdl.org>
Tue, 18 Sep 2012 22:50:09 -0700
changeset 6439fbbd640d7867
parent 6438 2c0fa683b18c
child 6440 f0ca76958984
Fixed touch coordinates with the new UI bounds calculation
src/video/uikit/SDL_uikitopengles.m
src/video/uikit/SDL_uikitview.m
     1.1 --- a/src/video/uikit/SDL_uikitopengles.m	Tue Sep 18 22:24:40 2012 -0700
     1.2 +++ b/src/video/uikit/SDL_uikitopengles.m	Tue Sep 18 22:50:09 2012 -0700
     1.3 @@ -105,7 +105,13 @@
     1.4      UIWindow *uiwindow = data->uiwindow;
     1.5  
     1.6      /* construct our view, passing in SDL's OpenGL configuration data */
     1.7 -    view = [[SDL_uikitopenglview alloc] initWithFrame: [uiwindow bounds]
     1.8 +    CGRect frame;
     1.9 +    if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
    1.10 +        frame = [displaydata->uiscreen bounds];
    1.11 +    } else {
    1.12 +        frame = [displaydata->uiscreen applicationFrame];
    1.13 +    }
    1.14 +    view = [[SDL_uikitopenglview alloc] initWithFrame: frame
    1.15                                      scale: displaymodedata->scale
    1.16                                      retainBacking: _this->gl_config.retained_backing
    1.17                                      rBits: _this->gl_config.red_size
     2.1 --- a/src/video/uikit/SDL_uikitview.m	Tue Sep 18 22:24:40 2012 -0700
     2.2 +++ b/src/video/uikit/SDL_uikitview.m	Tue Sep 18 22:50:09 2012 -0700
     2.3 @@ -79,9 +79,6 @@
     2.4  - (CGPoint)touchLocation:(UITouch *)touch shouldNormalize:(BOOL)normalize
     2.5  {
     2.6      CGPoint point = [touch locationInView: self];
     2.7 -    CGRect frame = [self frame];
     2.8 -
     2.9 -    frame = CGRectApplyAffineTransform(frame, [self transform]);
    2.10  
    2.11      // Get the display scale and apply that to the input coordinates
    2.12      SDL_Window *window = self->viewcontroller.window;
    2.13 @@ -91,8 +88,9 @@
    2.14      point.y *= displaymodedata->scale;
    2.15      
    2.16      if (normalize) {
    2.17 -        point.x /= frame.size.width;
    2.18 -        point.y /= frame.size.height;
    2.19 +        CGRect bounds = [self bounds];
    2.20 +        point.x /= bounds.size.width;
    2.21 +        point.y /= bounds.size.height;
    2.22      }
    2.23      return point;
    2.24  }