From ceae7175006c9b56acc63d40bcaa93986ed28572 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Wed, 28 Sep 2022 10:38:38 +0200 Subject: [PATCH] output: don't round geometry as often CCBUG: 459373 --- src/core/output.cpp | 5 +++++ src/core/output.h | 5 +++++ src/wayland/xdgoutput_v1_interface.cpp | 8 ++++---- src/workspace.cpp | 8 ++++---- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/core/output.cpp b/src/core/output.cpp index 374ca8551d..ddd98ab87e 100644 --- a/src/core/output.cpp +++ b/src/core/output.cpp @@ -169,6 +169,11 @@ QRect Output::geometry() const return QRect(m_state.position, pixelSize() / scale()); } +QRectF Output::fractionalGeometry() const +{ + return QRectF(m_state.position, QSizeF(pixelSize()) / scale()); +} + QSize Output::physicalSize() const { return orientateSize(m_information.physicalSize); diff --git a/src/core/output.h b/src/core/output.h index a65e726309..48b4db28ce 100644 --- a/src/core/output.h +++ b/src/core/output.h @@ -131,6 +131,11 @@ public: */ QRect geometry() const; + /** + * Returns geometry of this output in device independent pixels, without rounding + */ + QRectF fractionalGeometry() const; + /** * Equivalent to `QRect(QPoint(0, 0), geometry().size())` */ diff --git a/src/wayland/xdgoutput_v1_interface.cpp b/src/wayland/xdgoutput_v1_interface.cpp index 3436359da8..65ed5cc417 100644 --- a/src/wayland/xdgoutput_v1_interface.cpp +++ b/src/wayland/xdgoutput_v1_interface.cpp @@ -44,8 +44,8 @@ public: { } - QPoint pos; - QSize size; + QPointF pos; + QSizeF size; QString name; QString description; QPointer output; @@ -137,7 +137,7 @@ void XdgOutputV1Interface::update() return; } - const QRect geometry = d->output->handle()->geometry(); + const QRectF geometry = d->output->handle()->fractionalGeometry(); const auto resources = d->resourceMap(); if (d->pos != geometry.topLeft()) { @@ -194,7 +194,7 @@ void XdgOutputV1InterfacePrivate::sendLogicalSize(Resource *resource) ClientConnection *connection = output->display()->getConnection(resource->client()); qreal scaleOverride = connection->scaleOverride(); - send_logical_size(resource->handle, size.width() * scaleOverride, size.height() * scaleOverride); + send_logical_size(resource->handle, std::round(size.width() * scaleOverride), std::round(size.height() * scaleOverride)); } void XdgOutputV1InterfacePrivate::sendLogicalPosition(Resource *resource) diff --git a/src/workspace.cpp b/src/workspace.cpp index 4a6e3fa8ff..ef8259749b 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -2394,7 +2394,7 @@ void Workspace::updateClientArea() workAreas[desktop] = m_geometry; for (const Output *output : std::as_const(m_outputs)) { - screenAreas[desktop][output] = output->geometry(); + screenAreas[desktop][output] = output->fractionalGeometry(); } } @@ -2439,7 +2439,7 @@ void Workspace::updateClientArea() } restrictedAreas[vd] += strutRegion; for (Output *output : std::as_const(m_outputs)) { - const auto geo = screenAreas[vd][output].intersected(adjustClientArea(window, output->geometry())); + const auto geo = screenAreas[vd][output].intersected(adjustClientArea(window, output->fractionalGeometry())); // ignore the geometry if it results in the screen getting removed completely if (!geo.isEmpty()) { screenAreas[vd][output] = geo; @@ -2488,12 +2488,12 @@ QRectF Workspace::clientArea(clientAreaOption opt, const Output *output, const V return *outputIt; } } - return output->geometry(); + return output->fractionalGeometry(); case MaximizeFullArea: case FullScreenArea: case MovementArea: case ScreenArea: - return output->geometry(); + return output->fractionalGeometry(); case WorkArea: return m_workAreas.value(desktop, m_geometry); case FullArea: