diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2016-12-07 11:52:55 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-12-16 15:02:46 +0000 |
commit | 4e7af898b28fa8995582a4c0df0455a575525911 (patch) | |
tree | 3f79310ac8f282c978329579f627b2b7616712be /src/compositor/extensions | |
parent | 391c71b4488d69f3a0b16171b01f569fbc9ec07b (diff) |
Add support for running compositors with custom device pixel ratio
And add a manual test for showing that it works with different scale factors as
well.
Task-number: QTBUG-55303
Change-Id: Ib842ea51cfb62a2d46713e95d56b8a9da445d14d
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
Diffstat (limited to 'src/compositor/extensions')
-rw-r--r-- | src/compositor/extensions/qwaylandwlshellintegration.cpp | 17 | ||||
-rw-r--r-- | src/compositor/extensions/qwaylandwlshellintegration_p.h | 1 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/compositor/extensions/qwaylandwlshellintegration.cpp b/src/compositor/extensions/qwaylandwlshellintegration.cpp index abf5b627c..b32416764 100644 --- a/src/compositor/extensions/qwaylandwlshellintegration.cpp +++ b/src/compositor/extensions/qwaylandwlshellintegration.cpp @@ -125,7 +125,8 @@ void WlShellIntegration::handleSetMaximized(QWaylandOutput *output) nextState = State::Maximized; finalPosition = designatedOutput->position() + designatedOutput->availableGeometry().topLeft(); - m_shellSurface->sendConfigure(designatedOutput->availableGeometry().size(), QWaylandWlShellSurface::NoneEdge); + auto scaleFactor = m_item->view()->output()->scaleFactor(); + m_shellSurface->sendConfigure(designatedOutput->availableGeometry().size() / scaleFactor, QWaylandWlShellSurface::NoneEdge); } void WlShellIntegration::handleSetFullScreen(QWaylandWlShellSurface::FullScreenMethod method, uint framerate, QWaylandOutput *output) @@ -176,8 +177,9 @@ void WlShellIntegration::handleSetPopup(QWaylandSeat *seat, QWaylandSurface *par t.clear(&t); m_item->setRotation(0); m_item->setScale(1.0); - m_item->setX(relativeToParent.x()); - m_item->setY(relativeToParent.y()); + auto scaleFactor = m_item->output()->scaleFactor() / devicePixelRatio(); + m_item->setX(relativeToParent.x() * scaleFactor); + m_item->setY(relativeToParent.y() * scaleFactor); m_item->setParentItem(parentItem); } @@ -206,6 +208,11 @@ void WlShellIntegration::handlePopupRemoved() isPopup = false; } +qreal WlShellIntegration::devicePixelRatio() const +{ + return m_item->window() ? m_item->window()->devicePixelRatio() : 1; +} + void WlShellIntegration::handleShellSurfaceDestroyed() { if (isPopup) @@ -237,7 +244,7 @@ void WlShellIntegration::adjustOffsetForNextFrame(const QPointF &offset) float scaleFactor = m_item->view()->output()->scaleFactor(); QQuickItem *moveItem = m_item->moveItem(); - moveItem->setPosition(moveItem->position() + offset * scaleFactor); + moveItem->setPosition(moveItem->position() + offset * scaleFactor / devicePixelRatio()); } bool WlShellIntegration::mouseMoveEvent(QMouseEvent *event) @@ -250,7 +257,7 @@ bool WlShellIntegration::mouseMoveEvent(QMouseEvent *event) return true; } float scaleFactor = m_item->view()->output()->scaleFactor(); - QPointF delta = (event->windowPos() - resizeState.initialMousePos) / scaleFactor; + QPointF delta = (event->windowPos() - resizeState.initialMousePos) / scaleFactor * devicePixelRatio(); QSize newSize = m_shellSurface->sizeForResize(resizeState.initialSize, delta, resizeState.resizeEdges); m_shellSurface->sendConfigure(newSize, resizeState.resizeEdges); } else if (grabberState == GrabberState::Move) { diff --git a/src/compositor/extensions/qwaylandwlshellintegration_p.h b/src/compositor/extensions/qwaylandwlshellintegration_p.h index c0bbcfd10..d5ecffac1 100644 --- a/src/compositor/extensions/qwaylandwlshellintegration_p.h +++ b/src/compositor/extensions/qwaylandwlshellintegration_p.h @@ -86,6 +86,7 @@ private: void handlePopupClosed(); void handlePopupRemoved(); + qreal devicePixelRatio() const; QWaylandQuickShellSurfaceItem *m_item; QPointer<QWaylandWlShellSurface> m_shellSurface; |