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

@ -0,0 +1,48 @@
#include "WaylandSeatInterface.h"
#include "FileLogger.h"
void WaylandSeatInterface::seatCapabilitiesEvent(void *data, struct wl_seat *wl_seat, uint32_t capabilities)
{
auto thisClass = static_cast<WaylandSeatInterface*>(data);
thisClass->onSeatCapabilitiesEvent(capabilities);
}
void WaylandSeatInterface::onSeatCapabilitiesEvent(uint32_t capabilities)
{
const bool have_pointer = capabilities & WL_SEAT_CAPABILITY_POINTER;
if (have_pointer && mPointerInterface == nullptr)
{
auto pointer = wl_seat_get_pointer(mSeat);
mPointerInterface = std::make_unique<WaylandPointerInterface>(pointer);
}
else if (!have_pointer && mPointerInterface!= nullptr)
{
wl_pointer_release(mPointerInterface->getPointer());
mPointerInterface.release();
}
}
WaylandSeatInterface::WaylandSeatInterface(wl_seat* seat)
: mSeat(seat)
{
mSeatListener.capabilities = seatCapabilitiesEvent;
mSeatListener.name = seatNameEvent;
wl_seat_add_listener(mSeat, &mSeatListener, this);
}
void WaylandSeatInterface::seatNameEvent(void *data, struct wl_seat *wl_seat, const char *name)
{
MLOG_INFO("seat name: " << name);
}
void WaylandSeatInterface::setKeyboard(wl_keyboard* keyboard)
{
}
void WaylandSeatInterface::setPointer(wl_pointer* pointer)
{
}