From 56fb507a76442ca2312216e7da64e3c05e0540f7 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Tue, 26 Feb 2019 13:40:54 +0000 Subject: [PATCH] [wayland] Squash reconfigure methods Summary: We can handle the case of a null size inside ShellClient::requestGeometry and that makes that method more robust. With that we don't need to handle separate code paths in the handler of RequestGeometryBlocker. It's not an exact identical code path, but everything still works out. If the geometry is unchanged, we'll save the positionAfterResize but when we apply it doSetGeometry will no-op. There's also an assumption that toggling maximised will always send a valid size, but that's true for the current state. Test Plan: Ran unit tests Reviewers: #kwin, zzag Reviewed By: #kwin, zzag Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D19331 --- shell_client.cpp | 28 +++++++++++++++++++--------- shell_client.h | 6 +----- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/shell_client.cpp b/shell_client.cpp index e156b91a87..eb1e930047 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -1084,29 +1084,39 @@ bool ShellClient::requestGeometry(const QRect &rect) m_blockedRequestGeometry = rect; return false; } - PendingConfigureRequest configureRequest; - configureRequest.positionAfterResize = rect.topLeft(); - configureRequest.maximizeMode = m_requestedMaximizeMode; - const QSize size = rect.size() - QSize(borderLeft() + borderRight(), borderTop() + borderBottom()); + QSize size; + if (rect.isValid()) { + size = rect.size() - QSize(borderLeft() + borderRight(), borderTop() + borderBottom()); + } else { + size = QSize(0, 0); + } m_requestedClientSize = size; - if (m_shellSurface) { + quint64 serialId = 0; + + if (m_shellSurface && !size.isEmpty()) { m_shellSurface->requestSize(size); } if (m_xdgShellSurface) { - configureRequest.serialId = m_xdgShellSurface->configure(xdgSurfaceStates(), size); + serialId = m_xdgShellSurface->configure(xdgSurfaceStates(), size); } if (m_xdgShellPopup) { auto parent = transientFor(); if (parent) { const QPoint globalClientContentPos = parent->geometry().topLeft() + parent->clientPos(); - const QPoint relativeOffset = rect.topLeft() -globalClientContentPos; - configureRequest.serialId = m_xdgShellPopup->configure(QRect(relativeOffset, rect.size())); + const QPoint relativeOffset = rect.topLeft() - globalClientContentPos; + serialId = m_xdgShellPopup->configure(QRect(relativeOffset, rect.size())); } } - m_pendingConfigureRequests.append(configureRequest); + if (rect.isValid()) { //if there's no requested size, then there's implicity no positional information worth using + PendingConfigureRequest configureRequest; + configureRequest.serialId = serialId; + configureRequest.positionAfterResize = rect.topLeft(); + configureRequest.maximizeMode = m_requestedMaximizeMode; + m_pendingConfigureRequests.append(configureRequest); + } m_blockedRequestGeometry = QRect(); return true; diff --git a/shell_client.h b/shell_client.h index 51d00a75d8..6b2d8d5fab 100644 --- a/shell_client.h +++ b/shell_client.h @@ -269,11 +269,7 @@ private: { m_client->m_requestGeometryBlockCounter--; if (m_client->m_requestGeometryBlockCounter == 0) { - if (m_client->m_blockedRequestGeometry.isValid()) { - m_client->requestGeometry(m_client->m_blockedRequestGeometry); - } else if (m_client->m_xdgShellSurface) { - m_client->m_xdgShellSurface->configure(m_client->xdgSurfaceStates()); - } + m_client->requestGeometry(m_client->m_blockedRequestGeometry); } } private: