Fix virtual keyboard on Harmattan not following window content orientation changes
authorSimon Hausmann <simon.hausmann@nokia.com>
Thu, 26 Jan 2012 13:35:55 +0000 (14:35 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 26 Jan 2012 14:45:19 +0000 (15:45 +0100)
Track the input item's window and notify the input method server when the content
orientation changes.

Change-Id: I401c4fd677ed2eebd8b85968d4a2b3692517e097
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
src/plugins/platforminputcontexts/meego/qmeegoplatforminputcontext.cpp
src/plugins/platforminputcontexts/meego/qmeegoplatforminputcontext.h

index dc0a4f2..0df21e3 100644 (file)
@@ -151,6 +151,7 @@ public:
     bool correctionEnabled;
     QRect keyboardRect;
     QString preedit;
+    QWeakPointer<QWindow> window;
     QMeeGoPlatformInputContext *q;
 };
 
@@ -447,6 +448,11 @@ void QMeeGoPlatformInputContext::updateInputMethodArea(int x, int y, int width,
     emitKeyboardRectChanged();
 }
 
+void QMeeGoPlatformInputContext::updateServerWindowOrientation(Qt::ScreenOrientation orientation)
+{
+    d->server->appOrientationChanged(orientationAngle(orientation));
+}
+
 void QMeeGoPlatformInputContext::inputItemChanged()
 {
     if (!d->valid)
@@ -455,6 +461,15 @@ void QMeeGoPlatformInputContext::inputItemChanged()
     QInputPanel *panel = qApp->inputPanel();
     QObject *input = panel->inputItem();
     QWindow *window = panel->inputWindow();
+    if (window != d->window.data()) {
+       if (d->window)
+           disconnect(d->window.data(), SIGNAL(contentOrientationChanged(Qt::ScreenOrientation)),
+                      this, SLOT(updateServerWindowOrientation(Qt::ScreenOrientation)));
+        d->window = window;
+        if (d->window)
+            connect(d->window.data(), SIGNAL(contentOrientationChanged(Qt::ScreenOrientation)),
+                    this, SLOT(updateServerWindowOrientation(Qt::ScreenOrientation)));
+    }
 
     d->imState["focusState"] = input != 0;
     if (input) {
@@ -465,9 +480,8 @@ void QMeeGoPlatformInputContext::inputItemChanged()
             d->active = true;
             d->server->activateContext();
 
-            // ### react to orientation changes, too
             if (window)
-                d->server->appOrientationChanged(orientationAngle(window->screen()->orientation()));
+                d->server->appOrientationChanged(orientationAngle(window->contentOrientation()));
         }
     }
     d->sendStateUpdate(/*focusChanged*/true);
index e84ac20..8b3edd0 100644 (file)
@@ -86,6 +86,7 @@ public Q_SLOTS:
     void setRedirectKeys(bool );
     void setSelection(int start, int length);
     void updateInputMethodArea(int x, int y, int width, int height);
+    void updateServerWindowOrientation(Qt::ScreenOrientation orientation);
 
 private:
     QMeeGoPlatformInputContextPrivate *d;