summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Edmundson <davidedmundson@kde.org>2020-08-12 14:42:41 +0100
committerDavid Edmundson <davidedmundson@kde.org>2020-08-26 16:43:35 +0100
commit26bcfde0aa102205f70f3f4959bfbe9166f93885 (patch)
tree510b792515397e651736a0d8264d1edb5e45be62
parent8f27bf64fe0a944bccd7bb5a920abc12a112762f (diff)
Client: Expose XdgShell native resources
Many new specifications now rely on passing xdg_surface/xdg_toplevel as arguments to other protocols. wl_shell is currently exposed through native resources but xdg-shell related classes were not. Fixes: QTBUG-81479 Change-Id: I2023f39ad6813ff58e8a86d739f307d791794b16 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp12
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h2
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp10
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h1
-rw-r--r--tests/auto/client/xdgshell/tst_xdgshell.cpp19
5 files changed, 44 insertions, 0 deletions
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
index b6d23ac10..43360ede3 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
@@ -378,6 +378,18 @@ void QWaylandXdgSurface::setSizeHints()
}
}
+void *QWaylandXdgSurface::nativeResource(const QByteArray &resource)
+{
+ QByteArray lowerCaseResource = resource.toLower();
+ if (lowerCaseResource == "xdg_surface")
+ return object();
+ else if (lowerCaseResource == "xdg_toplevel" && m_toplevel)
+ return m_toplevel->object();
+ else if (lowerCaseResource == "xdg_popup" && m_popup)
+ return m_popup->object();
+ return nullptr;
+}
+
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 0c98be35c..5aeec2eb9 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
@@ -97,6 +97,8 @@ public:
void setSizeHints();
+ void *nativeResource(const QByteArray &resource);
+
protected:
void requestWindowStates(Qt::WindowStates states) override;
void xdg_surface_configure(uint32_t serial) override;
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
index 8769d9716..b259a3010 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
@@ -83,6 +83,16 @@ void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *new
}
}
+void *QWaylandXdgShellIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
+{
+ if (auto waylandWindow = static_cast<QWaylandWindow *>(window->handle())) {
+ if (auto xdgSurface = qobject_cast<QWaylandXdgSurface *>(waylandWindow->shellSurface())) {
+ return xdgSurface->nativeResource(resource);
+ }
+ }
+ return nullptr;
+}
+
}
QT_END_NAMESPACE
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
index b6caa6c95..ceca0335d 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
@@ -66,6 +66,7 @@ public:
bool initialize(QWaylandDisplay *display) override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) override;
private:
QScopedPointer<QWaylandXdgShell> m_xdgShell;
diff --git a/tests/auto/client/xdgshell/tst_xdgshell.cpp b/tests/auto/client/xdgshell/tst_xdgshell.cpp
index 3007fb326..891bc0b28 100644
--- a/tests/auto/client/xdgshell/tst_xdgshell.cpp
+++ b/tests/auto/client/xdgshell/tst_xdgshell.cpp
@@ -51,6 +51,7 @@ private slots:
void minMaxSize();
void windowGeometry();
void foreignSurface();
+ void nativeResources();
};
void tst_xdgshell::showMinimized()
@@ -563,5 +564,23 @@ void tst_xdgshell::foreignSurface()
wl_surface_destroy(foreignSurface);
}
+void tst_xdgshell::nativeResources()
+{
+ QRasterWindow window;
+ window.resize(400, 320);
+ window.show();
+ QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+
+ auto *ni = QGuiApplication::platformNativeInterface();
+ auto *xdg_surface_proxy = static_cast<::wl_proxy *>(ni->nativeResourceForWindow("xdg_surface", &window));
+ QCOMPARE(wl_proxy_get_class(xdg_surface_proxy), "xdg_surface");
+
+ auto *xdg_toplevel_proxy = static_cast<::wl_proxy *>(ni->nativeResourceForWindow("xdg_toplevel", &window));
+ QCOMPARE(wl_proxy_get_class(xdg_toplevel_proxy), "xdg_toplevel");
+
+ auto *xdg_popup_proxy = static_cast<::wl_proxy *>(ni->nativeResourceForWindow("xdg_popup", &window));
+ QCOMPARE(xdg_popup_proxy, nullptr);
+}
+
QCOMPOSITOR_TEST_MAIN(tst_xdgshell)
#include "tst_xdgshell.moc"