Add support for QWindow::setOrientation on Harmattan
authorSimon Hausmann <simon.hausmann@nokia.com>
Tue, 17 Jan 2012 09:03:32 +0000 (10:03 +0100)
committerQt by Nokia <qt-info@nokia.com>
Tue, 17 Jan 2012 11:21:56 +0000 (12:21 +0100)
Set the _MEEGOTOUCH_ORIENTATION_ANGLE property on the window, just like
Qt Components for MeeGo and MeegoTouch itself.

Change-Id: I0b9adf4550593678bbcba89a2d4f1f65c1f4bd20
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/plugins/platforms/xcb/qxcbconnection.cpp
src/plugins/platforms/xcb/qxcbconnection.h
src/plugins/platforms/xcb/qxcbwindow.cpp
src/plugins/platforms/xcb/qxcbwindow.h
src/plugins/platforms/xcb/xcb.pro

index ca21b1e..afc6c18 100644 (file)
@@ -909,6 +909,9 @@ static const char * xcb_atomnames = {
     "Abs MT Pressure\0"
     "Abs MT Tracking ID\0"
     "Max Contacts\0"
+#if XCB_USE_MAEMO_WINDOW_PROPERTIES
+    "_MEEGOTOUCH_ORIENTATION_ANGLE\0"
+#endif
 };
 
 xcb_atom_t QXcbConnection::atom(QXcbAtom::Atom atom)
index c227b4c..1feba55 100644 (file)
@@ -243,6 +243,10 @@ namespace QXcbAtom {
         AbsMTTrackingID,
         MaxContacts,
 
+#if XCB_USE_MAEMO_WINDOW_PROPERTIES
+        MeegoTouchOrientationAngle,
+#endif
+
         NPredefinedAtoms,
 
         _QT_SETTINGS_TIMESTAMP = NPredefinedAtoms,
index 2cd2a15..760605b 100644 (file)
@@ -1148,6 +1148,23 @@ void QXcbWindow::requestActivateWindow()
     connection()->sync();
 }
 
+#if XCB_USE_MAEMO_WINDOW_PROPERTIES
+void QXcbWindow::setOrientation(Qt::ScreenOrientation orientation)
+{
+    int angle = 0;
+    switch (orientation) {
+        case Qt::PortraitOrientation: angle = 270; break;
+        case Qt::LandscapeOrientation: angle = 0; break;
+        case Qt::InvertedPortraitOrientation: angle = 90; break;
+        case Qt::InvertedLandscapeOrientation: angle = 180; break;
+        case Qt::UnknownOrientation: break;
+    }
+    Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
+                                   atom(QXcbAtom::MeegoTouchOrientationAngle), XCB_ATOM_CARDINAL, 32,
+                                   1, &angle));
+}
+#endif
+
 QSurfaceFormat QXcbWindow::format() const
 {
     // ### return actual format
index f0b6437..a0e0d85 100644 (file)
@@ -79,6 +79,10 @@ public:
 
     void requestActivateWindow();
 
+#if XCB_USE_MAEMO_WINDOW_PROPERTIES
+    void setOrientation(Qt::ScreenOrientation orientation);
+#endif
+
     bool setKeyboardGrabEnabled(bool grab);
     bool setMouseGrabEnabled(bool grab);
 
index 2498581..823a12b 100644 (file)
@@ -46,11 +46,14 @@ contains(QT_CONFIG, xcb-xlib) {
     DEFINES += XCB_USE_XLIB
     LIBS += -lX11 -lX11-xcb
 
-    linux-g++-maemo:contains(QT_CONFIG, xinput2) {
-        # XInput2 support for Harmattan.
-        DEFINES += XCB_USE_XINPUT2_MAEMO
-        SOURCES += qxcbconnection_maemo.cpp
-        LIBS += -lXi
+    linux-g++-maemo {
+        contains(QT_CONFIG, xinput2) {
+            # XInput2 support for Harmattan.
+            DEFINES += XCB_USE_XINPUT2_MAEMO
+            SOURCES += qxcbconnection_maemo.cpp
+            LIBS += -lXi
+        }
+        DEFINES += XCB_USE_MAEMO_WINDOW_PROPERTIES
     }
 }