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>
This commit is contained in:
parent
e1f73494ca
commit
af89d09f92
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user