Simple wayland pointer support.

This commit is contained in:
James Grogan 2022-11-10 14:59:59 +00:00
parent 63a93ec1a8
commit e2cc98e1fb
9 changed files with 291 additions and 11 deletions

View file

@ -3,11 +3,12 @@
#include "FileLogger.h"
#include "WaylandSurface.h"
#include "WaylandBuffer.h"
#include "WaylandSeatInterface.h"
#include <cstring>
#include <sstream>
void WaylandWindowInterface::registryHandleGlobalCallback(void *data, struct wl_registry *registry,
void WaylandWindowInterface::registryHandleGlobalEvent(void *data, struct wl_registry *registry,
uint32_t name, const char *interface, uint32_t version)
{
auto thisClass = static_cast<WaylandWindowInterface*>(data);
@ -28,9 +29,14 @@ void WaylandWindowInterface::registryHandleGlobalCallback(void *data, struct wl_
{
thisClass->setXdgBase(static_cast<xdg_wm_base*>(wl_registry_bind(registry, name, &xdg_wm_base_interface, 1)));
}
else if (strcmp(interface, wl_seat_interface.name) == 0)
{
thisClass->setSeat(static_cast<wl_seat*>(wl_registry_bind(registry, name, &wl_seat_interface, 5)));
}
}
void WaylandWindowInterface::registryHandleGlobalRemoveCallback(void *data, struct wl_registry *registry, uint32_t name)
void WaylandWindowInterface::registryHandleGlobalRemoveEvent(void *data, struct wl_registry *registry, uint32_t name)
{
}
@ -39,8 +45,8 @@ void WaylandWindowInterface::registryHandleGlobalRemoveCallback(void *data, stru
WaylandWindowInterface::WaylandWindowInterface()
: mBuffer(std::make_shared<WaylandBuffer>())
{
mRegistryListener.global = registryHandleGlobalCallback;
mRegistryListener.global_remove = registryHandleGlobalRemoveCallback;
mRegistryListener.global = registryHandleGlobalEvent;
mRegistryListener.global_remove = registryHandleGlobalRemoveEvent;
}
WaylandWindowInterface::~WaylandWindowInterface()
@ -69,6 +75,11 @@ void WaylandWindowInterface::connect()
wl_display_roundtrip(mDisplay);
}
void WaylandWindowInterface::setSeat(wl_seat* seat)
{
mSeatInterface = std::make_unique<WaylandSeatInterface>(seat);
}
void WaylandWindowInterface::setXdgBase(xdg_wm_base* xdg_base)
{
mXdgBase = xdg_base;
@ -104,14 +115,12 @@ void WaylandWindowInterface::addWindow(mt::Window* window)
void WaylandWindowInterface::mapWindow(mt::Window* window)
{
if (mSurfaces.empty())
{
return;
}
mSurfaces[0]->initialize(mCompositor, mXdgBase, mBuffer);
}
void WaylandWindowInterface::disconnect()