1
0
mirror of https://github.com/danog/patches.git synced 2024-11-26 11:54:51 +01:00
patches/qtwayland_5_12_8/0005-set-size-hints.patch
2020-06-17 20:10:54 +04:00

203 lines
7.3 KiB
Diff

diff --git a/src/client/qwaylandshellsurface_p.h b/src/client/qwaylandshellsurface_p.h
index c4f5512b..873193ae 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 fed632b2..39cc5847 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -616,6 +616,11 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
wl_surface::commit();
}
+void QWaylandWindow::commit()
+{
+ wl_surface::commit();
+}
+
const wl_callback_listener QWaylandWindow::callbackListener = {
[](void *data, wl_callback *callback, uint32_t time) {
Q_UNUSED(callback);
@@ -1195,6 +1200,12 @@ void QWaylandWindow::addAttachOffset(const QPoint point)
mOffset += point;
}
+void QWaylandWindow::propagateSizeHints()
+{
+ if (mShellSurface)
+ mShellSurface->propagateSizeHints();
+}
+
bool QWaylandWindow::startSystemResize(Qt::Edges edges)
{
if (auto *seat = display()->lastInputDevice())
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
index 4242f3a8..a40b6c97 100644
--- a/src/client/qwaylandwindow_p.h
+++ b/src/client/qwaylandwindow_p.h
@@ -122,6 +122,8 @@ public:
void handleExpose(const QRegion &region);
void commit(QWaylandBuffer *buffer, const QRegion &damage);
+ void commit();
+
bool waitForFrameSync(int timeout);
QMargins frameMargins() const override;
@@ -188,7 +190,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 startSystemResize(Qt::Edges edges) override;
diff --git a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
index 4491b94b..ba3b5671 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;
}
@@ -298,6 +303,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 eb49119e..a93292ae 100644
--- a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h
+++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h
@@ -89,6 +89,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 c5ad57ab..5884f772 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;
}
@@ -332,6 +337,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 a791ce7f..23c3b135 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
@@ -93,6 +93,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;