Fixed touch coordinates with the new UI bounds calculation
authorSam Lantinga <slouken@libsdl.org>
Tue, 18 Sep 2012 22:50:09 -0700
changeset 6439 fbbd640d7867
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
--- a/src/video/uikit/SDL_uikitopengles.m	Tue Sep 18 22:24:40 2012 -0700
+++ b/src/video/uikit/SDL_uikitopengles.m	Tue Sep 18 22:50:09 2012 -0700
@@ -105,7 +105,13 @@
     UIWindow *uiwindow = data->uiwindow;
 
     /* construct our view, passing in SDL's OpenGL configuration data */
-    view = [[SDL_uikitopenglview alloc] initWithFrame: [uiwindow bounds]
+    CGRect frame;
+    if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
+        frame = [displaydata->uiscreen bounds];
+    } else {
+        frame = [displaydata->uiscreen applicationFrame];
+    }
+    view = [[SDL_uikitopenglview alloc] initWithFrame: frame
                                     scale: displaymodedata->scale
                                     retainBacking: _this->gl_config.retained_backing
                                     rBits: _this->gl_config.red_size
--- a/src/video/uikit/SDL_uikitview.m	Tue Sep 18 22:24:40 2012 -0700
+++ b/src/video/uikit/SDL_uikitview.m	Tue Sep 18 22:50:09 2012 -0700
@@ -79,9 +79,6 @@
 - (CGPoint)touchLocation:(UITouch *)touch shouldNormalize:(BOOL)normalize
 {
     CGPoint point = [touch locationInView: self];
-    CGRect frame = [self frame];
-
-    frame = CGRectApplyAffineTransform(frame, [self transform]);
 
     // Get the display scale and apply that to the input coordinates
     SDL_Window *window = self->viewcontroller.window;
@@ -91,8 +88,9 @@
     point.y *= displaymodedata->scale;
     
     if (normalize) {
-        point.x /= frame.size.width;
-        point.y /= frame.size.height;
+        CGRect bounds = [self bounds];
+        point.x /= bounds.size.width;
+        point.y /= bounds.size.height;
     }
     return point;
 }