Some window interface cleaning

This commit is contained in:
James Grogan 2022-11-11 10:35:41 +00:00
parent 1180e576fa
commit 02ebb9a54b
12 changed files with 169 additions and 141 deletions

View file

@ -1,4 +1,4 @@
#include "WaylandWindowInterface.h"
#include "WaylandInterface.h"
#include "FileLogger.h"
#include "WaylandSurface.h"
@ -9,10 +9,10 @@
#include <cstring>
#include <sstream>
void WaylandWindowInterface::registryHandleGlobalEvent(void *data, struct wl_registry *registry,
void WaylandInterface::registryHandleGlobalEvent(void *data, struct wl_registry *registry,
uint32_t name, const char *interface, uint32_t version)
{
auto thisClass = static_cast<WaylandWindowInterface*>(data);
auto thisClass = static_cast<WaylandInterface*>(data);
std::stringstream sstrm;
sstrm << "interface: " << interface << " version " << version << " name " << name;
@ -36,25 +36,26 @@ void WaylandWindowInterface::registryHandleGlobalEvent(void *data, struct wl_reg
}
}
void WaylandWindowInterface::registryHandleGlobalRemoveEvent(void *data, struct wl_registry *registry, uint32_t name)
void WaylandInterface::registryHandleGlobalRemoveEvent(void *data, struct wl_registry *registry, uint32_t name)
{
}
WaylandWindowInterface::WaylandWindowInterface()
: mBuffer(std::make_shared<WaylandBuffer>())
WaylandInterface::WaylandInterface(DesktopManager* desktopManager)
: mDesktopManager(desktopManager),
mBuffer(std::make_shared<WaylandBuffer>())
{
mRegistryListener.global = registryHandleGlobalEvent;
mRegistryListener.global_remove = registryHandleGlobalRemoveEvent;
}
WaylandWindowInterface::~WaylandWindowInterface()
WaylandInterface::~WaylandInterface()
{
}
void WaylandWindowInterface::initialize(DesktopManager* desktopManager)
void WaylandInterface::initialize()
{
mDisplay = wl_display_connect(nullptr);
@ -81,45 +82,45 @@ void WaylandWindowInterface::initialize(DesktopManager* desktopManager)
}
}
void WaylandWindowInterface::setSeat(wl_seat* seat)
void WaylandInterface::setSeat(wl_seat* seat)
{
mSeatInterface = std::make_unique<WaylandSeatInterface>(seat);
}
void WaylandWindowInterface::setXdgBase(xdg_wm_base* xdg_base)
void WaylandInterface::setXdgBase(xdg_wm_base* xdg_base)
{
mXdgBase = xdg_base;
auto xdg_ping_handler = [](void *data, struct xdg_wm_base *xdg_wm_base, uint32_t serial)
{
auto thisClass = static_cast<WaylandWindowInterface*>(data);
auto thisClass = static_cast<WaylandInterface*>(data);
thisClass->doXdgPong(serial);
};
mXdgBaseListener.ping = xdg_ping_handler;
xdg_wm_base_add_listener(mXdgBase, &mXdgBaseListener, this);
}
void WaylandWindowInterface::setCompositor(wl_compositor* compositor)
void WaylandInterface::setCompositor(wl_compositor* compositor)
{
mCompositor = compositor;
}
void WaylandWindowInterface::setSharedMemory(wl_shm* shared_memory)
void WaylandInterface::setSharedMemory(wl_shm* shared_memory)
{
mBuffer->setSharedMemory(shared_memory);
}
void WaylandWindowInterface::doXdgPong(uint32_t serial)
void WaylandInterface::doXdgPong(uint32_t serial)
{
xdg_wm_base_pong(mXdgBase, serial);
}
void WaylandWindowInterface::addWindow(mt::Window* window, DesktopManager* desktopManager)
void WaylandInterface::addWindow(mt::Window* window)
{
auto surface = std::make_unique<WaylandSurface>(window);
mSurfaces.push_back(std::move(surface));
}
void WaylandWindowInterface::showWindow(mt::Window* window)
void WaylandInterface::showWindow(mt::Window* window)
{
if (mSurfaces.empty())
{
@ -129,7 +130,7 @@ void WaylandWindowInterface::showWindow(mt::Window* window)
mSurfaces[0]->initialize(mCompositor, mXdgBase, mBuffer, mEglInterface.get());
}
void WaylandWindowInterface::shutDown()
void WaylandInterface::shutDown()
{
if (mDisplay)
{
@ -137,7 +138,7 @@ void WaylandWindowInterface::shutDown()
}
}
void WaylandWindowInterface::loop(DesktopManager* desktopManager)
void WaylandInterface::loop()
{
while (wl_display_dispatch(mDisplay) != -1)
{

View file

@ -14,22 +14,23 @@ class WaylandSurface;
class WaylandBuffer;
class WaylandSeatInterface;
class WaylandEglInterface;
class DesktopManager;
class WaylandWindowInterface : public AbstractUIInterface
class WaylandInterface : public AbstractUIInterface
{
public:
WaylandWindowInterface();
WaylandInterface(DesktopManager* desktopManager);
~WaylandWindowInterface();
~WaylandInterface();
void loop(DesktopManager* desktopManager) override;
void loop() override;
void addWindow(mt::Window* window, DesktopManager* desktopManager) override;
void addWindow(mt::Window* window) override;
void showWindow(mt::Window* window) override;
void initialize(DesktopManager* desktopManager) override;
void initialize() override;
void shutDown() override;
@ -47,6 +48,8 @@ private:
void setXdgBase(xdg_wm_base* xdg_base);
DesktopManager* mDesktopManager{nullptr};
wl_display* mDisplay{nullptr};
wl_compositor* mCompositor{nullptr};
wl_registry_listener mRegistryListener;