summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-08-15 16:49:54 +0200
committerPaul Olav Tvete <paul.tvete@qt.io>2018-08-17 15:22:18 +0000
commitc7e775aef78b655666916bba15196c89dbf0b43d (patch)
treed61cc2300274b7481ad4151cca990eb4d98f1008
parent192a8364a983ceff7a7d9f2a33161e1da738ed70 (diff)
Compositor xdg-shell: Respect min and max size
[ChangeLog][Compositor] xdg-shell minimum and maximum sizes are now respected when resizing. Change-Id: Iaf6a2bd283117e948fda6693530e08f68f755a17 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r--src/compositor/extensions/qwaylandxdgshell.cpp11
-rw-r--r--src/compositor/extensions/qwaylandxdgshell_p.h2
-rw-r--r--src/compositor/extensions/qwaylandxdgshellv6.cpp11
3 files changed, 17 insertions, 7 deletions
diff --git a/src/compositor/extensions/qwaylandxdgshell.cpp b/src/compositor/extensions/qwaylandxdgshell.cpp
index 205269a88..175caea62 100644
--- a/src/compositor/extensions/qwaylandxdgshell.cpp
+++ b/src/compositor/extensions/qwaylandxdgshell.cpp
@@ -935,9 +935,14 @@ QSize QWaylandXdgToplevel::sizeForResize(const QSizeF &size, const QPointF &delt
else if (edges & Qt::BottomEdge)
height += delta.y();
- //TODO: use minSize given by the client here instead
- QSizeF newSize(qMax(width, 1.0), qMax(height, 1.0));
- return newSize.toSize();
+ QSize newSize = QSize(width, height)
+ .expandedTo(minSize())
+ .expandedTo({1, 1}); // We don't want to send a size of (0,0) as that means that the client decides
+
+ if (maxSize().isValid())
+ newSize = newSize.boundedTo(maxSize());
+
+ return newSize;
}
/*!
diff --git a/src/compositor/extensions/qwaylandxdgshell_p.h b/src/compositor/extensions/qwaylandxdgshell_p.h
index 70def5f7a..e87bb17f0 100644
--- a/src/compositor/extensions/qwaylandxdgshell_p.h
+++ b/src/compositor/extensions/qwaylandxdgshell_p.h
@@ -177,7 +177,7 @@ public:
QString m_title;
QString m_appId;
QSize m_maxSize;
- QSize m_minSize;
+ QSize m_minSize = {0, 0};
QScopedPointer<QWaylandXdgToplevelDecorationV1> m_decoration;
static QWaylandSurfaceRole s_role;
diff --git a/src/compositor/extensions/qwaylandxdgshellv6.cpp b/src/compositor/extensions/qwaylandxdgshellv6.cpp
index 0772846fd..d447ac3c8 100644
--- a/src/compositor/extensions/qwaylandxdgshellv6.cpp
+++ b/src/compositor/extensions/qwaylandxdgshellv6.cpp
@@ -934,9 +934,14 @@ QSize QWaylandXdgToplevelV6::sizeForResize(const QSizeF &size, const QPointF &de
else if (edges & Qt::BottomEdge)
height += delta.y();
- //TODO: use minSize given by the client here instead
- QSizeF newSize(qMax(width, 1.0), qMax(height, 1.0));
- return newSize.toSize();
+ QSize newSize = QSize(width, height)
+ .expandedTo(minSize())
+ .expandedTo({1, 1}); // We don't want to send a size of (0,0) as that means that the client decides
+
+ if (maxSize().isValid())
+ newSize = newSize.boundedTo(maxSize());
+
+ return newSize;
}
/*!