Port wlshell integration to QWaylandShellIntegrationTemplate

Change-Id: Ib05a4645f930f41819447f6e1d562753a36e5710
Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
David Redondo 2023-02-23 10:39:01 +01:00
parent 621a2d94ae
commit 0badceeb6d
2 changed files with 6 additions and 21 deletions

View File

@ -11,31 +11,16 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient { namespace QtWaylandClient {
bool QWaylandWlShellIntegration::initialize(QWaylandDisplay *display) QWaylandWlShellIntegration::QWaylandWlShellIntegration() : QWaylandShellIntegrationTemplate(1)
{ {
const auto globals = display->globals();
for (QWaylandDisplay::RegistryGlobal global : globals) {
if (global.interface == QLatin1String("wl_shell")) {
m_wlShell = new QtWayland::wl_shell(display->wl_registry(), global.id, 1);
break;
}
}
if (!m_wlShell) {
qCDebug(lcQpaWayland) << "Couldn't find global wl_shell";
return false;
}
qCWarning(lcQpaWayland) << "\"wl-shell\" is a deprecated shell extension, prefer using" qCWarning(lcQpaWayland) << "\"wl-shell\" is a deprecated shell extension, prefer using"
<< "\"xdg-shell\" if supported by the compositor" << "\"xdg-shell\" if supported by the compositor"
<< "by setting the environment variable QT_WAYLAND_SHELL_INTEGRATION"; << "by setting the environment variable QT_WAYLAND_SHELL_INTEGRATION";
return true;
} }
QWaylandShellSurface *QWaylandWlShellIntegration::createShellSurface(QWaylandWindow *window) QWaylandShellSurface *QWaylandWlShellIntegration::createShellSurface(QWaylandWindow *window)
{ {
return new QWaylandWlShellSurface(m_wlShell->get_shell_surface(window->wlSurface()), window); return new QWaylandWlShellSurface(get_shell_surface(window->wlSurface()), window);
} }
void *QWaylandWlShellIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window) void *QWaylandWlShellIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window)

View File

@ -23,16 +23,16 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient { namespace QtWaylandClient {
class Q_WAYLANDCLIENT_EXPORT QWaylandWlShellIntegration : public QWaylandShellIntegration class Q_WAYLANDCLIENT_EXPORT QWaylandWlShellIntegration
: public QWaylandShellIntegrationTemplate<QWaylandWlShellIntegration>,
public QtWayland::wl_shell
{ {
public: public:
QWaylandWlShellIntegration() {} QWaylandWlShellIntegration();
bool initialize(QWaylandDisplay *) override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override; QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) override; void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) override;
private: private:
QtWayland::wl_shell *m_wlShell = nullptr;
}; };
} }