Port to QtWaylandClient's shell surface api

This commit is contained in:
Vlad Zahorodnii 2021-11-13 12:27:06 +02:00
parent 3214fb588f
commit 826c3e3ce0
2 changed files with 22 additions and 21 deletions

View File

@ -22,26 +22,30 @@ QWaylandLayerShellIntegration::~QWaylandLayerShellIntegration()
{ {
} }
bool QWaylandLayerShellIntegration::initialize(QtWaylandClient::QWaylandDisplay *display) bool QWaylandLayerShellIntegration::initialize()
{ {
QWaylandShellIntegration::initialize(display); if (m_layerShell) {
display->addRegistryListener(registryLayer, this); return true;
return m_layerShell != nullptr; }
wl_registry *registry;
uint32_t id;
uint32_t version;
const bool found = findGlobal(QLatin1String("zwlr_layer_shell_v1"), &registry, &id, &version);
if (!found) {
qWarning() << "Could not find the zwlr_layer_shell_v1 global. Compositor does not support the layer shell protocol?";
return false;
}
m_layerShell.reset(new QWaylandLayerShell(registry, id, std::min(version, 4u)));
return true;
} }
QtWaylandClient::QWaylandShellSurface *QWaylandLayerShellIntegration::createShellSurface(QtWaylandClient::QWaylandWindow *window) QtWaylandClient::QWaylandShellSurface *QWaylandLayerShellIntegration::createShellSurface(QtWaylandClient::QWaylandWindow *window)
{ {
if (m_layerShell) {
return m_layerShell->createLayerSurface(window); return m_layerShell->createLayerSurface(window);
} }
return nullptr;
void QWaylandLayerShellIntegration::registryLayer(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version)
{
QWaylandLayerShellIntegration *shell = static_cast<QWaylandLayerShellIntegration *>(data);
if (interface == zwlr_layer_shell_v1_interface.name)
shell->m_layerShell.reset(new QWaylandLayerShell(registry, id, std::min(version, 4u)));
} }
} }
//#include "qwaylandlayershellintegration.moc"

View File

@ -8,10 +8,9 @@
#ifndef _LAYERSHELLINTEGRATION_P_H #ifndef _LAYERSHELLINTEGRATION_P_H
#define _LAYERSHELLINTEGRATION_P_H #define _LAYERSHELLINTEGRATION_P_H
#include <wayland-client.h>
#include "layershellqt_export.h" #include "layershellqt_export.h"
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
#include <QtWaylandClient/private/qwaylandclientshellapi_p.h>
namespace LayerShellQt namespace LayerShellQt
{ {
@ -23,12 +22,10 @@ public:
QWaylandLayerShellIntegration(); QWaylandLayerShellIntegration();
~QWaylandLayerShellIntegration() override; ~QWaylandLayerShellIntegration() override;
bool initialize(QtWaylandClient::QWaylandDisplay *display) override; bool initialize() override;
QtWaylandClient::QWaylandShellSurface *createShellSurface(QtWaylandClient::QWaylandWindow *window) override; QtWaylandClient::QWaylandShellSurface *createShellSurface(QtWaylandClient::QWaylandWindow *window) override;
private: private:
static void registryLayer(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version);
QScopedPointer<QWaylandLayerShell> m_layerShell; QScopedPointer<QWaylandLayerShell> m_layerShell;
}; };