diff options
author | Matt Hoosier <matt.hoosier@garmin.com> | 2018-06-12 11:13:20 -0500 |
---|---|---|
committer | Matt Hoosier <matt.hoosier@garmin.com> | 2018-06-17 01:39:22 +0000 |
commit | 17eb840b65c1e62351c99a0ca64937e2deaf32de (patch) | |
tree | ebfa0acc1433ae34d589f75819a63012fdc19ed6 /src/compositor/extensions/qwaylandwlshellintegration.cpp | |
parent | 254b1428724f3e79248b906ad4cba810c0d37572 (diff) |
Compositor: make WlShell reconfigure clients on output geometry change
[ChangeLog][Compositor] Made the wl_shell compositor protocol
implementation re-issue configure requests with updated sizes
when the size or available geometry changes on output used by
a maximized or fullscreen surface.
Change-Id: I5a688afb315523281d6661e2d098423acfb1a297
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Diffstat (limited to 'src/compositor/extensions/qwaylandwlshellintegration.cpp')
-rw-r--r-- | src/compositor/extensions/qwaylandwlshellintegration.cpp | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/src/compositor/extensions/qwaylandwlshellintegration.cpp b/src/compositor/extensions/qwaylandwlshellintegration.cpp index 9e1e9dd6d..896b1587d 100644 --- a/src/compositor/extensions/qwaylandwlshellintegration.cpp +++ b/src/compositor/extensions/qwaylandwlshellintegration.cpp @@ -99,6 +99,12 @@ void WlShellIntegration::handleSetDefaultTopLevel() // so we need to unset the flags here but we save the previous state and move // to the initial position when redrawing nextState = State::Windowed; + + // Any handlers for making maximized or fullscreen state track the size of + // the designated output, are unneeded now that we're going to windowed + // state. + nonwindowedState.output = nullptr; + disconnect(nonwindowedState.sizeChangedConnection); } void WlShellIntegration::handleSetTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, bool inactive) @@ -129,8 +135,23 @@ void WlShellIntegration::handleSetMaximized(QWaylandOutput *output) nextState = State::Maximized; finalPosition = designatedOutput->position() + designatedOutput->availableGeometry().topLeft(); - auto scaleFactor = m_item->view()->output()->scaleFactor(); - m_shellSurface->sendConfigure(designatedOutput->availableGeometry().size() / scaleFactor, QWaylandWlShellSurface::NoneEdge); + // Any prior output-resize handlers are irrelevant at this point + disconnect(nonwindowedState.sizeChangedConnection); + nonwindowedState.output = designatedOutput; + nonwindowedState.sizeChangedConnection = connect(designatedOutput, &QWaylandOutput::availableGeometryChanged, this, &WlShellIntegration::handleMaximizedSizeChanged); + handleMaximizedSizeChanged(); +} + +void WlShellIntegration::handleMaximizedSizeChanged() +{ + if (!m_shellSurface) + return; + + if (nextState == State::Maximized) { + QWaylandOutput *designatedOutput = nonwindowedState.output; + auto scaleFactor = designatedOutput->scaleFactor(); + m_shellSurface->sendConfigure(designatedOutput->availableGeometry().size() / scaleFactor, QWaylandWlShellSurface::NoneEdge); + } } void WlShellIntegration::handleSetFullScreen(QWaylandWlShellSurface::FullScreenMethod method, uint framerate, QWaylandOutput *output) @@ -154,7 +175,22 @@ void WlShellIntegration::handleSetFullScreen(QWaylandWlShellSurface::FullScreenM nextState = State::FullScreen; finalPosition = designatedOutput->position(); - m_shellSurface->sendConfigure(designatedOutput->geometry().size(), QWaylandWlShellSurface::NoneEdge); + // Any prior output-resize handlers are irrelevant at this point + disconnect(nonwindowedState.sizeChangedConnection); + nonwindowedState.output = designatedOutput; + nonwindowedState.sizeChangedConnection = connect(designatedOutput, &QWaylandOutput::geometryChanged, this, &WlShellIntegration::handleFullScreenSizeChanged); + handleFullScreenSizeChanged(); +} + +void WlShellIntegration::handleFullScreenSizeChanged() +{ + if (!m_shellSurface) + return; + + if (nextState == State::FullScreen) { + QWaylandOutput *designatedOutput = nonwindowedState.output; + m_shellSurface->sendConfigure(designatedOutput->geometry().size(), QWaylandWlShellSurface::NoneEdge); + } } void WlShellIntegration::handleSetPopup(QWaylandSeat *seat, QWaylandSurface *parent, const QPoint &relativeToParent) @@ -221,6 +257,11 @@ void WlShellIntegration::handleShellSurfaceDestroyed() { if (isPopup) handlePopupRemoved(); + + // Disarm any handlers that might fire and attempt to use the now-stale pointer + nonwindowedState.output = nullptr; + disconnect(nonwindowedState.sizeChangedConnection); + m_shellSurface = nullptr; } |