From a0a38b3c86cbcfaf37cff12c7c6493431aa4c3f5 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 18 Sep 2012 22:50:09 -0700 Subject: [PATCH] Fixed touch coordinates with the new UI bounds calculation --- src/video/uikit/SDL_uikitopengles.m | 8 +++++++- src/video/uikit/SDL_uikitview.m | 8 +++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/video/uikit/SDL_uikitopengles.m b/src/video/uikit/SDL_uikitopengles.m index d819b1a24..70721d2c8 100755 --- a/src/video/uikit/SDL_uikitopengles.m +++ b/src/video/uikit/SDL_uikitopengles.m @@ -105,7 +105,13 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window) 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 diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index 3e4afc561..82dde8600 100755 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -79,9 +79,6 @@ - (id)initWithFrame:(CGRect)frame - (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 @@ - (CGPoint)touchLocation:(UITouch *)touch shouldNormalize:(BOOL)normalize 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; }