diff options
author | Giulio Camuffo <giulio.camuffo@jollamobile.com> | 2014-09-22 16:36:26 +0300 |
---|---|---|
committer | Giulio Camuffo <giulio.camuffo@jollamobile.com> | 2014-09-24 10:43:15 +0200 |
commit | be93c343c581c3375b2fe4412ff7b2c76f8df253 (patch) | |
tree | 4da47bcb0458738208dd35c4744047a740ac6130 /src/client | |
parent | 75cda1dcbcd7cddd1bd79218c305bf8814dc460f (diff) | |
download | qtwayland-be93c343c581c3375b2fe4412ff7b2c76f8df253.tar.gz |
Use the screen resolution to determine whether a screen is portrait
We were using the screen physical size to determine if a screen is
portrait or landscape, but we may not always get a valid size.
Instead use the screen resolution.
The orientation is then calculated in the wl_output.done handler,
since we don't know the resolution yet when receiving the first
wl_output.geometry event.
Change-Id: I3554f916e54db829f49fa3d1ea24f7ce1ff24e7c
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/qwaylandscreen.cpp | 52 | ||||
-rw-r--r-- | src/client/qwaylandscreen_p.h | 1 |
2 files changed, 30 insertions, 23 deletions
diff --git a/src/client/qwaylandscreen.cpp b/src/client/qwaylandscreen.cpp index 88667ae0..5c625ed4 100644 --- a/src/client/qwaylandscreen.cpp +++ b/src/client/qwaylandscreen.cpp @@ -61,6 +61,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, uint32_t id) , mExtendedOutput(0) , mDepth(32) , mRefreshRate(60000) + , mTransform(-1) , mFormat(QImage::Format_ARGB32_Premultiplied) , mOutputName(QStringLiteral("Screen%1").arg(id)) , m_orientation(Qt::PrimaryOrientation) @@ -178,29 +179,7 @@ void QWaylandScreen::output_geometry(int32_t x, int32_t y, Q_UNUSED(subpixel); Q_UNUSED(make); - bool isPortrait = height > width; - switch (transform) { - case WL_OUTPUT_TRANSFORM_NORMAL: - m_orientation = isPortrait ? Qt::PortraitOrientation : Qt::LandscapeOrientation; - break; - case WL_OUTPUT_TRANSFORM_90: - m_orientation = isPortrait ? Qt::InvertedLandscapeOrientation : Qt::PortraitOrientation; - break; - case WL_OUTPUT_TRANSFORM_180: - m_orientation = isPortrait ? Qt::InvertedPortraitOrientation : Qt::InvertedLandscapeOrientation; - break; - case WL_OUTPUT_TRANSFORM_270: - m_orientation = isPortrait ? Qt::LandscapeOrientation : Qt::InvertedPortraitOrientation; - break; - // Ignore these ones, at least for now - case WL_OUTPUT_TRANSFORM_FLIPPED: - case WL_OUTPUT_TRANSFORM_FLIPPED_90: - case WL_OUTPUT_TRANSFORM_FLIPPED_180: - case WL_OUTPUT_TRANSFORM_FLIPPED_270: - break; - } - - QWindowSystemInterface::handleScreenOrientationChange(screen(), m_orientation); + mTransform = transform; if (!model.isEmpty()) mOutputName = model; @@ -214,6 +193,33 @@ void QWaylandScreen::output_done() // the done event is sent after all the geometry and the mode events are sent, // and the last mode event to be sent is the active one, so we can trust the // values of mGeometry and mRefreshRate here + + if (mTransform >= 0) { + bool isPortrait = mGeometry.height() > mGeometry.width(); + switch (mTransform) { + case WL_OUTPUT_TRANSFORM_NORMAL: + m_orientation = isPortrait ? Qt::PortraitOrientation : Qt::LandscapeOrientation; + break; + case WL_OUTPUT_TRANSFORM_90: + m_orientation = isPortrait ? Qt::InvertedLandscapeOrientation : Qt::PortraitOrientation; + break; + case WL_OUTPUT_TRANSFORM_180: + m_orientation = isPortrait ? Qt::InvertedPortraitOrientation : Qt::InvertedLandscapeOrientation; + break; + case WL_OUTPUT_TRANSFORM_270: + m_orientation = isPortrait ? Qt::LandscapeOrientation : Qt::InvertedPortraitOrientation; + break; + // Ignore these ones, at least for now + case WL_OUTPUT_TRANSFORM_FLIPPED: + case WL_OUTPUT_TRANSFORM_FLIPPED_90: + case WL_OUTPUT_TRANSFORM_FLIPPED_180: + case WL_OUTPUT_TRANSFORM_FLIPPED_270: + break; + } + + QWindowSystemInterface::handleScreenOrientationChange(screen(), m_orientation); + mTransform = -1; + } QWindowSystemInterface::handleScreenGeometryChange(screen(), mGeometry, mGeometry); QWindowSystemInterface::handleScreenRefreshRateChange(screen(), refreshRate()); } diff --git a/src/client/qwaylandscreen_p.h b/src/client/qwaylandscreen_p.h index 866ac26e..49eeea67 100644 --- a/src/client/qwaylandscreen_p.h +++ b/src/client/qwaylandscreen_p.h @@ -103,6 +103,7 @@ private: QRect mGeometry; int mDepth; int mRefreshRate; + int mTransform; QImage::Format mFormat; QSize mPhysicalSize; QString mOutputName; |