diff options
author | Ilya Fedin <fedin-ilja2010@ya.ru> | 2023-02-22 22:20:06 +0400 |
---|---|---|
committer | Ilya Fedin <fedin-ilja2010@ya.ru> | 2023-02-28 22:44:47 +0400 |
commit | ae026d6ac7b7910b9f3934a1df2b69d3fce344bc (patch) | |
tree | fd02c5eb29f00db5be2e2333d96bbcd90232b19e /src/client/qwaylandwindow.cpp | |
parent | 95edcfabc2a289f74421b7e6228e1c58bbdfb8a9 (diff) | |
download | qtwayland-ae026d6ac7b7910b9f3934a1df2b69d3fce344bc.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
Pick-to: 6.5
Change-Id: I1b98afc8b5c867ecb7cc586267b13f7ec4b1a88c
Reviewed-by: David Edmundson <davidedmundson@kde.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 6aa2c6ab..a77cce5a 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -460,20 +460,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)); @@ -808,11 +794,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; @@ -827,11 +808,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; @@ -841,7 +818,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)); } /*! |