summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2012-01-13 10:31:11 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-24 15:38:48 +0100
commitb39df8bf92a530783144dbcf5cae939742ff2d23 (patch)
tree0560985d33f59a48693acadbdfbb59b328131499 /src/gui
parentb0a0403daf81e82ea732aa91ec92cf94553a7935 (diff)
Made window orientation API more flexible.
Previously we only had QWindow::setOrientation() which was a hint about the orientation the window's contents were rendered in. However, it's necessary to separate between the orientation corresponding to the window buffer layout and orientation of the contents. A game for example might typically want to use a landscape buffer even on a portrait device. Thus, we replace QWindow::orientation() with QWindow::reportContentOrientationChange() and QWindow::requestWindowOrientation(). Change-Id: I1f07362192daf36c45519cb05b43ac352f1945b5 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qguiapplication.cpp21
-rw-r--r--src/gui/kernel/qguiapplication_p.h1
-rw-r--r--src/gui/kernel/qplatformscreen_qpa.cpp29
-rw-r--r--src/gui/kernel/qplatformscreen_qpa.h3
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.cpp31
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.h3
-rw-r--r--src/gui/kernel/qscreen.cpp111
-rw-r--r--src/gui/kernel/qscreen.h18
-rw-r--r--src/gui/kernel/qscreen_p.h9
-rw-r--r--src/gui/kernel/qwindow.cpp102
-rw-r--r--src/gui/kernel/qwindow.h12
-rw-r--r--src/gui/kernel/qwindow_p.h6
12 files changed, 246 insertions, 100 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 6a8f8582be..b3adcfcbaf 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1078,11 +1078,16 @@ void QGuiApplicationPrivate::reportScreenOrientationChange(QWindowSystemInterfac
return;
QScreen *s = e->screen.data();
- s->d_func()->currentOrientation = e->orientation;
+ s->d_func()->orientation = e->orientation;
- emit s->currentOrientationChanged(s->currentOrientation());
+ reportScreenOrientationChange(s);
+}
+
+void QGuiApplicationPrivate::reportScreenOrientationChange(QScreen *s)
+{
+ emit s->orientationChanged(s->orientation());
- QScreenOrientationChangeEvent event(s, s->currentOrientation());
+ QScreenOrientationChangeEvent event(s, s->orientation());
QCoreApplication::sendEvent(QCoreApplication::instance(), &event);
}
@@ -1098,6 +1103,10 @@ void QGuiApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate:
QScreen *s = e->screen.data();
s->d_func()->geometry = e->geometry;
+ Qt::ScreenOrientation primaryOrientation = s->primaryOrientation();
+ Qt::ScreenOrientation orientation = s->orientation();
+ s->d_func()->updatePrimaryOrientation();
+
emit s->sizeChanged(s->size());
emit s->geometryChanged(s->geometry());
emit s->physicalDotsPerInchXChanged(s->physicalDotsPerInchX());
@@ -1105,6 +1114,12 @@ void QGuiApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate:
emit s->physicalDotsPerInchChanged(s->physicalDotsPerInch());
emit s->availableSizeChanged(s->availableSize());
emit s->availableGeometryChanged(s->availableGeometry());
+
+ if (s->primaryOrientation() != primaryOrientation)
+ emit s->primaryOrientationChanged(s->primaryOrientation());
+
+ if (s->orientation() != orientation)
+ reportScreenOrientationChange(s);
}
void QGuiApplicationPrivate::reportAvailableGeometryChange(
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 09db13e28e..7881d8a955 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -122,6 +122,7 @@ public:
static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
+ static void reportScreenOrientationChange(QScreen *screen);
static void reportScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e);
static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e);
diff --git a/src/gui/kernel/qplatformscreen_qpa.cpp b/src/gui/kernel/qplatformscreen_qpa.cpp
index 7006b77a36..37a3aeddc8 100644
--- a/src/gui/kernel/qplatformscreen_qpa.cpp
+++ b/src/gui/kernel/qplatformscreen_qpa.cpp
@@ -160,36 +160,15 @@ QDpi QPlatformScreen::logicalDpi() const
}
/*!
- Reimplement this function in subclass to return the primary orientation
- of the screen, i.e. the orientation the display controller or equivalent
- expects.
-
- The default implementation returns Qt::PortraitOrientation if the
- geometry's height is greater or Qt::LandscapeOrientation if the geometry's
- width is greater.
-*/
-Qt::ScreenOrientation QPlatformScreen::primaryOrientation() const
-{
- return geometry().height() > geometry().width() ? Qt::PortraitOrientation :
- Qt::LandscapeOrientation;
-}
-
-/*!
Reimplement this function in subclass to return the current orientation
of the screen, for example based on accelerometer data to determine
- the physical screen orientation.
-
- The current orientation is only a hint to the application saying
- what the preferred application orientation should be, the application
- is free to limit itself to a certain set of supported orientations.
-
- The default implementation returns the same as primaryOrientation().
+ the device orientation.
- \sa primaryOrientation()
+ The default implementation returns Qt::PrimaryOrientation.
*/
-Qt::ScreenOrientation QPlatformScreen::currentOrientation() const
+Qt::ScreenOrientation QPlatformScreen::orientation() const
{
- return primaryOrientation();
+ return Qt::PrimaryOrientation;
}
QPlatformScreen * QPlatformScreen::platformScreenForWindow(const QWindow *window)
diff --git a/src/gui/kernel/qplatformscreen_qpa.h b/src/gui/kernel/qplatformscreen_qpa.h
index 09a243aa83..04cc2ccc39 100644
--- a/src/gui/kernel/qplatformscreen_qpa.h
+++ b/src/gui/kernel/qplatformscreen_qpa.h
@@ -99,8 +99,7 @@ public:
virtual QSizeF physicalSize() const;
virtual QDpi logicalDpi() const;
- virtual Qt::ScreenOrientation currentOrientation() const;
- virtual Qt::ScreenOrientation primaryOrientation() const;
+ virtual Qt::ScreenOrientation orientation() const;
virtual QWindow *topLevelAt(const QPoint &point) const;
virtual QList<QPlatformScreen *> virtualSiblings() const;
diff --git a/src/gui/kernel/qplatformwindow_qpa.cpp b/src/gui/kernel/qplatformwindow_qpa.cpp
index 463267869c..b9506e7999 100644
--- a/src/gui/kernel/qplatformwindow_qpa.cpp
+++ b/src/gui/kernel/qplatformwindow_qpa.cpp
@@ -239,19 +239,44 @@ void QPlatformWindow::requestActivateWindow()
}
/*!
- Set the orientation of the platform window's contents.
+ Handle changes to the orientation of the platform window's contents.
This is a hint to the window manager in case it needs to display
additional content like popups, dialogs, status bars, or similar
in relation to the window.
- \sa QWindow::setOrientation()
+ \sa QWindow::reportContentOrientationChange()
*/
-void QPlatformWindow::setOrientation(Qt::ScreenOrientation orientation)
+void QPlatformWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation)
{
Q_UNUSED(orientation);
}
+/*!
+ Request a different orientation of the platform window.
+
+ This tells the window manager how the window wants to be rotated in order
+ to be displayed, and how input events should be translated.
+
+ As an example, a portrait compositor might rotate the window by 90 degrees,
+ if the window is in landscape. It will also rotate input coordinates from
+ portrait to landscape such that top right in portrait gets mapped to top
+ left in landscape.
+
+ If the implementation doesn't support the requested orientation it should
+ signal this by returning an actual supported orientation.
+
+ If the implementation doesn't support rotating the window at all it should
+ return Qt::PrimaryOrientation, this is also the default value.
+
+ \sa QWindow::requestWindowOrientation()
+*/
+Qt::ScreenOrientation QPlatformWindow::requestWindowOrientation(Qt::ScreenOrientation orientation)
+{
+ Q_UNUSED(orientation);
+ return Qt::PrimaryOrientation;
+}
+
bool QPlatformWindow::setKeyboardGrabEnabled(bool grab)
{
Q_UNUSED(grab);
diff --git a/src/gui/kernel/qplatformwindow_qpa.h b/src/gui/kernel/qplatformwindow_qpa.h
index 509cf30fa8..de5c955eba 100644
--- a/src/gui/kernel/qplatformwindow_qpa.h
+++ b/src/gui/kernel/qplatformwindow_qpa.h
@@ -95,7 +95,8 @@ public:
virtual void setOpacity(qreal level);
virtual void requestActivateWindow();
- virtual void setOrientation(Qt::ScreenOrientation orientation);
+ virtual void handleContentOrientationChange(Qt::ScreenOrientation orientation);
+ virtual Qt::ScreenOrientation requestWindowOrientation(Qt::ScreenOrientation orientation);
virtual bool setKeyboardGrabEnabled(bool grab);
virtual bool setMouseGrabEnabled(bool grab);
diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp
index 0a7d22c6c8..43c2dcc50d 100644
--- a/src/gui/kernel/qscreen.cpp
+++ b/src/gui/kernel/qscreen.cpp
@@ -343,35 +343,36 @@ QRect QScreen::availableVirtualGeometry() const
}
/*!
- \property QScreen::primaryOrientation
- \brief the primary screen orientation
+ \property QScreen::orientation
+ \brief the screen orientation
+
+ The screen orientation represents the physical orientation
+ of the display. For example, the screen orientation of a mobile device
+ will change based on the device is being held, and a desktop display
+ might be rotated so that it's in portrait mode.
- The primary screen orientation is the orientation that corresponds
- to an un-rotated screen buffer. When the current orientation is equal
- to the primary orientation no rotation needs to be done by the
- application.
+ \sa primaryOrientation(), orientationChanged()
*/
-Qt::ScreenOrientation QScreen::primaryOrientation() const
+Qt::ScreenOrientation QScreen::orientation() const
{
Q_D(const QScreen);
- return d->platformScreen->primaryOrientation();
+ return d->orientation == Qt::PrimaryOrientation ? primaryOrientation() : d->orientation;
}
/*!
\property QScreen::primaryOrientation
- \brief the current screen orientation
+ \brief the primary screen orientation
- The current orientation is a hint to the application saying
- what the preferred application orientation should be, based on the
- current orientation of the physical display and / or other factors.
+ The primary screen orientation is Qt::LandscapeOrientation
+ if the screen geometry's width is greater than or equal to its
+ height, or Qt::PortraitOrientation otherwise.
- \sa primaryOrientation()
- \sa currentOrientationChanged()
+ \sa primaryOrientationChanged()
*/
-Qt::ScreenOrientation QScreen::currentOrientation() const
+Qt::ScreenOrientation QScreen::primaryOrientation() const
{
Q_D(const QScreen);
- return d->currentOrientation;
+ return d->primaryOrientation;
}
// i must be power of two
@@ -393,10 +394,18 @@ static int log2(uint i)
rotation \a a to rotation \a b.
The result will be 0, 90, 180, or 270.
+
+ Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation().
*/
int QScreen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b)
{
- if (a == Qt::UnknownOrientation || b == Qt::UnknownOrientation || a == b)
+ if (a == Qt::PrimaryOrientation)
+ a = primaryOrientation();
+
+ if (b == Qt::PrimaryOrientation)
+ b = primaryOrientation();
+
+ if (a == b)
return 0;
int ia = log2(uint(a));
@@ -420,10 +429,18 @@ int QScreen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b)
the resulting transform will be such that the point QPoint(0, 0) is mapped to QPoint(0, w),
and QPoint(h, w) is mapped to QPoint(0, h). Thus, the landscape coordinate system QRect(0, 0, h, w)
is mapped (with a 90 degree rotation) into the portrait coordinate system QRect(0, 0, w, h).
+
+ Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation().
*/
QTransform QScreen::transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target)
{
- if (a == Qt::UnknownOrientation || b == Qt::UnknownOrientation || a == b)
+ if (a == Qt::PrimaryOrientation)
+ a = primaryOrientation();
+
+ if (b == Qt::PrimaryOrientation)
+ b = primaryOrientation();
+
+ if (a == b)
return QTransform();
int angle = angleBetween(a, b);
@@ -453,10 +470,18 @@ QTransform QScreen::transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientat
This will flip the x and y dimensions of the rectangle if orientation \a is
Qt::PortraitOrientation or Qt::InvertedPortraitOrientation and orientation \b is
Qt::LandscapeOrientation or Qt::InvertedLandscapeOrientation, or vice versa.
+
+ Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation().
*/
QRect QScreen::mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect)
{
- if (a == Qt::UnknownOrientation || b == Qt::UnknownOrientation || a == b)
+ if (a == Qt::PrimaryOrientation)
+ a = primaryOrientation();
+
+ if (b == Qt::PrimaryOrientation)
+ b = primaryOrientation();
+
+ if (a == b)
return rect;
if ((a == Qt::PortraitOrientation || a == Qt::InvertedPortraitOrientation)
@@ -469,14 +494,50 @@ QRect QScreen::mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, cons
}
/*!
- \fn QScreen::currentOrientationChanged(Qt::ScreenOrientation orientation)
+ Convenience function to check if a screen orientation is either portrait
+ or inverted portrait.
- This signal is emitted when the current orientation of the screen
- changes. The current orientation is a hint to the application saying
- what the preferred application orientation should be, based on the
- current orientation of the physical display and / or other factors.
+ Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation().
+*/
+bool QScreen::isPortrait(Qt::ScreenOrientation o)
+{
+ return o == Qt::PortraitOrientation || o == Qt::InvertedPortraitOrientation
+ || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::PortraitOrientation);
+}
- \sa currentOrientation()
+/*!
+ Convenience function to check if a screen orientation is either landscape
+ or inverted landscape.
+
+ Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation().
+*/
+bool QScreen::isLandscape(Qt::ScreenOrientation o)
+{
+ return o == Qt::LandscapeOrientation || o == Qt::InvertedLandscapeOrientation
+ || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::LandscapeOrientation);
+}
+
+/*!
+ \fn QScreen::orientationChanged(Qt::ScreenOrientation orientation)
+
+ This signal is emitted when the orientation of the screen
+ changes.
+
+ \sa orientation()
*/
+/*!
+ \fn QScreen::primaryOrientationChanged(Qt::ScreenOrientation orientation)
+
+ This signal is emitted when the primary orientation of the screen
+ changes.
+
+ \sa primaryOrientation()
+*/
+
+void QScreenPrivate::updatePrimaryOrientation()
+{
+ primaryOrientation = geometry.width() >= geometry.height() ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h
index c45590c1b4..aa3d750b41 100644
--- a/src/gui/kernel/qscreen.h
+++ b/src/gui/kernel/qscreen.h
@@ -81,8 +81,8 @@ class Q_GUI_EXPORT QScreen : public QObject
Q_PROPERTY(qreal logicalDotsPerInch READ logicalDotsPerInch NOTIFY logicalDotsPerInchChanged)
Q_PROPERTY(QSize availableSize READ availableSize NOTIFY availableSizeChanged)
Q_PROPERTY(QRect availableGeometry READ availableGeometry NOTIFY availableGeometryChanged)
- Q_PROPERTY(Qt::ScreenOrientation primaryOrientation READ primaryOrientation CONSTANT)
- Q_PROPERTY(Qt::ScreenOrientation currentOrientation READ currentOrientation NOTIFY currentOrientationChanged)
+ Q_PROPERTY(Qt::ScreenOrientation primaryOrientation READ orientation NOTIFY primaryOrientationChanged)
+ Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation NOTIFY orientationChanged)
public:
QPlatformScreen *handle() const;
@@ -116,11 +116,14 @@ public:
QRect availableVirtualGeometry() const;
Qt::ScreenOrientation primaryOrientation() const;
- Qt::ScreenOrientation currentOrientation() const;
+ Qt::ScreenOrientation orientation() const;
- static int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b);
- static QTransform transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target);
- static QRect mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect);
+ int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b);
+ QTransform transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target);
+ QRect mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect);
+
+ bool isPortrait(Qt::ScreenOrientation orientation);
+ bool isLandscape(Qt::ScreenOrientation orientation);
Q_SIGNALS:
void sizeChanged(const QSize &size);
@@ -133,7 +136,8 @@ Q_SIGNALS:
void logicalDotsPerInchChanged(qreal dpi);
void availableSizeChanged(const QSize &size);
void availableGeometryChanged(const QRect &rect);
- void currentOrientationChanged(Qt::ScreenOrientation orientation);
+ void primaryOrientationChanged(Qt::ScreenOrientation orientation);
+ void orientationChanged(Qt::ScreenOrientation orientation);
private:
QScreen(QPlatformScreen *screen);
diff --git a/src/gui/kernel/qscreen_p.h b/src/gui/kernel/qscreen_p.h
index 545534df29..2fdf12dd90 100644
--- a/src/gui/kernel/qscreen_p.h
+++ b/src/gui/kernel/qscreen_p.h
@@ -59,13 +59,18 @@ public:
QScreenPrivate(QPlatformScreen *screen)
: platformScreen(screen)
{
- currentOrientation = screen->currentOrientation();
+ orientation = screen->orientation();
geometry = screen->geometry();
availableGeometry = screen->availableGeometry();
logicalDpi = screen->logicalDpi();
+
+ updatePrimaryOrientation();
}
- Qt::ScreenOrientation currentOrientation;
+ void updatePrimaryOrientation();
+
+ Qt::ScreenOrientation orientation;
+ Qt::ScreenOrientation primaryOrientation;
QRect geometry;
QRect availableGeometry;
QDpi logicalDpi;
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 2893273ce0..65ac5f1539 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -72,8 +72,24 @@ QT_BEGIN_NAMESPACE
to support double and triple buffering. To release a windows memory
resources, the destroy() function.
- */
-
+ \section1 Window and content orientation
+
+ QWindow has reportContentOrientationChange() and
+ requestWindowOrientation() that can be used to specify the
+ layout of the window contents in relation to the screen. The
+ window orientation determines the actual buffer layout of the
+ window, and the windowing system uses this value to rotate the
+ window before it ends up on the display, and to ensure that input
+ coordinates are in the correct coordinate space relative to the
+ application.
+
+ On the other hand, the content orientation is simply a hint to the
+ windowing system about which orientation the window contents are in.
+ It's useful when you wish to keep the same buffer layout, but rotate
+ the contents instead, especially when doing rotation animations
+ between different orientations. The windowing system might use this
+ value to determine the layout of system popups or dialogs.
+*/
QWindow::QWindow(QScreen *targetScreen)
: QObject(*new QWindowPrivate(), 0)
, QSurface(QSurface::Window)
@@ -375,42 +391,82 @@ bool QWindow::isActive() const
}
/*!
- Returns the window's currently set orientation.
+ Reports that the orientation of the window's contents have changed.
+
+ This is a hint to the window manager in case it needs to display
+ additional content like popups, dialogs, status bars, or similar
+ in relation to the window.
+
+ The recommended orientation is QScreen::orientation() but
+ an application doesn't have to support all possible orientations,
+ and thus can opt to ignore the current screen orientation.
+
+ The difference between the window and the content orientation
+ determines how much to rotate the content by. QScreen::angleBetween(),
+ QScreen::transformBetween(), and QScreen::mapBetween() can be used
+ to compute the necessary transform.
+
+ \sa requestWindowOrientation(), QScreen::orientation()
+*/
+void QWindow::reportContentOrientationChange(Qt::ScreenOrientation orientation)
+{
+ Q_D(QWindow);
+ if (!d->platformWindow)
+ create();
+ Q_ASSERT(d->platformWindow);
+ d->contentOrientation = orientation;
+ d->platformWindow->handleContentOrientationChange(orientation);
+}
- The default value is Qt::UnknownOrientation.
+/*!
+ Returns the actual content orientation.
- \sa setOrientation(), QScreen::currentOrientation()
+ This is the last value set with reportContentOrientationChange(),
+ except Qt::PrimaryOrientation gets converted to the screen's
+ primary orientation.
*/
-Qt::ScreenOrientation QWindow::orientation() const
+Qt::ScreenOrientation QWindow::contentOrientation() const
{
Q_D(const QWindow);
- return d->orientation;
+ return d->contentOrientation == Qt::PrimaryOrientation ? screen()->primaryOrientation() : d->contentOrientation;
}
/*!
- Set the orientation of the window's contents.
+ Requests the given window orientation.
- This is a hint to the window manager in case it needs to display
- additional content like popups, dialogs, status bars, or similar
- in relation to the window.
+ The window orientation specifies how the window should be rotated
+ by the window manager in order to be displayed. Input events will
+ be correctly mapped to the given orientation.
- The recommended orientation is QScreen::currentOrientation() but
- an application doesn't have to support all possible orientations,
- and thus can opt to ignore the current screen orientation.
+ The return value is false if the system doesn't support the given
+ orientation (for example when requesting a portrait orientation
+ on a device that only handles landscape buffers, typically a desktop
+ system).
+
+ If the return value is false, call windowOrientation() to get the actual
+ supported orientation.
- \sa QScreen::currentOrientation()
+ \sa windowOrientation(), reportContentOrientationChange(), QScreen::orientation()
*/
-void QWindow::setOrientation(Qt::ScreenOrientation orientation)
+bool QWindow::requestWindowOrientation(Qt::ScreenOrientation orientation)
{
Q_D(QWindow);
- if (orientation == d->orientation)
- return;
+ if (!d->platformWindow)
+ create();
+ Q_ASSERT(d->platformWindow);
+ d->windowOrientation = d->platformWindow->requestWindowOrientation(orientation);
+ return d->windowOrientation == orientation;
+}
- d->orientation = orientation;
- if (d->platformWindow) {
- d->platformWindow->setOrientation(orientation);
- }
- emit orientationChanged(orientation);
+/*!
+ Returns the actual window orientation.
+
+ \sa requestWindowOrientation()
+*/
+Qt::ScreenOrientation QWindow::windowOrientation() const
+{
+ Q_D(const QWindow);
+ return d->windowOrientation == Qt::PrimaryOrientation ? screen()->primaryOrientation() : d->windowOrientation;
}
Qt::WindowState QWindow::windowState() const
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index 6f3c64fe15..088192d714 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -91,7 +91,6 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface
Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged)
- Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
public:
enum SurfaceType { RasterSurface, OpenGLSurface };
@@ -133,8 +132,11 @@ public:
bool isActive() const;
- Qt::ScreenOrientation orientation() const;
- void setOrientation(Qt::ScreenOrientation orientation);
+ void reportContentOrientationChange(Qt::ScreenOrientation orientation);
+ Qt::ScreenOrientation contentOrientation() const;
+
+ bool requestWindowOrientation(Qt::ScreenOrientation orientation);
+ Qt::ScreenOrientation windowOrientation() const;
Qt::WindowState windowState() const;
void setWindowState(Qt::WindowState state);
@@ -252,17 +254,13 @@ Q_SIGNALS:
void screenChanged(QScreen *screen);
void xChanged(int arg);
-
void yChanged(int arg);
void widthChanged(int arg);
-
void heightChanged(int arg);
void visibleChanged(bool arg);
- void orientationChanged(Qt::ScreenOrientation arg);
-
private Q_SLOTS:
void screenDestroyed(QObject *screen);
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index 2bb9173d94..2e28205f86 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -76,7 +76,8 @@ public:
, windowState(Qt::WindowNoState)
, resizeEventPending(true)
, positionPolicy(WindowFrameExclusive)
- , orientation(Qt::UnknownOrientation)
+ , contentOrientation(Qt::PrimaryOrientation)
+ , windowOrientation(Qt::PrimaryOrientation)
, maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)
, modality(Qt::NonModal)
, transientParent(0)
@@ -111,7 +112,8 @@ public:
Qt::WindowState windowState;
bool resizeEventPending;
PositionPolicy positionPolicy;
- Qt::ScreenOrientation orientation;
+ Qt::ScreenOrientation contentOrientation;
+ Qt::ScreenOrientation windowOrientation;
QSize minimumSize;
QSize maximumSize;