[wayland] Honor xdg-toplevel size constraints

Summary:
This change ensures that we honor surface size constraints specified by
xdg-toplevel clients.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26830
This commit is contained in:
Vlad Zahorodnii 2020-02-12 12:43:30 +02:00
parent c3abe87f4c
commit 2b120e07ca
3 changed files with 26 additions and 0 deletions

View file

@ -3106,6 +3106,8 @@ QSize AbstractClient::adjustedSize() const
/**
* Constrains the client size @p size according to a set of the window's size hints.
*
* Default implementation applies only minimum and maximum size constraints.
*/
QSize AbstractClient::constrainClientSize(const QSize &size, SizeMode mode) const
{
@ -3123,6 +3125,12 @@ QSize AbstractClient::constrainClientSize(const QSize &size, SizeMode mode) cons
height = 1;
}
const QSize minimumSize = minSize();
const QSize maximumSize = maxSize();
width = qBound(minimumSize.width(), width, maximumSize.width());
height = qBound(minimumSize.height(), height, maximumSize.height());
return QSize(width, height);
}

View file

@ -345,6 +345,22 @@ QSize XdgShellClient::clientSize() const
return m_windowGeometry.size().boundedTo(boundingRect.size());
}
QSize XdgShellClient::minSize() const
{
if (m_xdgShellToplevel) {
return rules()->checkMinSize(m_xdgShellToplevel->minimumSize());
}
return QSize(0, 0);
}
QSize XdgShellClient::maxSize() const
{
if (m_xdgShellToplevel) {
return rules()->checkMaxSize(m_xdgShellToplevel->maximumSize());
}
return QSize(INT_MAX, INT_MAX);
}
void XdgShellClient::debug(QDebug &stream) const
{
stream.nospace();

View file

@ -63,6 +63,8 @@ public:
QStringList activities() const override;
QPoint clientContentPos() const override;
QSize clientSize() const override;
QSize minSize() const override;
QSize maxSize() const override;
QRect transparentRect() const override;
NET::WindowType windowType(bool direct = false, int supported_types = 0) const override;
void debug(QDebug &stream) const override;