Fix up minimal dependency case and clang support.

This commit is contained in:
James Grogan 2022-11-30 15:28:15 +00:00
parent 925f0c3ccd
commit 1adc9272f8
17 changed files with 183 additions and 226 deletions

View file

@ -4,7 +4,7 @@ set (platform_INCLUDES "")
set (platform_LIBS "")
if(UNIX)
message(STATUS "Checking optional dependencies for module: window")
message(STATUS "Checking dependencies for module: window")
find_package(X11 QUIET)
if(X11_FOUND)
list(APPEND platform_INCLUDES
@ -20,9 +20,10 @@ if(UNIX)
ui_interfaces/x11/XcbGlWindowInterface.cpp
)
list(APPEND platform_LIBS ${X11_LIBRARIES} ${X11_xcb_LIB} ${X11_X11_xcb_LIB} ${X11_xkbcommon_LIB} ${X11_xkbcommon_X11_LIB} libxcb-image.so)
list(APPEND X11_INCLUDE_DIRS ${X11_xkbcommon_INCLUDE_PATH})
list(APPEND X11_INCLUDE_DIRS ${X11_xkbcommon_INCLUDE_PATH})
list(APPEND DEFINES "HAS_X11")
else()
message(STATUS "x11 development headers not found - skipping support")
message(STATUS "X11 not found - skipping support")
endif()
find_package(Wayland QUIET)
@ -47,7 +48,7 @@ if(UNIX)
list(APPEND platform_LIBS ${WAYLAND_LIBRARIES})
endif()
else()
Message(STATUS "Wayland dependencies not found - disabling Wayland support")
Message(STATUS "Wayland not found - skipping support")
endif()
else()
list(APPEND platform_INCLUDES

View file

@ -0,0 +1,27 @@
#pragma once
#include "AbstractUiInterface.h"
#include "DesktopManager.h"
#include "FontsManager.h"
class NullUIInterface : public AbstractUIInterface
{
public:
NullUIInterface(DesktopManager* desktopManager, std::unique_ptr<FontsManager> fontsManager, bool useHardware = false)
: AbstractUIInterface(desktopManager, std::move(fontsManager), useHardware)
{
};
virtual ~NullUIInterface() = default;
void loop() override{};
void showWindow(mt::Window* window) override{};
void addWindow(mt::Window* window) override{};
protected:
void initialize() override{};
void shutDown() override{};
};

View file

@ -1,7 +1,9 @@
#include "UiInterfaceFactory.h"
#ifdef __linux__
#ifdef HAS_X11
#include "XcbInterface.h"
#endif
#ifdef HAS_WAYLAND
#include "WaylandInterface.h"
#endif
@ -9,6 +11,8 @@
#include "Win32UiInterface.h"
#endif
#include "NullUiInterface.h"
#include "FontsManager.h"
std::unique_ptr<AbstractUIInterface> UiInterfaceFactory::create(DesktopManager* desktopManager, Backend backend)
@ -18,18 +22,26 @@ std::unique_ptr<AbstractUIInterface> UiInterfaceFactory::create(DesktopManager*
#ifdef __linux__
if (backend == Backend::UNSET || backend == Backend::X11 || backend == Backend::X11_RASTER)
{
#ifdef HAS_X11
const bool use_hardware = (backend != Backend::X11_RASTER);
return std::make_unique<XcbInterface>(desktopManager, std::move(fonts_manager), use_hardware);
#else
return std::make_unique<NullUIInterface>(desktopManager, std::move(fonts_manager));
#endif
}
else
{
#ifdef HAS_WAYLAND
const bool use_hardware = (backend != Backend::WAYLAND_RASTER);
return std::make_unique<WaylandInterface>(desktopManager, std::move(fonts_manager), use_hardware);
#else
const bool use_hardware = (backend != Backend::X11_RASTER);
return std::make_unique<XcbInterface>(desktopManager, std::move(fonts_manager), use_hardware);
#endif
#ifdef HAS_WAYLAND
const bool use_hardware = (backend != Backend::WAYLAND_RASTER);
return std::make_unique<WaylandInterface>(desktopManager, std::move(fonts_manager), use_hardware);
#else
#ifdef HAS_X11
const bool use_hardware = (backend != Backend::X11_RASTER);
return std::make_unique<XcbInterface>(desktopManager, std::move(fonts_manager), use_hardware);
#else
return std::make_unique<NullUIInterface>(desktopManager, std::move(fonts_manager));
#endif
#endif
}
#else
return std::make_unique<Win32UiInterface>();