summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Redondo <qt@david-redondo.de>2022-10-12 09:01:07 +0200
committerDavid Redondo <qt@david-redondo.de>2022-12-08 10:31:45 +0100
commitf8c8a06f08583a48e953fc989241b94325760618 (patch)
tree27e2378318bfc8abcb81bef75a3dbbc39aff320c
parent23d3fc712cdf7fc0a4ff837082de9ba773e8605c (diff)
client: Implement QNativeInterface::Private::QWaylandWindow
Task-number: QTBUG-94729 Change-Id: Ib79f3199a4518700aa032c5ca4760a2b53c401e5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Edmundson <davidedmundson@kde.org>
-rw-r--r--src/client/qwaylandnativeinterface.cpp2
-rw-r--r--src/client/qwaylandshellsurface_p.h4
-rw-r--r--src/client/qwaylandvulkanwindow.cpp2
-rw-r--r--src/client/qwaylandvulkanwindow_p.h2
-rw-r--r--src/client/qwaylandwindow.cpp14
-rw-r--r--src/client/qwaylandwindow_p.h15
-rw-r--r--src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.h1
-rw-r--r--src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h2
-rw-r--r--src/plugins/shellintegration/qt-shell/qwaylandqtsurface_p.h2
-rw-r--r--src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h2
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp9
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h2
12 files changed, 50 insertions, 7 deletions
diff --git a/src/client/qwaylandnativeinterface.cpp b/src/client/qwaylandnativeinterface.cpp
index b76b1f08b..ea3da8b48 100644
--- a/src/client/qwaylandnativeinterface.cpp
+++ b/src/client/qwaylandnativeinterface.cpp
@@ -143,7 +143,7 @@ void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourc
if (lowerCaseResource == "vksurface") {
if (window->surfaceType() == QSurface::VulkanSurface && window->handle()) {
// return a pointer to the VkSurfaceKHR value, not the value itself
- return static_cast<QWaylandVulkanWindow *>(window->handle())->surface();
+ return static_cast<QWaylandVulkanWindow *>(window->handle())->vkSurface();
}
}
#endif
diff --git a/src/client/qwaylandshellsurface_p.h b/src/client/qwaylandshellsurface_p.h
index 8f176e281..51116c52a 100644
--- a/src/client/qwaylandshellsurface_p.h
+++ b/src/client/qwaylandshellsurface_p.h
@@ -21,6 +21,8 @@
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <QtCore/private/qglobal_p.h>
+#include <any>
+
struct wl_surface;
QT_BEGIN_NAMESPACE
@@ -80,6 +82,8 @@ public:
QPlatformWindow *platformWindow();
struct wl_surface *wlSurface();
+ virtual std::any surfaceRole() const { return std::any(); };
+
protected:
void resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset = {0, 0});
void repositionFromApplyConfigure(const QPoint &position);
diff --git a/src/client/qwaylandvulkanwindow.cpp b/src/client/qwaylandvulkanwindow.cpp
index 228bf5ced..db25a2715 100644
--- a/src/client/qwaylandvulkanwindow.cpp
+++ b/src/client/qwaylandvulkanwindow.cpp
@@ -26,7 +26,7 @@ QWaylandWindow::WindowType QWaylandVulkanWindow::windowType() const
return QWaylandWindow::Vulkan;
}
-VkSurfaceKHR *QWaylandVulkanWindow::surface()
+VkSurfaceKHR *QWaylandVulkanWindow::vkSurface()
{
if (m_surface)
return &m_surface;
diff --git a/src/client/qwaylandvulkanwindow_p.h b/src/client/qwaylandvulkanwindow_p.h
index d71fb277c..df24e5dbd 100644
--- a/src/client/qwaylandvulkanwindow_p.h
+++ b/src/client/qwaylandvulkanwindow_p.h
@@ -30,7 +30,7 @@ public:
WindowType windowType() const override;
- VkSurfaceKHR *surface();
+ VkSurfaceKHR *vkSurface();
private:
VkSurfaceKHR m_surface = VK_NULL_HANDLE;
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index 56b9af282..4e254dee9 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -59,6 +59,11 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
static WId id = 1;
mWindowId = id++;
initializeWlSurface();
+
+ connect(this, &QWaylandWindow::wlSurfaceCreated, this,
+ &QNativeInterface::Private::QWaylandWindow::surfaceCreated);
+ connect(this, &QWaylandWindow::wlSurfaceDestroyed, this,
+ &QNativeInterface::Private::QWaylandWindow::surfaceDestroyed);
}
QWaylandWindow::~QWaylandWindow()
@@ -847,6 +852,15 @@ QWaylandShellSurface *QWaylandWindow::shellSurface() const
return mShellSurface;
}
+std::any QWaylandWindow::_surfaceRole() const
+{
+ if (mSubSurfaceWindow)
+ return mSubSurfaceWindow->object();
+ if (mShellSurface)
+ return mShellSurface->surfaceRole();
+ return {};
+}
+
QWaylandSubSurface *QWaylandWindow::subSurfaceWindow() const
{
return mSubSurfaceWindow;
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
index 6531606a7..2eb6b64ce 100644
--- a/src/client/qwaylandwindow_p.h
+++ b/src/client/qwaylandwindow_p.h
@@ -28,10 +28,12 @@
#include <QtCore/QMap> // for QVariantMap
#include <qpa/qplatformwindow.h>
+#include <qpa/qplatformwindow_p.h>
#include <QtWaylandClient/private/qwayland-wayland.h>
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
#include <QtWaylandClient/qtwaylandclientglobal.h>
+#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
struct wl_egl_window;
@@ -56,7 +58,8 @@ class QWaylandSurface;
class QWaylandFractionalScale;
class QWaylandViewport;
-class Q_WAYLANDCLIENT_EXPORT QWaylandWindow : public QObject, public QPlatformWindow
+class Q_WAYLANDCLIENT_EXPORT QWaylandWindow : public QNativeInterface::Private::QWaylandWindow,
+ public QPlatformWindow
{
Q_OBJECT
public:
@@ -115,17 +118,22 @@ public:
QMargins frameMargins() const override;
QMargins customMargins() const;
- void setCustomMargins(const QMargins &margins);
+ void setCustomMargins(const QMargins &margins) override;
QSize surfaceSize() const;
QRect windowContentGeometry() const;
QPointF mapFromWlSurface(const QPointF &surfacePosition) const;
QWaylandSurface *waylandSurface() const { return mSurface.data(); }
::wl_surface *wlSurface();
+ ::wl_surface *surface() const override
+ {
+ return const_cast<QWaylandWindow *>(this)->wlSurface();
+ }
static QWaylandWindow *fromWlSurface(::wl_surface *surface);
QWaylandDisplay *display() const { return mDisplay; }
QWaylandShellSurface *shellSurface() const;
+ std::any _surfaceRole() const override;
QWaylandSubSurface *subSurfaceWindow() const;
QWaylandScreen *waylandScreen() const;
@@ -207,7 +215,7 @@ public:
void deliverUpdateRequest() override;
void setXdgActivationToken(const QString &token);
- void requestXdgActivationToken(uint serial);
+ void requestXdgActivationToken(uint serial) override;
void beginFrame();
void endFrame();
@@ -222,7 +230,6 @@ public slots:
signals:
void wlSurfaceCreated();
void wlSurfaceDestroyed();
- void xdgActivationTokenCreated(const QString &token);
protected:
virtual void doHandleFrameCallback();
diff --git a/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.h b/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.h
index 8affdfd66..0a82e5eee 100644
--- a/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.h
+++ b/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.h
@@ -18,6 +18,7 @@ class Q_WAYLANDCLIENT_EXPORT QWaylandFullScreenShellV1Surface : public QWaylandS
{
public:
QWaylandFullScreenShellV1Surface(QtWayland::zwp_fullscreen_shell_v1 *shell, QWaylandWindow *window);
+ std::any surfaceRole() const override { return m_shell->object(); }
private:
QtWayland::zwp_fullscreen_shell_v1 *m_shell = nullptr;
diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h b/src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h
index 7e6811fd6..853897cd8 100644
--- a/src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h
+++ b/src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h
@@ -28,6 +28,8 @@ public:
void applyConfigure() override;
+ std::any surfaceRole() const override { return ivi_surface::object(); };
+
private:
void createExtendedSurface(QWaylandWindow *window);
void ivi_surface_configure(int32_t width, int32_t height) override;
diff --git a/src/plugins/shellintegration/qt-shell/qwaylandqtsurface_p.h b/src/plugins/shellintegration/qt-shell/qwaylandqtsurface_p.h
index 2f95dd71f..53c37f79d 100644
--- a/src/plugins/shellintegration/qt-shell/qwaylandqtsurface_p.h
+++ b/src/plugins/shellintegration/qt-shell/qwaylandqtsurface_p.h
@@ -42,6 +42,8 @@ public:
void raise() override;
void lower() override;
+ std::any surfaceRole() const override { return object(); };
+
private:
void resetConfiguration();
void sendSizeHints();
diff --git a/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h b/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h
index d3996f43b..246003028 100644
--- a/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h
+++ b/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h
@@ -57,6 +57,8 @@ public:
void applyConfigure() override;
bool wantsDecorations() const override;
+ std::any surfaceRole() const override { return object(); };
+
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 9bd5209f0..c1462e07d 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
@@ -417,6 +417,15 @@ void *QWaylandXdgSurface::nativeResource(const QByteArray &resource)
return nullptr;
}
+std::any QWaylandXdgSurface::surfaceRole() const
+{
+ if (m_toplevel)
+ return m_toplevel->object();
+ if (m_popup)
+ return m_popup->object();
+ return {};
+}
+
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 abfd0db3b..588602697 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
@@ -72,6 +72,8 @@ public:
void *nativeResource(const QByteArray &resource);
+ std::any surfaceRole() const override;
+
protected:
void requestWindowStates(Qt::WindowStates states) override;
void xdg_surface_configure(uint32_t serial) override;