More cleaning

This commit is contained in:
James Grogan 2022-11-11 11:48:42 +00:00
parent 02ebb9a54b
commit 6adc441e6f
37 changed files with 213 additions and 181 deletions

View file

@ -2,12 +2,15 @@
#include <memory>
#include "AbstractApp.h"
class AbstractDesktopApp
{
public:
AbstractDesktopApp() = default;
virtual ~AbstractDesktopApp() = default;
virtual AbstractApp* getMainApplication() const = 0;
};
using AbstractDesktopAppPtr = std::shared_ptr<AbstractDesktopApp>;

View file

@ -1,12 +1,14 @@
#include "DesktopManager.h"
#include "AbstractDesktopApp.h"
#include "FileLogger.h"
DesktopManager::DesktopManager()
DesktopManager::DesktopManager(AbstractDesktopApp* application)
: mScreens(),
mWindowManager(WindowManager::Create()),
mKeyboard(Keyboard::Create()),
mMainApplication(),
mUiApplication(application),
mModified(false),
mEventManager(EventManager::Create())
{
@ -18,9 +20,9 @@ DesktopManager::~DesktopManager()
}
std::unique_ptr<DesktopManager> DesktopManager::Create()
std::unique_ptr<DesktopManager> DesktopManager::Create(AbstractDesktopApp* application)
{
return std::make_unique<DesktopManager>();
return std::make_unique<DesktopManager>(application);
}
void DesktopManager::ClearEvents()
@ -100,14 +102,9 @@ void DesktopManager::SetKeyboard(KeyboardUPtr keyboard)
mKeyboard = std::move(keyboard);
}
void DesktopManager::SetMainApp(std::shared_ptr<AbstractApp> mainApp)
AbstractApp* DesktopManager::getMainApp() const
{
mMainApplication = mainApp;
}
AbstractApp* DesktopManager::GetMainApp()
{
return mMainApplication.get();
return mUiApplication->getMainApplication();
}
void DesktopManager::AddScreen(ScreenPtr screen)

View file

@ -13,21 +13,21 @@
#include "AbstractApp.h"
#include "EventManager.h"
class AbstractDesktopApp;
class DesktopManager
{
public:
DesktopManager();
DesktopManager(AbstractDesktopApp* application);
~DesktopManager();
static std::unique_ptr<DesktopManager> Create();
static std::unique_ptr<DesktopManager> Create(AbstractDesktopApp* application);
void SetWindowManager(WindowManagerUPtr windowManager);
void SetMainApp(std::shared_ptr<AbstractApp> mainApp);
AbstractApp* GetMainApp();
AbstractApp* getMainApp() const;
WindowManager* GetWindowManager() const;
@ -58,7 +58,7 @@ private:
WindowManagerUPtr mWindowManager;
KeyboardUPtr mKeyboard;
EventManagerUPtr mEventManager;
std::shared_ptr<AbstractApp> mMainApplication;
AbstractDesktopApp* mUiApplication;
bool mModified;
};

View file

@ -5,9 +5,18 @@ namespace mt
class Window;
}
class DesktopManager;
class AbstractUIInterface
{
public:
AbstractUIInterface(DesktopManager* desktopManager, bool useHardware = false)
: mDesktopManager(desktopManager),
mUseHardwareRendering(useHardware)
{
}
virtual ~AbstractUIInterface() = default;
virtual void initialize() = 0;
@ -26,5 +35,6 @@ public:
}
protected:
DesktopManager* mDesktopManager{nullptr};
bool mUseHardwareRendering{false};
};

View file

@ -10,13 +10,15 @@
std::unique_ptr<AbstractUIInterface> UiInterfaceFactory::create(DesktopManager* desktopManager, Backend backend)
{
#ifdef __linux__
if (backend == Backend::UNSET || backend == Backend::X11)
if (backend == Backend::UNSET || backend == Backend::X11 || backend == Backend::X11_RASTER)
{
return std::make_unique<XcbInterface>(desktopManager);
const bool use_hardware = (backend != Backend::X11_RASTER);
return std::make_unique<XcbInterface>(desktopManager, use_hardware);
}
else
{
return std::make_unique<WaylandInterface>(desktopManager);
const bool use_hardware = (backend != Backend::WAYLAND_RASTER);
return std::make_unique<WaylandInterface>(desktopManager, use_hardware);
}
#else
return std::make_unique<Win32UiInterface>();

View file

@ -12,7 +12,9 @@ public:
enum class Backend
{
UNSET,
X11_RASTER,
X11,
WAYLAND_RASTER,
WAYLAND
};

View file

@ -41,9 +41,8 @@ void WaylandInterface::registryHandleGlobalRemoveEvent(void *data, struct wl_reg
}
WaylandInterface::WaylandInterface(DesktopManager* desktopManager)
: mDesktopManager(desktopManager),
WaylandInterface::WaylandInterface(DesktopManager* desktopManager, bool useHardware)
: AbstractUIInterface(desktopManager, useHardware),
mBuffer(std::make_shared<WaylandBuffer>())
{
mRegistryListener.global = registryHandleGlobalEvent;

View file

@ -14,13 +14,12 @@ class WaylandSurface;
class WaylandBuffer;
class WaylandSeatInterface;
class WaylandEglInterface;
class DesktopManager;
class WaylandInterface : public AbstractUIInterface
{
public:
WaylandInterface(DesktopManager* desktopManager);
WaylandInterface(DesktopManager* desktopManager, bool useHardware = true);
~WaylandInterface();
@ -48,8 +47,6 @@ private:
void setXdgBase(xdg_wm_base* xdg_base);
DesktopManager* mDesktopManager{nullptr};
wl_display* mDisplay{nullptr};
wl_compositor* mCompositor{nullptr};
wl_registry_listener mRegistryListener;

View file

@ -20,8 +20,8 @@
#include "FileLogger.h"
XcbInterface::XcbInterface(DesktopManager* desktopManager)
: mDesktopManager(desktopManager),
XcbInterface::XcbInterface(DesktopManager* desktopManager, bool useHardware)
: AbstractUIInterface(desktopManager, useHardware),
mConnection(nullptr),
mX11Display(),
mGlxInterface(),

View file

@ -4,7 +4,6 @@
#include <memory>
class DesktopManager;
class GlxInterface;
using GlxInterfacePtr = std::unique_ptr<GlxInterface>;
@ -26,7 +25,7 @@ namespace mt
class XcbInterface : public AbstractUIInterface
{
public:
XcbInterface(DesktopManager* desktopManager);
XcbInterface(DesktopManager* desktopManager, bool useHardware = true);
~XcbInterface();
@ -57,7 +56,6 @@ private:
uint32_t getEventMask();
private:
DesktopManager* mDesktopManager{nullptr};
xcb_connection_t* mConnection;
_XDisplay* mX11Display;
GlxInterfacePtr mGlxInterface;