Commit be93c343 authored by Giulio Camuffo's avatar Giulio Camuffo
Browse files

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: default avatarGunnar Sletta <gunnar@sletta.org>
Showing with 30 additions and 23 deletions
...@@ -61,6 +61,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, uint32_t id) ...@@ -61,6 +61,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, uint32_t id)
, mExtendedOutput(0) , mExtendedOutput(0)
, mDepth(32) , mDepth(32)
, mRefreshRate(60000) , mRefreshRate(60000)
, mTransform(-1)
, mFormat(QImage::Format_ARGB32_Premultiplied) , mFormat(QImage::Format_ARGB32_Premultiplied)
, mOutputName(QStringLiteral("Screen%1").arg(id)) , mOutputName(QStringLiteral("Screen%1").arg(id))
, m_orientation(Qt::PrimaryOrientation) , m_orientation(Qt::PrimaryOrientation)
...@@ -178,29 +179,7 @@ void QWaylandScreen::output_geometry(int32_t x, int32_t y, ...@@ -178,29 +179,7 @@ void QWaylandScreen::output_geometry(int32_t x, int32_t y,
Q_UNUSED(subpixel); Q_UNUSED(subpixel);
Q_UNUSED(make); Q_UNUSED(make);
bool isPortrait = height > width; mTransform = transform;
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);
if (!model.isEmpty()) if (!model.isEmpty())
mOutputName = model; mOutputName = model;
...@@ -214,6 +193,33 @@ void QWaylandScreen::output_done() ...@@ -214,6 +193,33 @@ void QWaylandScreen::output_done()
// the done event is sent after all the geometry and the mode events are sent, // 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 // and the last mode event to be sent is the active one, so we can trust the
// values of mGeometry and mRefreshRate here // 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::handleScreenGeometryChange(screen(), mGeometry, mGeometry);
QWindowSystemInterface::handleScreenRefreshRateChange(screen(), refreshRate()); QWindowSystemInterface::handleScreenRefreshRateChange(screen(), refreshRate());
} }
......
...@@ -103,6 +103,7 @@ private: ...@@ -103,6 +103,7 @@ private:
QRect mGeometry; QRect mGeometry;
int mDepth; int mDepth;
int mRefreshRate; int mRefreshRate;
int mTransform;
QImage::Format mFormat; QImage::Format mFormat;
QSize mPhysicalSize; QSize mPhysicalSize;
QString mOutputName; QString mOutputName;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment