Fix QWaylandScreen geometry and physical size

The wl_output.geometry event carries the physical size of the output,
not the logical one. This happened to work only because the geometry
event was sent before the mode event, which carries the logical size.
Moreover, use the done event to send only one geometry change event
instead of one per advertized mode.

Change-Id: I5b09d56654aac149d90692bb5a3e050cc0d60cb6
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
This commit is contained in:
Giulio Camuffo 2014-09-06 00:26:20 +03:00
parent f58e56ccf9
commit c9dbc3d97d
2 changed files with 19 additions and 12 deletions

View File

@ -95,6 +95,11 @@ QImage::Format QWaylandScreen::format() const
return mFormat;
}
QSizeF QWaylandScreen::physicalSize() const
{
return mPhysicalSize;
}
QDpi QWaylandScreen::logicalDpi() const
{
static int force_dpi = !qgetenv("QT_WAYLAND_FORCE_DPI").isEmpty() ? qgetenv("QT_WAYLAND_FORCE_DPI").toInt() : -1;
@ -153,16 +158,11 @@ void QWaylandScreen::output_mode(uint32_t flags, int width, int height, int refr
QSize size(width, height);
if (size != mGeometry.size()) {
if (size != mGeometry.size())
mGeometry.setSize(size);
QWindowSystemInterface::handleScreenGeometryChange(screen(), mGeometry);
QWindowSystemInterface::handleScreenAvailableGeometryChange(screen(), mGeometry);
}
if (refresh != mRefreshRate) {
if (refresh != mRefreshRate)
mRefreshRate = refresh;
QWindowSystemInterface::handleScreenRefreshRateChange(screen(), refreshRate());
}
}
void QWaylandScreen::output_geometry(int32_t x, int32_t y,
@ -202,14 +202,18 @@ void QWaylandScreen::output_geometry(int32_t x, int32_t y,
if (!model.isEmpty())
mOutputName = model;
QRect geom(x, y, width, height);
mPhysicalSize = QSize(width, height);
mGeometry.moveTopLeft(QPoint(x, y));
}
if (mGeometry == geom)
return;
mGeometry = geom;
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
QWindowSystemInterface::handleScreenGeometryChange(screen(), mGeometry);
QWindowSystemInterface::handleScreenAvailableGeometryChange(screen(), mGeometry);
QWindowSystemInterface::handleScreenRefreshRateChange(screen(), refreshRate());
}
QT_END_NAMESPACE

View File

@ -65,6 +65,8 @@ public:
int depth() const;
QImage::Format format() const;
QSizeF physicalSize() const Q_DECL_OVERRIDE;
QDpi logicalDpi() const Q_DECL_OVERRIDE;
void setOrientationUpdateMask(Qt::ScreenOrientations mask);
@ -93,6 +95,7 @@ private:
const QString &make,
const QString &model,
int32_t transform) Q_DECL_OVERRIDE;
void output_done() Q_DECL_OVERRIDE;
int m_outputId;
QWaylandDisplay *mWaylandDisplay;