summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVlad Zahorodnii <vlad.zahorodnii@kde.org>2022-10-21 12:35:15 +0300
committerVlad Zahorodnii <vlad.zahorodnii@kde.org>2022-12-05 18:27:59 +0200
commit2262713fe95a05ad4cb28d4daca6cba5acfa0dff (patch)
tree9f56925afaf2b4925b34c864ad303fef229b2e73 /src
parent35d82dcae8d4d766fed77331dd4da6abe6495f06 (diff)
downloadqtwayland-2262713fe95a05ad4cb28d4daca6cba5acfa0dff.tar.gz
Client: Improve handling of 0xH and Wx0 xdg_toplevel configure events
The compositor can send a configure event with 0xH and Wx0 when it wants the window to have some concrete size along one dimension but wants the client to pick the size along the other dimension. Change-Id: I2e72017d4a71b19a930da24fa5c58b6ce672fb94 Reviewed-by: David Edmundson <davidedmundson@kde.org>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
index c0d7a7d4..9bd5209f 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
@@ -58,19 +58,38 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
m_xdgSurface->m_window->handleToplevelWindowTilingStatesChanged(m_toplevelStates);
m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
- if (m_pending.size.isEmpty()) {
- // An empty size in the configure means it's up to the client to choose the size
- bool normalPending = !(m_pending.states & (Qt::WindowMaximized|Qt::WindowFullScreen));
- if (normalPending && !m_normalSize.isEmpty()) {
- QSize size = m_normalSize;
+ // If the width or height is zero, the client should decide the size on its own.
+ QSize surfaceSize;
+
+ if (m_pending.size.width() > 0) {
+ surfaceSize.setWidth(m_pending.size.width());
+ } else {
+ if (Q_UNLIKELY(m_pending.states & (Qt::WindowMaximized | Qt::WindowFullScreen))) {
+ qCWarning(lcQpaWayland) << "Configure event with maximized or fullscreen state contains invalid width:" << m_pending.size.width();
+ } else {
+ int width = m_normalSize.width();
if (!m_pending.bounds.isEmpty())
- size = size.boundedTo(m_pending.bounds);
- m_xdgSurface->m_window->resizeFromApplyConfigure(size);
+ width = std::min(width, m_pending.bounds.width());
+ surfaceSize.setWidth(width);
}
+ }
+
+ if (m_pending.size.height() > 0) {
+ surfaceSize.setHeight(m_pending.size.height());
} else {
- m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+ if (Q_UNLIKELY(m_pending.states & (Qt::WindowMaximized | Qt::WindowFullScreen))) {
+ qCWarning(lcQpaWayland) << "Configure event with maximized or fullscreen state contains invalid height:" << m_pending.size.height();
+ } else {
+ int height = m_normalSize.height();
+ if (!m_pending.bounds.isEmpty())
+ height = std::min(height, m_pending.bounds.height());
+ surfaceSize.setHeight(height);
+ }
}
+ if (!surfaceSize.isEmpty())
+ m_xdgSurface->m_window->resizeFromApplyConfigure(surfaceSize);
+
m_applied = m_pending;
qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
}