diff options
author | Ilya Fedin <fedin-ilja2010@ya.ru> | 2023-02-22 22:20:06 +0400 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-02-28 19:01:17 +0000 |
commit | e18fb7883ff8bfec716524ce7361ac7f553975b0 (patch) | |
tree | 6aae355f5588aa4f6ffd854707c759cb25eb602f /src/client/qwaylandwindow.cpp | |
parent | a0d484d1ee38a527aa6f95b091b564e8a1f8c224 (diff) | |
download | qtwayland-e18fb7883ff8bfec716524ce7361ac7f553975b0.tar.gz |
client: Unify margins handling
Currently all the shell integrations except of xdg-shell pass
full surface size to resizeFromApplyConfigure.
xdg-shell behavior is not even consistent between the first and the
consequent calls to resizeFromApplyConfigure.
This replaces QWaylandWindow::customMargins with
QWaylandWindow::windowContentMargins in order to being able to retrieve
set_window_geometry margins separately from the geometry itself
and makes xdg-shell passing the geometry consistently as full surface
size removing the need in special casing.
This also makes QWaylandWindow::clientSizeMargins public so e.g.
xdg-shell can compute out absolute position for window content geometry
without special casing decorations
Change-Id: I1b98afc8b5c867ecb7cc586267b13f7ec4b1a88c
Reviewed-by: David Edmundson <davidedmundson@kde.org>
(cherry picked from commit ae026d6ac7b7910b9f3934a1df2b69d3fce344bc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/client/qwaylandwindow.cpp')
-rw-r--r-- | src/client/qwaylandwindow.cpp | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index a109126d..a1c3a58e 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -455,20 +455,6 @@ void QWaylandWindow::repositionFromApplyConfigure(const QPoint &globalPosition) void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset) { QMargins margins = clientSideMargins(); - - // Exclude shadows from margins once they are excluded from window geometry - // 1) First resizeFromApplyConfigure() call will have sizeWithMargins equal to surfaceSize() - // which has full margins (shadows included). - // 2) Following resizeFromApplyConfigure() calls should have sizeWithMargins equal to - // windowContentGeometry() which excludes shadows, therefore in this case we have to - // exclude them too in order not to accidentally apply smaller size to the window. - if (sizeWithMargins != surfaceSize()) { - if (mWindowDecorationEnabled) - margins = mWindowDecoration->margins(QWaylandAbstractDecoration::ShadowsExcluded); - if (!mCustomMargins.isNull()) - margins -= mCustomMargins; - } - int widthWithoutMargins = qMax(sizeWithMargins.width() - (margins.left() + margins.right()), 1); int heightWithoutMargins = qMax(sizeWithMargins.height() - (margins.top() + margins.bottom()), 1); QRect geometry(windowGeometry().topLeft(), QSize(widthWithoutMargins, heightWithoutMargins)); @@ -803,11 +789,6 @@ QMargins QWaylandWindow::clientSideMargins() const return mWindowDecorationEnabled ? mWindowDecoration->margins() : QMargins{}; } -QMargins QWaylandWindow::customMargins() const -{ - return mCustomMargins; -} - void QWaylandWindow::setCustomMargins(const QMargins &margins) { const QMargins oldMargins = mCustomMargins; mCustomMargins = margins; @@ -822,11 +803,7 @@ QSize QWaylandWindow::surfaceSize() const return geometry().marginsAdded(clientSideMargins()).size(); } -/*! - * Window geometry as defined by the xdg-shell spec (in wl_surface coordinates) - * topLeft is where the shadow stops and the decorations border start. - */ -QRect QWaylandWindow::windowContentGeometry() const +QMargins QWaylandWindow::windowContentMargins() const { QMargins shadowMargins; @@ -836,7 +813,17 @@ QRect QWaylandWindow::windowContentGeometry() const if (!mCustomMargins.isNull()) shadowMargins += mCustomMargins; - return QRect(QPoint(shadowMargins.left(), shadowMargins.top()), surfaceSize().shrunkBy(shadowMargins)); + return shadowMargins; +} + +/*! + * Window geometry as defined by the xdg-shell spec (in wl_surface coordinates) + * topLeft is where the shadow stops and the decorations border start. + */ +QRect QWaylandWindow::windowContentGeometry() const +{ + const QMargins margins = windowContentMargins(); + return QRect(QPoint(margins.left(), margins.top()), surfaceSize().shrunkBy(margins)); } /*! |