summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPier Luigi Fiorini <pierluigi.fiorini@liri.io>2019-01-06 19:21:20 +0100
committerPier Luigi Fiorini <pierluigi.fiorini@liri.io>2019-01-15 08:12:07 +0000
commit5698f22afbd0e6be273f31cf8b934383e7b68cdb (patch)
treea5f5e162c6980e0f0954b2e58ff0933a35c03881
parent312c74a4aa7124b5125c2ca6165805c50e23e828 (diff)
Set size hints for xdg-shell and xdg-shell-v6
Send minimum and maximum size hints to compositors. [ChangeLog][QPA plugin] Implement minimum and maximum size in the xdg-shell and xdg-shell-v6 shell integrations. Change-Id: I631c3348c8333d7a246b21228a92c436f5adb5dc Reviewed-by: Johan Helsing <johan.helsing@qt.io>
-rw-r--r--src/client/qwaylandshellsurface_p.h2
-rw-r--r--src/client/qwaylandwindow.cpp11
-rw-r--r--src/client/qwaylandwindow_p.h4
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp30
-rw-r--r--src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h3
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp30
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h3
7 files changed, 82 insertions, 1 deletions
diff --git a/src/client/qwaylandshellsurface_p.h b/src/client/qwaylandshellsurface_p.h
index d33a98a1..804056e5 100644
--- a/src/client/qwaylandshellsurface_p.h
+++ b/src/client/qwaylandshellsurface_p.h
@@ -97,6 +97,8 @@ public:
virtual void requestWindowStates(Qt::WindowStates states) {Q_UNUSED(states);}
virtual bool wantsDecorations() const { return false; }
+ virtual void propagateSizeHints() {}
+
private:
QWaylandWindow *m_window = nullptr;
friend class QWaylandWindow;
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index 17576ece..e8ff081c 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -605,6 +605,11 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
wl_surface::commit();
}
+void QWaylandWindow::commit()
+{
+ wl_surface::commit();
+}
+
const wl_callback_listener QWaylandWindow::callbackListener = {
QWaylandWindow::frameCallback
};
@@ -1118,6 +1123,12 @@ void QWaylandWindow::addAttachOffset(const QPoint point)
mOffset += point;
}
+void QWaylandWindow::propagateSizeHints()
+{
+ if (mShellSurface)
+ mShellSurface->propagateSizeHints();
+}
+
bool QtWaylandClient::QWaylandWindow::startSystemMove(const QPoint &pos)
{
Q_UNUSED(pos);
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
index e5838d23..52cbc3e5 100644
--- a/src/client/qwaylandwindow_p.h
+++ b/src/client/qwaylandwindow_p.h
@@ -120,6 +120,8 @@ public:
void handleExpose(const QRegion &region);
void commit(QWaylandBuffer *buffer, const QRegion &damage);
+ void commit();
+
void waitForFrameSync();
QMargins frameMargins() const override;
@@ -186,7 +188,7 @@ public:
QWaylandShmBackingStore *backingStore() const { return mBackingStore; }
bool setKeyboardGrabEnabled(bool) override { return false; }
- void propagateSizeHints() override { }
+ void propagateSizeHints() override;
void addAttachOffset(const QPoint point);
bool startSystemMove(const QPoint &pos) override;
diff --git a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
index 01122769..6652c876 100644
--- a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
@@ -46,6 +46,8 @@
#include <QtWaylandClient/private/qwaylandscreen_p.h>
#include <QtWaylandClient/private/qwaylandabstractdecoration_p.h>
+#include <QtGui/private/qwindow_p.h>
+
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
@@ -94,6 +96,9 @@ void QWaylandXdgSurfaceV6::Toplevel::applyConfigure()
QSize windowGeometrySize = m_xdgSurface->m_window->window()->frameGeometry().size();
m_xdgSurface->set_window_geometry(0, 0, windowGeometrySize.width(), windowGeometrySize.height());
+
+ m_xdgSurface->setSizeHints();
+
m_applied = m_pending;
qCDebug(lcQpaWayland) << "Applied pending zxdg_toplevel_v6 configure event:" << m_applied.size << m_applied.states;
}
@@ -305,6 +310,31 @@ bool QWaylandXdgSurfaceV6::wantsDecorations() const
return m_toplevel && !(m_toplevel->m_pending.states & Qt::WindowFullScreen);
}
+void QWaylandXdgSurfaceV6::propagateSizeHints()
+{
+ setSizeHints();
+
+ if (m_toplevel && m_window)
+ m_window->commit();
+}
+
+void QWaylandXdgSurfaceV6::setSizeHints()
+{
+ if (m_toplevel && m_window) {
+ const int minWidth = qMax(0, m_window->windowMinimumSize().width());
+ const int minHeight = qMax(0, m_window->windowMinimumSize().height());
+ m_toplevel->set_min_size(minWidth, minHeight);
+
+ int maxWidth = qMax(0, m_window->windowMaximumSize().width());
+ if (maxWidth == QWINDOWSIZE_MAX)
+ maxWidth = 0;
+ int maxHeight = qMax(0, m_window->windowMaximumSize().height());
+ if (maxHeight == QWINDOWSIZE_MAX)
+ maxHeight = 0;
+ m_toplevel->set_max_size(maxWidth, maxHeight);
+ }
+}
+
void QWaylandXdgSurfaceV6::requestWindowStates(Qt::WindowStates states)
{
if (m_toplevel)
diff --git a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h
index e688f751..62c13157 100644
--- a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h
+++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h
@@ -88,6 +88,9 @@ public:
bool handlesActiveState() const { return m_toplevel; }
void applyConfigure() override;
bool wantsDecorations() const override;
+ void propagateSizeHints() override;
+
+ void setSizeHints();
protected:
void requestWindowStates(Qt::WindowStates states) override;
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
index cabba5b3..fc515ca1 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
@@ -46,6 +46,8 @@
#include <QtWaylandClient/private/qwaylandscreen_p.h>
#include <QtWaylandClient/private/qwaylandabstractdecoration_p.h>
+#include <QtGui/private/qwindow_p.h>
+
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
@@ -104,6 +106,9 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
QSize windowGeometrySize = m_xdgSurface->m_window->window()->frameGeometry().size();
m_xdgSurface->set_window_geometry(0, 0, windowGeometrySize.width(), windowGeometrySize.height());
+
+ m_xdgSurface->setSizeHints();
+
m_applied = m_pending;
qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
}
@@ -339,6 +344,31 @@ bool QWaylandXdgSurface::wantsDecorations() const
return m_toplevel && m_toplevel->wantsDecorations();
}
+void QWaylandXdgSurface::propagateSizeHints()
+{
+ setSizeHints();
+
+ if (m_toplevel && m_window)
+ m_window->commit();
+}
+
+void QWaylandXdgSurface::setSizeHints()
+{
+ if (m_toplevel && m_window) {
+ const int minWidth = qMax(0, m_window->windowMinimumSize().width());
+ const int minHeight = qMax(0, m_window->windowMinimumSize().height());
+ m_toplevel->set_min_size(minWidth, minHeight);
+
+ int maxWidth = qMax(0, m_window->windowMaximumSize().width());
+ if (maxWidth == QWINDOWSIZE_MAX)
+ maxWidth = 0;
+ int maxHeight = qMax(0, m_window->windowMaximumSize().height());
+ if (maxHeight == QWINDOWSIZE_MAX)
+ maxHeight = 0;
+ m_toplevel->set_max_size(maxWidth, maxHeight);
+ }
+}
+
void QWaylandXdgSurface::requestWindowStates(Qt::WindowStates states)
{
if (m_toplevel)
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
index 416feee2..c39ccde3 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
@@ -92,6 +92,9 @@ public:
bool handlesActiveState() const { return m_toplevel; }
void applyConfigure() override;
bool wantsDecorations() const override;
+ void propagateSizeHints() override;
+
+ void setSizeHints();
protected:
void requestWindowStates(Qt::WindowStates states) override;