summaryrefslogtreecommitdiff
path: root/src/client/qwaylandwindow.cpp
diff options
context:
space:
mode:
authorJan Grulich <jgrulich@redhat.com>2021-03-17 15:45:54 +0100
committerJan Grulich <jgrulich@redhat.com>2021-04-19 05:43:25 +0100
commit2c10fa3785c1c0312625d543c8457df655432d82 (patch)
tree2f161c90c724babb6db339426c9a4f2648d33772 /src/client/qwaylandwindow.cpp
parent20d7cc45933a4a26c886b47c0b69da82195e7204 (diff)
downloadqtwayland-2c10fa3785c1c0312625d543c8457df655432d82.tar.gz
Client: get correct window content geometry
We have to apply geometry where we don't include shadows, because we need them to be ignored in some scenarios. Also, with geometry being already shrunk by the size of shadow margins, we have to avoid doing it again, otherwise we can accidentally make our window smaller every time we update its size or state. Change-Id: I0e26ee1be8d918913125ee7f7c97de56ccc797cf Reviewed-by: David Edmundson <davidedmundson@kde.org>
Diffstat (limited to 'src/client/qwaylandwindow.cpp')
-rw-r--r--src/client/qwaylandwindow.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index 4d59a2b7..27a9e562 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -374,7 +374,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
sendExposeEvent(exposeGeometry);
if (mShellSurface && isExposed())
- mShellSurface->setWindowGeometry(QRect(QPoint(), surfaceSize()));
+ mShellSurface->setWindowGeometry(windowContentGeometry());
if (isOpaque() && mMask.isEmpty())
setOpaqueArea(rect);
@@ -383,6 +383,16 @@ void QWaylandWindow::setGeometry(const QRect &rect)
void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
{
QMargins margins = frameMargins();
+
+ // 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 (mWindowDecoration && (sizeWithMargins != surfaceSize()))
+ margins = mWindowDecoration->margins(QWaylandAbstractDecoration::ShadowsExcluded);
+
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));
@@ -708,7 +718,7 @@ QRect QWaylandWindow::windowContentGeometry() const
if (mWindowDecoration)
shadowMargins = mWindowDecoration->margins(QWaylandAbstractDecoration::ShadowsOnly);
- return QRect(QPoint(shadowMargins.left(), shadowMargins.right()), surfaceSize().shrunkBy(shadowMargins));
+ return QRect(QPoint(shadowMargins.left(), shadowMargins.top()), surfaceSize().shrunkBy(shadowMargins));
}
/*!