summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2012-12-18 09:50:28 +0100
committerTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-02-27 23:55:57 +0100
commit31796ca8abb8878165c7099145b08abfdf8bf1e3 (patch)
tree9a48bbe00ee83432fdb2b8d3bba9f5ddaa0dfb61 /src/plugins
parentb960424195634c00673d499e4719ccb4f8704ad0 (diff)
iOS: report changes to keyboard rect back to Qt
QInputContext expects us to report whenever the input panel changes geometry. This patch implements this. Change-Id: I9162f0d48da6925274a7489c9bcb6adab9afae82 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/ios/qiosglobal.h1
-rw-r--r--src/plugins/platforms/ios/qiosglobal.mm9
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.h1
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.mm15
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm4
5 files changed, 25 insertions, 5 deletions
diff --git a/src/plugins/platforms/ios/qiosglobal.h b/src/plugins/platforms/ios/qiosglobal.h
index 7a23a2a485..849d9bce37 100644
--- a/src/plugins/platforms/ios/qiosglobal.h
+++ b/src/plugins/platforms/ios/qiosglobal.h
@@ -54,6 +54,7 @@ CGRect toCGRect(const QRect &rect);
QRect fromCGRect(const CGRect &rect);
Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientation);
UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation);
+QRect fromPortraitToPrimary(const QRect &rect);
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm
index a8a89a1637..f9b4b14a19 100644
--- a/src/plugins/platforms/ios/qiosglobal.mm
+++ b/src/plugins/platforms/ios/qiosglobal.mm
@@ -113,5 +113,14 @@ UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation)
return uiOrientation;
}
+QRect fromPortraitToPrimary(const QRect &rect)
+{
+ // UIScreen is always in portrait. Use this function to convert CGRects
+ // aligned with UIScreen into whatever is the current orientation of QScreen.
+ QScreen *screen = QGuiApplication::primaryScreen();
+ return screen->isPortrait(screen->primaryOrientation()) ? rect
+ : QRect(rect.y(), screen->geometry().width() - rect.width() - rect.x(), rect.height(), rect.width());
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/ios/qiosinputcontext.h b/src/plugins/platforms/ios/qiosinputcontext.h
index 22782d183c..ceed5ffaf2 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.h
+++ b/src/plugins/platforms/ios/qiosinputcontext.h
@@ -56,6 +56,7 @@ public:
QIOSInputContext();
~QIOSInputContext();
+ QRectF keyboardRect() const;
void showInputPanel();
void hideInputPanel();
bool isInputPanelVisible() const;
diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm
index 7937337e4a..89d210cb54 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.mm
+++ b/src/plugins/platforms/ios/qiosinputcontext.mm
@@ -39,6 +39,7 @@
**
****************************************************************************/
+#include "qiosglobal.h"
#include "qiosinputcontext.h"
#include "qioswindow.h"
#include <QGuiApplication>
@@ -47,6 +48,7 @@
@public
QIOSInputContext *m_context;
BOOL m_keyboardVisible;
+ QRectF m_keyboardRect;
}
@end
@@ -80,6 +82,10 @@
{
CGRect frame;
[[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&frame];
+
+ m_keyboardRect = fromPortraitToPrimary(fromCGRect(frame));
+ m_context->emitKeyboardRectChanged();
+
BOOL visible = CGRectIntersectsRect(frame, [UIScreen mainScreen].bounds);
if (m_keyboardVisible != visible) {
m_keyboardVisible = visible;
@@ -90,8 +96,8 @@
@end
QIOSInputContext::QIOSInputContext()
- : QPlatformInputContext(),
- m_keyboardListener([[QIOSKeyboardListener alloc] initWithQIOSInputContext:this])
+ : QPlatformInputContext()
+ , m_keyboardListener([[QIOSKeyboardListener alloc] initWithQIOSInputContext:this])
{
}
@@ -100,6 +106,11 @@ QIOSInputContext::~QIOSInputContext()
[m_keyboardListener release];
}
+QRectF QIOSInputContext::keyboardRect() const
+{
+ return m_keyboardListener->m_keyboardRect;
+}
+
void QIOSInputContext::showInputPanel()
{
if (isInputPanelVisible())
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index fdf2f31ea1..a0403a0d69 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -212,11 +212,9 @@ void QIOSScreen::setPrimaryOrientation(Qt::ScreenOrientation orientation)
return;
// Switching portrait/landscape means swapping width/height (and adjusting x/y):
- CGRect frame = m_uiScreen.applicationFrame;
- m_availableGeometry = portrait ? QRect(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height)
- : QRect(frame.origin.y, m_geometry.width() - frame.size.width - frame.origin.x, frame.size.height, frame.size.width);
m_geometry = QRect(0, 0, m_geometry.height(), m_geometry.width());
m_physicalSize = QSizeF(m_physicalSize.height(), m_physicalSize.width());
+ m_availableGeometry = fromPortraitToPrimary(fromCGRect(m_uiScreen.applicationFrame));
QWindowSystemInterface::handleScreenGeometryChange(screen(), m_geometry);
QWindowSystemInterface::handleScreenAvailableGeometryChange(screen(), m_availableGeometry);