From 61332caa2026f10a43bbd9879c0c577188e5eef2 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 10 Jun 2024 13:59:55 +0300 Subject: [PATCH] wayland: Fix one dimensional size constraints QSize::isEmpty() will return true if either dimension is 0. On the other hand, given the current language in the spec, it seems like the client is allowed to set size constraints per dimension. BUG: 488260 --- src/wayland/xdgshell.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/wayland/xdgshell.cpp b/src/wayland/xdgshell.cpp index 5b11315cc0..2c5845fc67 100644 --- a/src/wayland/xdgshell.cpp +++ b/src/wayland/xdgshell.cpp @@ -347,8 +347,12 @@ void XdgToplevelInterfacePrivate::apply(XdgToplevelCommit *commit) const auto minSize = commit->minimumSize.value_or(minimumSize); const auto maxSize = commit->maximumSize.value_or(maximumSize); - if (!minSize.isEmpty() && !maxSize.isEmpty() && (minSize.width() > maxSize.width() || minSize.height() > maxSize.height())) { - wl_resource_post_error(resource()->handle, error_invalid_size, "minimum size can't be bigger than the maximum"); + if ((minSize.width() > 0) && (maxSize.width() > 0) && (minSize.width() > maxSize.width())) { + wl_resource_post_error(resource()->handle, error_invalid_size, "minimum width can't be bigger than the maximum width"); + return; + } + if ((minSize.height() > 0) && (maxSize.height() > 0) && (minSize.height() > maxSize.height())) { + wl_resource_post_error(resource()->handle, error_invalid_size, "minimum height can't be bigger than the maximum height"); return; } @@ -575,12 +579,14 @@ QString XdgToplevelInterface::windowClass() const QSize XdgToplevelInterface::minimumSize() const { - return d->minimumSize.isEmpty() ? QSize(0, 0) : d->minimumSize; + return QSize(d->minimumSize.width() > 0 ? d->minimumSize.width() : 0, + d->minimumSize.height() > 0 ? d->minimumSize.height() : 0); } QSize XdgToplevelInterface::maximumSize() const { - return d->maximumSize.isEmpty() ? QSize(INT_MAX, INT_MAX) : d->maximumSize; + return QSize(d->maximumSize.width() > 0 ? d->maximumSize.width() : INT_MAX, + d->maximumSize.height() > 0 ? d->maximumSize.height() : INT_MAX); } quint32 XdgToplevelInterface::sendConfigure(const QSize &size, const States &states)