More cleaning
This commit is contained in:
parent
02ebb9a54b
commit
6adc441e6f
37 changed files with 213 additions and 181 deletions
|
@ -9,7 +9,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
// Start the main app
|
||||
auto main_app = MainApplication::Create();
|
||||
main_app->Initialize(std::move(command_line_args));
|
||||
main_app->initialize(std::move(command_line_args));
|
||||
|
||||
main_app->Run();
|
||||
|
||||
|
|
|
@ -1,27 +1,42 @@
|
|||
list(APPEND client_HEADERS
|
||||
MediaTool.h
|
||||
text_editor/TextEditorView.h
|
||||
text_editor/TextEditorModel.h
|
||||
text_editor/TextEditorController.h
|
||||
text_editor/PlainTextDocument.h
|
||||
audio_editor/AudioEditorView.h
|
||||
image_editor/ImageEditorView.h
|
||||
web_client/WebClientView.h)
|
||||
|
||||
|
||||
list(APPEND client_LIB_INCLUDES
|
||||
text_editor/TextEditorView.cpp
|
||||
text_editor/TextEditorModel.cpp
|
||||
text_editor/TextEditorController.cpp
|
||||
text_editor/PlainTextDocument.cpp
|
||||
audio_editor/AudioEditorView.cpp
|
||||
image_editor/ImageEditorView.cpp
|
||||
web_client/WebClientView.cpp
|
||||
MediaTool.cpp)
|
||||
|
||||
if(WIN32)
|
||||
add_executable(sample_gui_win WIN32 gui-main-win.cpp)
|
||||
target_include_directories(sample_gui PUBLIC
|
||||
"${PROJECT_SOURCE_DIR}/src/console"
|
||||
"${PROJECT_SOURCE_DIR}/src/client"
|
||||
)
|
||||
target_link_libraries(sample_gui_win PUBLIC client windows console core
|
||||
network database geometry audio web)
|
||||
set_property(TARGET sample_gui_win PROPERTY FOLDER apps)
|
||||
add_executable(sample_gui WIN32 gui-main-win.cpp ${client_LIB_INCLUDES})
|
||||
else()
|
||||
find_package(X11 QUIET)
|
||||
if(X11_FOUND)
|
||||
add_executable(sample_gui gui-main.cpp)
|
||||
target_include_directories(sample_gui PUBLIC
|
||||
"${PROJECT_SOURCE_DIR}/src/console"
|
||||
"${PROJECT_SOURCE_DIR}/src/client"
|
||||
)
|
||||
target_link_libraries(sample_gui PUBLIC client windows console core
|
||||
network database geometry audio web)
|
||||
set_property(TARGET sample_gui PROPERTY FOLDER apps)
|
||||
add_executable(sample_gui gui-main.cpp ${client_LIB_INCLUDES} ${client_HEADERS})
|
||||
else()
|
||||
message(STATUS "Skipping sample GUI as no X11 dev support")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_include_directories(sample_gui PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/text_editor"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/audio_editor"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/image_editor"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/web_client"
|
||||
)
|
||||
target_link_libraries(sample_gui PUBLIC client windows console core network database geometry audio web)
|
||||
set_property(TARGET sample_gui PROPERTY FOLDER apps)
|
||||
|
||||
|
||||
|
|
54
apps/sample-gui/MediaTool.cpp
Normal file
54
apps/sample-gui/MediaTool.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
#include "MediaTool.h"
|
||||
|
||||
#include "TextEditorView.h"
|
||||
#include "AudioEditorView.h"
|
||||
#include "ImageEditorView.h"
|
||||
#include "WebClientView.h"
|
||||
#include "TabbedPanelWidget.h"
|
||||
#include "TopBar.h"
|
||||
#include "StatusBar.h"
|
||||
#include "HorizontalSpacer.h"
|
||||
|
||||
#include "DesktopManager.h"
|
||||
#include "MainApplication.h"
|
||||
|
||||
MediaTool::MediaTool(std::unique_ptr<CommandLineArgs> args)
|
||||
: GuiApplication(std::move(args))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MediaTool::initializeViews()
|
||||
{
|
||||
auto mainWindow = mDesktopManager->GetWindowManager()->GetMainWindow();
|
||||
mainWindow->SetSize(800, 600);
|
||||
|
||||
auto tabbedPanel = TabbedPanelWidget::Create();
|
||||
|
||||
auto textEditor = TextEditorView::Create();
|
||||
auto path = mMainApplication->GetCommandLineArgs()->getLaunchPath();
|
||||
path /= "out.txt";
|
||||
textEditor->GetController()->SetSavePath(path);
|
||||
textEditor->GetController()->SetLoadPath(path);
|
||||
textEditor->Initialize();
|
||||
tabbedPanel->AddPanel(std::move(textEditor), "Text Editor");
|
||||
|
||||
auto audioEditor = AudioEditorView::Create();
|
||||
tabbedPanel->AddPanel(std::move(audioEditor), "Audio Editor");
|
||||
|
||||
auto imageEditor = ImageEditorView::Create();
|
||||
tabbedPanel->AddPanel(std::move(imageEditor), "Image Editor");
|
||||
|
||||
auto webClient = WebClientView::Create();
|
||||
tabbedPanel->AddPanel(std::move(webClient), "Web Client");
|
||||
|
||||
auto topBar = TopBar::Create();
|
||||
auto statusBar = StatusBar::Create();
|
||||
|
||||
auto horizontalSpace = HorizontalSpacer::Create();
|
||||
horizontalSpace->AddWidgetWithScale(std::move(topBar), 1);
|
||||
horizontalSpace->AddWidgetWithScale(std::move(tabbedPanel), 20);
|
||||
horizontalSpace->AddWidgetWithScale(std::move(statusBar), 1);
|
||||
|
||||
mainWindow->AddWidget(std::move(horizontalSpace));
|
||||
}
|
12
apps/sample-gui/MediaTool.h
Normal file
12
apps/sample-gui/MediaTool.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include "GuiApplication.h"
|
||||
|
||||
class MediaTool : public GuiApplication
|
||||
{
|
||||
public:
|
||||
MediaTool(std::unique_ptr<CommandLineArgs> args);
|
||||
|
||||
protected:
|
||||
void initializeViews() override;
|
||||
};
|
|
@ -1,6 +1,6 @@
|
|||
#include <memory>
|
||||
|
||||
#include "GuiApplication.h"
|
||||
#include "MediaTool.h"
|
||||
#include "MainApplication.h"
|
||||
#include "CommandLineArgs.h"
|
||||
|
||||
|
@ -10,15 +10,9 @@ int main(int argc, char *argv[])
|
|||
args->process(argc, argv);
|
||||
args->recordLaunchPath();
|
||||
|
||||
// Start the main app
|
||||
auto main_app = MainApplication::Create();
|
||||
main_app->Initialize(std::move(args));
|
||||
|
||||
// Start the gui app
|
||||
auto gui_app = GuiApplication();
|
||||
gui_app.SetMainApplication(main_app);
|
||||
gui_app.Run();
|
||||
auto gui_app = GuiApplication(std::move(args));
|
||||
gui_app.run();
|
||||
|
||||
main_app->ShutDown();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -2,27 +2,13 @@ list(APPEND client_HEADERS
|
|||
TopBar.h
|
||||
StatusBar.h
|
||||
GuiApplication.h
|
||||
TabbedPanelWidget.h
|
||||
text_editor/TextEditorView.h
|
||||
text_editor/TextEditorModel.h
|
||||
text_editor/TextEditorController.h
|
||||
text_editor/PlainTextDocument.h
|
||||
audio_editor/AudioEditorView.h
|
||||
image_editor/ImageEditorView.h
|
||||
web_client/WebClientView.h)
|
||||
TabbedPanelWidget.h)
|
||||
|
||||
list(APPEND client_LIB_INCLUDES
|
||||
TopBar.cpp
|
||||
StatusBar.cpp
|
||||
GuiApplication.cpp
|
||||
TabbedPanelWidget.cpp
|
||||
text_editor/TextEditorView.cpp
|
||||
text_editor/TextEditorModel.cpp
|
||||
text_editor/TextEditorController.cpp
|
||||
text_editor/PlainTextDocument.cpp
|
||||
audio_editor/AudioEditorView.cpp
|
||||
image_editor/ImageEditorView.cpp
|
||||
web_client/WebClientView.cpp)
|
||||
TabbedPanelWidget.cpp)
|
||||
|
||||
add_library(client SHARED ${client_LIB_INCLUDES} ${client_HEADERS})
|
||||
|
||||
|
|
|
@ -1,26 +1,20 @@
|
|||
#include "GuiApplication.h"
|
||||
|
||||
#include "Widget.h"
|
||||
#include "UiInterfaceFactory.h"
|
||||
#include "Window.h"
|
||||
#include "TextElement.h"
|
||||
#include "WindowManager.h"
|
||||
#include "TextEditorView.h"
|
||||
#include "AudioEditorView.h"
|
||||
#include "ImageEditorView.h"
|
||||
#include "WebClientView.h"
|
||||
#include "TabbedPanelWidget.h"
|
||||
#include "TopBar.h"
|
||||
#include "StatusBar.h"
|
||||
#include "HorizontalSpacer.h"
|
||||
#include "DesktopManager.h"
|
||||
#include "MainApplication.h"
|
||||
#include "AbstractUiInterface.h"
|
||||
|
||||
#include "FileLogger.h"
|
||||
|
||||
GuiApplication::GuiApplication()
|
||||
GuiApplication::GuiApplication(std::unique_ptr<CommandLineArgs> args)
|
||||
: AbstractDesktopApp(),
|
||||
mMainApplication(),
|
||||
mDesktopManager(DesktopManager::Create())
|
||||
mMainApplication(MainApplication::Create()),
|
||||
mDesktopManager(DesktopManager::Create(this))
|
||||
{
|
||||
|
||||
mMainApplication->initialize(args ? std::move(args) : CommandLineArgs::Create());
|
||||
}
|
||||
|
||||
GuiApplication::~GuiApplication()
|
||||
|
@ -28,61 +22,37 @@ GuiApplication::~GuiApplication()
|
|||
|
||||
}
|
||||
|
||||
void GuiApplication::SetMainApplication(MainApplicationPtr app)
|
||||
AbstractApp* GuiApplication::getMainApplication() const
|
||||
{
|
||||
mMainApplication = app;
|
||||
mDesktopManager->SetMainApp(app);
|
||||
return mMainApplication.get();
|
||||
}
|
||||
|
||||
void GuiApplication::SetUpWidget()
|
||||
void GuiApplication::initializeViews()
|
||||
{
|
||||
auto mainWindow = mDesktopManager->GetWindowManager()->GetMainWindow();
|
||||
mainWindow->SetSize(800, 600);
|
||||
|
||||
auto tabbedPanel = TabbedPanelWidget::Create();
|
||||
|
||||
auto textEditor = TextEditorView::Create();
|
||||
auto path = mMainApplication->GetCommandLineArgs()->getLaunchPath();
|
||||
path /= "out.txt";
|
||||
textEditor->GetController()->SetSavePath(path);
|
||||
textEditor->GetController()->SetLoadPath(path);
|
||||
textEditor->Initialize();
|
||||
tabbedPanel->AddPanel(std::move(textEditor), "Text Editor");
|
||||
|
||||
auto audioEditor = AudioEditorView::Create();
|
||||
tabbedPanel->AddPanel(std::move(audioEditor), "Audio Editor");
|
||||
|
||||
auto imageEditor = ImageEditorView::Create();
|
||||
tabbedPanel->AddPanel(std::move(imageEditor), "Image Editor");
|
||||
|
||||
auto webClient = WebClientView::Create();
|
||||
tabbedPanel->AddPanel(std::move(webClient), "Web Client");
|
||||
|
||||
auto topBar = TopBar::Create();
|
||||
auto statusBar = StatusBar::Create();
|
||||
|
||||
auto horizontalSpace = HorizontalSpacer::Create();
|
||||
horizontalSpace->AddWidgetWithScale(std::move(topBar), 1);
|
||||
horizontalSpace->AddWidgetWithScale(std::move(tabbedPanel), 20);
|
||||
horizontalSpace->AddWidgetWithScale(std::move(statusBar), 1);
|
||||
|
||||
mainWindow->AddWidget(std::move(horizontalSpace));
|
||||
}
|
||||
|
||||
void GuiApplication::Run()
|
||||
void GuiApplication::setUiInterfaceBackend(UiInterfaceFactory::Backend backend)
|
||||
{
|
||||
mUiInterfaceBackend = backend;
|
||||
}
|
||||
|
||||
void GuiApplication::run()
|
||||
{
|
||||
auto mainWindow = mDesktopManager->GetWindowManager()->GetMainWindow();
|
||||
SetUpWidget();
|
||||
initializeViews();
|
||||
|
||||
MLOG_INFO("Creating Window Interface");
|
||||
auto window_interface = UiInterfaceFactory::create(mDesktopManager.get());
|
||||
mUiInterface = UiInterfaceFactory::create(mDesktopManager.get(), mUiInterfaceBackend);
|
||||
|
||||
window_interface->initialize();
|
||||
window_interface->addWindow(mainWindow);
|
||||
window_interface->showWindow(mainWindow);
|
||||
window_interface->loop();
|
||||
mUiInterface->initialize();
|
||||
mUiInterface->addWindow(mainWindow);
|
||||
mUiInterface->showWindow(mainWindow);
|
||||
mUiInterface->loop();
|
||||
|
||||
window_interface->shutDown();
|
||||
mUiInterface->shutDown();
|
||||
|
||||
MLOG_INFO("Window Interface Shut Down");
|
||||
|
||||
mMainApplication->ShutDown();
|
||||
}
|
||||
|
|
|
@ -1,28 +1,35 @@
|
|||
#pragma once
|
||||
|
||||
#include "MainApplication.h"
|
||||
#include "AbstractDesktopApp.h"
|
||||
#include "DesktopManager.h"
|
||||
#include "UiInterfaceFactory.h"
|
||||
#include "CommandLineArgs.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class MainApplication;
|
||||
class DesktopManager;
|
||||
class AbstractUiInterface;
|
||||
|
||||
class GuiApplication : public AbstractDesktopApp
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
DesktopManagerUPtr mDesktopManager;
|
||||
MainApplicationPtr mMainApplication;
|
||||
|
||||
public:
|
||||
|
||||
GuiApplication();
|
||||
GuiApplication(std::unique_ptr<CommandLineArgs> args = nullptr);
|
||||
|
||||
~GuiApplication();
|
||||
|
||||
void SetMainApplication(MainApplicationPtr app);
|
||||
AbstractApp* getMainApplication() const override;
|
||||
|
||||
void Run();
|
||||
void run();
|
||||
|
||||
void SetUpWidget();
|
||||
void setUiInterfaceBackend(UiInterfaceFactory::Backend backend);
|
||||
|
||||
protected:
|
||||
virtual void initializeViews();
|
||||
|
||||
std::unique_ptr<DesktopManager> mDesktopManager;
|
||||
std::unique_ptr<MainApplication> mMainApplication;
|
||||
|
||||
private:
|
||||
UiInterfaceFactory::Backend mUiInterfaceBackend = UiInterfaceFactory::Backend::UNSET;
|
||||
std::unique_ptr<AbstractUIInterface> mUiInterface;
|
||||
};
|
||||
|
|
|
@ -28,7 +28,7 @@ MainApplication::~MainApplication()
|
|||
|
||||
}
|
||||
|
||||
void MainApplication::Initialize(CommandLineArgsUPtr commandLineArgs, std::unique_ptr<IApplicationContext> applicationContext)
|
||||
void MainApplication::initialize(CommandLineArgsUPtr commandLineArgs, std::unique_ptr<IApplicationContext> applicationContext)
|
||||
{
|
||||
if (applicationContext)
|
||||
{
|
||||
|
@ -137,7 +137,7 @@ void MainApplication::ShutDown()
|
|||
FileLogger::GetInstance().Close();
|
||||
}
|
||||
|
||||
std::shared_ptr<MainApplication> MainApplication::Create()
|
||||
std::unique_ptr<MainApplication> MainApplication::Create()
|
||||
{
|
||||
return std::make_shared<MainApplication>();
|
||||
return std::make_unique<MainApplication>();
|
||||
}
|
||||
|
|
|
@ -13,12 +13,11 @@
|
|||
class MainApplication : public AbstractApp
|
||||
{
|
||||
public:
|
||||
|
||||
MainApplication();
|
||||
|
||||
~MainApplication();
|
||||
|
||||
void Initialize(CommandLineArgsUPtr commandLineArgs, std::unique_ptr<IApplicationContext> applicationContext=nullptr);
|
||||
void initialize(CommandLineArgsUPtr commandLineArgs, std::unique_ptr<IApplicationContext> applicationContext=nullptr);
|
||||
|
||||
void Run();
|
||||
|
||||
|
@ -26,7 +25,7 @@ public:
|
|||
|
||||
CommandLineArgs* GetCommandLineArgs() const;
|
||||
|
||||
static std::shared_ptr<MainApplication> Create();
|
||||
static std::unique_ptr<MainApplication> Create();
|
||||
|
||||
private:
|
||||
void RunServer();
|
||||
|
|
|
@ -10,9 +10,9 @@ namespace mt
|
|||
{
|
||||
|
||||
Window::Window()
|
||||
:mWidth(400),
|
||||
mHeight(300),
|
||||
mWidget()
|
||||
:mWidth(800),
|
||||
mHeight(600),
|
||||
mWidget(Widget::Create())
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -50,6 +50,10 @@ void Window::OnPaint(const PaintEvent* event)
|
|||
|
||||
void Window::AddWidget(WidgetUPtr widget)
|
||||
{
|
||||
if (mWidget)
|
||||
{
|
||||
mWidget.reset();
|
||||
}
|
||||
mWidget = std::move(widget);
|
||||
}
|
||||
|
||||
|
|
|
@ -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>;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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};
|
||||
};
|
||||
|
|
|
@ -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>();
|
||||
|
|
|
@ -12,7 +12,9 @@ public:
|
|||
enum class Backend
|
||||
{
|
||||
UNSET,
|
||||
X11_RASTER,
|
||||
X11,
|
||||
WAYLAND_RASTER,
|
||||
WAYLAND
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#include "DesktopManager.h"
|
||||
#include "XcbInterface.h"
|
||||
|
||||
#include "TestCase.h"
|
||||
#include "TestCaseRunner.h"
|
||||
|
||||
#include "GuiApplication.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
@ -13,18 +12,11 @@ class TestOpenGlRendering : public TestCase
|
|||
public:
|
||||
bool Run() override
|
||||
{
|
||||
auto desktopManager = DesktopManager::Create();
|
||||
auto app = std::make_unique<GuiApplication>();
|
||||
|
||||
auto mainWindow = desktopManager->GetWindowManager()->GetMainWindow();
|
||||
mainWindow->SetSize(800, 600);
|
||||
|
||||
XcbInterface window_interface(desktopManager.get());
|
||||
window_interface.setUseHardwareRendering(true);
|
||||
window_interface.initialize();
|
||||
window_interface.addWindow(mainWindow);
|
||||
window_interface.showWindow(mainWindow);
|
||||
window_interface.loop();
|
||||
window_interface.shutDown();
|
||||
//app->setUiInterfaceBackend(UiInterfaceFactory::Backend::X11);
|
||||
app->setUiInterfaceBackend(UiInterfaceFactory::Backend::X11_RASTER);
|
||||
app->run();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -3,27 +3,18 @@
|
|||
#include "Window.h"
|
||||
#include "FileLogger.h"
|
||||
|
||||
#include "DesktopManager.h"
|
||||
#include "GuiApplication.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
FileLogger::GetInstance().Open();
|
||||
|
||||
auto desktop_manager = DesktopManager::Create();
|
||||
auto app = std::make_unique<GuiApplication>();
|
||||
|
||||
auto window = desktop_manager->GetWindowManager()->GetMainWindow();
|
||||
window->SetSize(800, 600);
|
||||
//app->setUiInterfaceBackend(UiInterfaceFactory::Backend::WAYLAND);
|
||||
app->setUiInterfaceBackend(UiInterfaceFactory::Backend::WAYLAND_RASTER);
|
||||
|
||||
WaylandInterface window_interface(desktop_manager.get());
|
||||
window_interface.setUseHardwareRendering(true);
|
||||
window_interface.initialize();
|
||||
app->run();
|
||||
|
||||
window_interface.addWindow(window);
|
||||
|
||||
window_interface.showWindow(window);
|
||||
|
||||
window_interface.loop();
|
||||
|
||||
window_interface.shutDown();
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue