|
|
93bb3c |
From d533901938a996367d7b6f87b0214f5a17098aed Mon Sep 17 00:00:00 2001
|
|
|
93bb3c |
From: Jan Grulich <jgrulich@redhat.com>
|
|
|
93bb3c |
Date: Tue, 23 Mar 2021 16:03:22 +0100
|
|
|
93bb3c |
Subject: [PATCH] Client: expose toplevel window state
|
|
|
93bb3c |
|
|
|
93bb3c |
QWaylandWindow has only basic information about window state, like if
|
|
|
93bb3c |
it's active or maximized, but it has no information about tiling, which
|
|
|
93bb3c |
can be useful for client-side decorations. We also need to bump version
|
|
|
93bb3c |
of xdg-shell protocol we support, because additional states are not in
|
|
|
93bb3c |
the version currently supported by QtWayland. It shouldn't be a problem
|
|
|
93bb3c |
to increase the version as the new version adds just these additional
|
|
|
93bb3c |
window states.
|
|
|
93bb3c |
|
|
|
93bb3c |
Change-Id: I4c46516d9c7296c69ea51a022b3bdb4ca06bef8d
|
|
|
93bb3c |
Reviewed-by: David Edmundson <davidedmundson@kde.org>
|
|
|
93bb3c |
---
|
|
|
93bb3c |
src/client/qwaylandwindow.cpp | 15 +++++++++++++++
|
|
|
93bb3c |
src/client/qwaylandwindow_p.h | 16 ++++++++++++++++
|
|
|
93bb3c |
.../xdg-shell/qwaylandxdgshell.cpp | 16 +++++++++++++++-
|
|
|
93bb3c |
.../xdg-shell/qwaylandxdgshell_p.h | 3 ++-
|
|
|
93bb3c |
4 files changed, 48 insertions(+), 2 deletions(-)
|
|
|
93bb3c |
|
|
|
93bb3c |
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
|
|
|
93bb3c |
index ba881cb..a1e891d 100644
|
|
|
93bb3c |
--- a/src/client/qwaylandwindow.cpp
|
|
|
93bb3c |
+++ b/src/client/qwaylandwindow.cpp
|
|
|
93bb3c |
@@ -1089,6 +1089,16 @@ Qt::WindowStates QWaylandWindow::windowStates() const
|
|
|
93bb3c |
return mLastReportedWindowStates;
|
|
|
93bb3c |
}
|
|
|
93bb3c |
|
|
|
93bb3c |
+QWaylandWindow::ToplevelWindowTilingStates QWaylandWindow::toplevelWindowTilingStates() const
|
|
|
93bb3c |
+{
|
|
|
93bb3c |
+ return mLastReportedToplevelWindowTilingStates;
|
|
|
93bb3c |
+}
|
|
|
93bb3c |
+
|
|
|
93bb3c |
+void QWaylandWindow::handleToplevelWindowTilingStatesChanged(ToplevelWindowTilingStates states)
|
|
|
93bb3c |
+{
|
|
|
93bb3c |
+ mLastReportedToplevelWindowTilingStates = states;
|
|
|
93bb3c |
+}
|
|
|
93bb3c |
+
|
|
|
93bb3c |
void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
|
|
|
93bb3c |
{
|
|
|
93bb3c |
createDecoration();
|
|
|
93bb3c |
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
|
|
|
93bb3c |
index e068796..f4e5d3d 100644
|
|
|
93bb3c |
--- a/src/client/qwaylandwindow_p.h
|
|
|
93bb3c |
+++ b/src/client/qwaylandwindow_p.h
|
|
|
93bb3c |
@@ -95,6 +95,15 @@ public:
|
|
|
93bb3c |
Vulkan
|
|
|
93bb3c |
};
|
|
|
93bb3c |
|
|
|
93bb3c |
+ enum ToplevelWindowTilingState {
|
|
|
93bb3c |
+ WindowNoState = 0,
|
|
|
93bb3c |
+ WindowTiledLeft = 1,
|
|
|
93bb3c |
+ WindowTiledRight = 2,
|
|
|
93bb3c |
+ WindowTiledTop = 4,
|
|
|
93bb3c |
+ WindowTiledBottom = 8
|
|
|
93bb3c |
+ };
|
|
|
93bb3c |
+ Q_DECLARE_FLAGS(ToplevelWindowTilingStates, ToplevelWindowTilingState)
|
|
|
93bb3c |
+
|
|
|
93bb3c |
QWaylandWindow(QWindow *window, QWaylandDisplay *display);
|
|
|
93bb3c |
~QWaylandWindow() override;
|
|
|
93bb3c |
|
|
|
93bb3c |
@@ -145,6 +154,9 @@ public:
|
|
|
93bb3c |
void handleContentOrientationChange(Qt::ScreenOrientation orientation) override;
|
|
|
93bb3c |
void setOrientationMask(Qt::ScreenOrientations mask);
|
|
|
93bb3c |
|
|
|
93bb3c |
+ ToplevelWindowTilingStates toplevelWindowTilingStates() const;
|
|
|
93bb3c |
+ void handleToplevelWindowTilingStatesChanged(ToplevelWindowTilingStates states);
|
|
|
93bb3c |
+
|
|
|
93bb3c |
void setWindowState(Qt::WindowStates states) override;
|
|
|
93bb3c |
void setWindowFlags(Qt::WindowFlags flags) override;
|
|
|
93bb3c |
void handleWindowStatesChanged(Qt::WindowStates states);
|
|
|
93bb3c |
@@ -257,6 +269,7 @@ protected:
|
|
|
93bb3c |
QRegion mMask;
|
|
|
93bb3c |
QRegion mOpaqueArea;
|
|
|
93bb3c |
Qt::WindowStates mLastReportedWindowStates = Qt::WindowNoState;
|
|
|
93bb3c |
+ ToplevelWindowTilingStates mLastReportedToplevelWindowTilingStates = WindowNoState;
|
|
|
93bb3c |
|
|
|
93bb3c |
QWaylandShmBackingStore *mBackingStore = nullptr;
|
|
|
93bb3c |
QWaylandBuffer *mQueuedBuffer = nullptr;
|
|
|
93bb3c |
@@ -293,6 +306,8 @@ private:
|
|
|
93bb3c |
friend class QWaylandSubSurface;
|
|
|
93bb3c |
};
|
|
|
93bb3c |
|
|
|
93bb3c |
+Q_DECLARE_OPERATORS_FOR_FLAGS(QWaylandWindow::ToplevelWindowTilingStates)
|
|
|
93bb3c |
+
|
|
|
93bb3c |
inline QIcon QWaylandWindow::windowIcon() const
|
|
|
93bb3c |
{
|
|
|
93bb3c |
return mWindowIcon;
|
|
|
93bb3c |
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
|
|
|
93bb3c |
index d7d0ddf..2c6e84b 100644
|
|
|
93bb3c |
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
|
|
|
93bb3c |
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
|
|
|
93bb3c |
@@ -88,6 +88,7 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
|
|
|
93bb3c |
&& !m_xdgSurface->m_window->display()->isKeyboardAvailable())
|
|
|
93bb3c |
m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
|
|
|
93bb3c |
|
|
|
93bb3c |
+ m_xdgSurface->m_window->handleToplevelWindowTilingStatesChanged(m_toplevelStates);
|
|
|
93bb3c |
m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
|
|
|
93bb3c |
|
|
|
93bb3c |
if (m_pending.size.isEmpty()) {
|
|
|
93bb3c |
@@ -120,6 +121,7 @@ void QWaylandXdgSurface::Toplevel::xdg_toplevel_configure(int32_t width, int32_t
|
|
|
93bb3c |
size_t numStates = states->size / sizeof(uint32_t);
|
|
|
93bb3c |
|
|
|
93bb3c |
m_pending.states = Qt::WindowNoState;
|
|
|
93bb3c |
+ m_toplevelStates = QWaylandWindow::WindowNoState;
|
|
|
93bb3c |
|
|
|
93bb3c |
for (size_t i = 0; i < numStates; i++) {
|
|
|
93bb3c |
switch (xdgStates[i]) {
|
|
|
93bb3c |
@@ -132,6 +134,18 @@ void QWaylandXdgSurface::Toplevel::xdg_toplevel_configure(int32_t width, int32_t
|
|
|
93bb3c |
case XDG_TOPLEVEL_STATE_FULLSCREEN:
|
|
|
93bb3c |
m_pending.states |= Qt::WindowFullScreen;
|
|
|
93bb3c |
break;
|
|
|
93bb3c |
+ case XDG_TOPLEVEL_STATE_TILED_LEFT:
|
|
|
93bb3c |
+ m_toplevelStates |= QWaylandWindow::WindowTiledLeft;
|
|
|
93bb3c |
+ break;
|
|
|
93bb3c |
+ case XDG_TOPLEVEL_STATE_TILED_RIGHT:
|
|
|
93bb3c |
+ m_toplevelStates |= QWaylandWindow::WindowTiledRight;
|
|
|
93bb3c |
+ break;
|
|
|
93bb3c |
+ case XDG_TOPLEVEL_STATE_TILED_TOP:
|
|
|
93bb3c |
+ m_toplevelStates |= QWaylandWindow::WindowTiledTop;
|
|
|
93bb3c |
+ break;
|
|
|
93bb3c |
+ case XDG_TOPLEVEL_STATE_TILED_BOTTOM:
|
|
|
93bb3c |
+ m_toplevelStates |= QWaylandWindow::WindowTiledBottom;
|
|
|
93bb3c |
+ break;
|
|
|
93bb3c |
default:
|
|
|
93bb3c |
break;
|
|
|
93bb3c |
}
|
|
|
93bb3c |
@@ -451,7 +465,7 @@ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
|
|
|
93bb3c |
}
|
|
|
93bb3c |
|
|
|
93bb3c |
QWaylandXdgShell::QWaylandXdgShell(QWaylandDisplay *display, uint32_t id, uint32_t availableVersion)
|
|
|
93bb3c |
- : QtWayland::xdg_wm_base(display->wl_registry(), id, qMin(availableVersion, 1u))
|
|
|
93bb3c |
+ : QtWayland::xdg_wm_base(display->wl_registry(), id, qMin(availableVersion, 2u))
|
|
|
93bb3c |
, m_display(display)
|
|
|
93bb3c |
{
|
|
|
93bb3c |
display->addRegistryListener(&QWaylandXdgShell::handleRegistryGlobal, this);
|
|
|
93bb3c |
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
|
|
|
93bb3c |
index 0c98be3..d791213 100644
|
|
|
93bb3c |
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
|
|
|
93bb3c |
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
|
|
|
93bb3c |
@@ -58,6 +58,7 @@
|
|
|
93bb3c |
|
|
|
93bb3c |
#include <QtWaylandClient/qtwaylandclientglobal.h>
|
|
|
93bb3c |
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
|
|
|
93bb3c |
+#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
|
|
93bb3c |
|
|
|
93bb3c |
#include <QtCore/QSize>
|
|
|
93bb3c |
#include <QtGui/QRegion>
|
|
|
93bb3c |
@@ -69,7 +70,6 @@ class QWindow;
|
|
|
93bb3c |
namespace QtWaylandClient {
|
|
|
93bb3c |
|
|
|
93bb3c |
class QWaylandDisplay;
|
|
|
93bb3c |
-class QWaylandWindow;
|
|
|
93bb3c |
class QWaylandInputDevice;
|
|
|
93bb3c |
class QWaylandXdgShell;
|
|
|
93bb3c |
|
|
|
93bb3c |
@@ -123,6 +123,7 @@ private:
|
|
|
93bb3c |
QSize size = {0, 0};
|
|
|
93bb3c |
Qt::WindowStates states = Qt::WindowNoState;
|
|
|
93bb3c |
} m_pending, m_applied;
|
|
|
93bb3c |
+ QWaylandWindow::ToplevelWindowTilingStates m_toplevelStates = QWaylandWindow::WindowNoState;
|
|
|
93bb3c |
QSize m_normalSize;
|
|
|
93bb3c |
|
|
|
93bb3c |
QWaylandXdgSurface *m_xdgSurface = nullptr;
|