Skip to content

Instantly share code, notes, and snippets.

@lauromoura
Created April 24, 2012 14:32
Show Gist options
  • Save lauromoura/2480130 to your computer and use it in GitHub Desktop.
Save lauromoura/2480130 to your computer and use it in GitHub Desktop.
QXcbWindow requestWindowOrientation fix
commit 68cac318403df59ef861b632b3af15b4342d8c83
Author: Lauro Neto <lauro.neto@openbossa.org>
Date: Tue Apr 24 15:35:15 2012 -0300
Add requestWindowOrientation implementation for QXcbWindow
QXcbWindow implements setOrientation in Maemo but the application
has no way to request a new orientation as QPlatformWindow implements
just a placeholder method.
Change-Id: I20d0be0c7f7e4593ac1e3c2ac2518144fc7fed0e
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 5a8f90b..4a8bbc9 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -1195,6 +1195,23 @@ void QXcbWindow::setOrientation(Qt::ScreenOrientation orientation)
atom(QXcbAtom::MeegoTouchOrientationAngle), XCB_ATOM_CARDINAL, 32,
1, &angle));
}
+
+Qt::ScreenOrientation QXcbWindow::requestWindowOrientation(Qt::ScreenOrientation orientation)
+{
+ switch (orientation) {
+ case Qt::PortraitOrientation:
+ case Qt::LandscapeOrientation:
+ case Qt::InvertedPortraitOrientation:
+ case Qt::InvertedLandscapeOrientation:
+ case Qt::PrimaryOrientation:
+ setOrientation(orientation);
+ break;
+ default: // Unsupported orientations
+ orientation = Qt::PrimaryOrientation;
+ }
+
+ return orientation;
+}
#endif
QSurfaceFormat QXcbWindow::format() const
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
index c212095..54bb9f3 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -81,6 +81,7 @@ public:
#if XCB_USE_MAEMO_WINDOW_PROPERTIES
void setOrientation(Qt::ScreenOrientation orientation);
+ Qt::ScreenOrientation requestWindowOrientation(Qt::ScreenOrientation orientation);
#endif
bool setKeyboardGrabEnabled(bool grab);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment