mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-09-11 00:15:37 +03:00
refactor: addWindow skeleton
This commit is contained in:
parent
7b81428a79
commit
8ec6b95161
@ -22,6 +22,7 @@ ecm_qt_declare_logging_category(
|
||||
"Bismuth Plasma Tiling Extension")
|
||||
|
||||
add_subdirectory(plasma-api)
|
||||
add_subdirectory(engine)
|
||||
|
||||
target_sources(bismuth_core PRIVATE qml-plugin.cpp ts-proxy.cpp controller.cpp
|
||||
qmldir ${BISMUTH_LOG})
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "engine/engine.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "plasma-api/client.hpp"
|
||||
#include "plasma-api/workspace.hpp"
|
||||
@ -20,9 +21,10 @@
|
||||
|
||||
namespace Bismuth
|
||||
{
|
||||
Controller::Controller(PlasmaApi::Api &api)
|
||||
Controller::Controller(PlasmaApi::Api &api, Engine &engine)
|
||||
: m_plasmaApi(api)
|
||||
, m_proxy()
|
||||
, m_engine(engine)
|
||||
{
|
||||
bindEvents();
|
||||
}
|
||||
@ -34,6 +36,7 @@ void Controller::bindEvents()
|
||||
connect(&workspace, &PlasmaApi::Workspace::numberScreensChanged, this, &Controller::onSurfaceUpdate);
|
||||
connect(&workspace, &PlasmaApi::Workspace::screenResized, this, &Controller::onSurfaceUpdate);
|
||||
connect(&workspace, &PlasmaApi::Workspace::currentActivityChanged, this, &Controller::onCurrentSurfaceChanged);
|
||||
connect(&workspace, &PlasmaApi::Workspace::clientAdded, this, &Controller::onClientAdded);
|
||||
}
|
||||
|
||||
void Controller::registerAction(const Action &data)
|
||||
@ -77,6 +80,11 @@ void Controller::onSurfaceUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
void Controller::onClientAdded(PlasmaApi::Client client)
|
||||
{
|
||||
m_engine.addWindow(client);
|
||||
}
|
||||
|
||||
void Controller::setProxy(TSProxy *proxy)
|
||||
{
|
||||
m_proxy = proxy;
|
||||
|
@ -11,7 +11,9 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "engine/engine.hpp"
|
||||
#include "plasma-api/api.hpp"
|
||||
#include "plasma-api/client.hpp"
|
||||
|
||||
class TSProxy;
|
||||
|
||||
@ -31,7 +33,7 @@ class Controller : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Controller(PlasmaApi::Api &);
|
||||
Controller(PlasmaApi::Api &, Engine &);
|
||||
|
||||
void bindEvents();
|
||||
void registerAction(const Action &);
|
||||
@ -41,12 +43,14 @@ public:
|
||||
public Q_SLOTS:
|
||||
void onCurrentSurfaceChanged();
|
||||
void onSurfaceUpdate();
|
||||
void onClientAdded(PlasmaApi::Client);
|
||||
|
||||
private:
|
||||
std::vector<QAction *> m_registeredShortcuts{};
|
||||
|
||||
PlasmaApi::Api &m_plasmaApi;
|
||||
TSProxy *m_proxy;
|
||||
Engine &m_engine;
|
||||
};
|
||||
|
||||
}
|
||||
|
4
src/core/engine/CMakeLists.txt
Normal file
4
src/core/engine/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
||||
# SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
target_sources(bismuth_core PRIVATE engine.cpp windows_list.cpp window.cpp)
|
17
src/core/engine/engine.cpp
Normal file
17
src/core/engine/engine.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "engine.hpp"
|
||||
|
||||
namespace Bismuth
|
||||
{
|
||||
Engine::Engine()
|
||||
{
|
||||
}
|
||||
|
||||
void Engine::addWindow(PlasmaApi::Client client)
|
||||
{
|
||||
m_windows.add(client);
|
||||
// Bind events of this window
|
||||
}
|
||||
}
|
21
src/core/engine/engine.hpp
Normal file
21
src/core/engine/engine.hpp
Normal file
@ -0,0 +1,21 @@
|
||||
// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "plasma-api/client.hpp"
|
||||
#include "windows_list.hpp"
|
||||
|
||||
namespace Bismuth
|
||||
{
|
||||
class Engine
|
||||
{
|
||||
public:
|
||||
Engine();
|
||||
|
||||
void addWindow(PlasmaApi::Client);
|
||||
|
||||
private:
|
||||
WindowsList m_windows{};
|
||||
};
|
||||
}
|
9
src/core/engine/window.cpp
Normal file
9
src/core/engine/window.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "window.hpp"
|
||||
|
||||
namespace Bismuth
|
||||
{
|
||||
|
||||
}
|
11
src/core/engine/window.hpp
Normal file
11
src/core/engine/window.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Bismuth
|
||||
{
|
||||
class Window
|
||||
{
|
||||
};
|
||||
}
|
14
src/core/engine/windows_list.cpp
Normal file
14
src/core/engine/windows_list.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "windows_list.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
namespace Bismuth
|
||||
{
|
||||
|
||||
void WindowsList::add(PlasmaApi::Client)
|
||||
{
|
||||
qDebug(Bi) << "Adding window... (CXX)";
|
||||
}
|
||||
}
|
19
src/core/engine/windows_list.hpp
Normal file
19
src/core/engine/windows_list.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "plasma-api/client.hpp"
|
||||
#include "window.hpp"
|
||||
|
||||
namespace Bismuth
|
||||
{
|
||||
class WindowsList
|
||||
{
|
||||
public:
|
||||
void add(PlasmaApi::Client);
|
||||
|
||||
private:
|
||||
std::map<PlasmaApi::Client, Window> m_windowMap{};
|
||||
};
|
||||
}
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "config.hpp"
|
||||
#include "controller.hpp"
|
||||
#include "engine/engine.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "plasma-api/api.hpp"
|
||||
#include "ts-proxy.hpp"
|
||||
@ -27,7 +28,7 @@ void CorePlugin::registerTypes(const char *uri)
|
||||
|
||||
Core::Core(QQuickItem *parent)
|
||||
: QQuickItem(parent)
|
||||
, m_engine() // We cannot get engine from the pointer in the constructor
|
||||
, m_qmlEngine() // We cannot get engine from the pointer in the constructor
|
||||
, m_controller()
|
||||
, m_tsProxy()
|
||||
, m_config()
|
||||
@ -41,10 +42,11 @@ Core::Core(QQuickItem *parent)
|
||||
void Core::init()
|
||||
{
|
||||
m_config = std::make_unique<Bismuth::Config>();
|
||||
m_engine = qmlEngine(this);
|
||||
m_plasmaApi = std::make_unique<PlasmaApi::Api>(m_engine);
|
||||
m_controller = std::make_unique<Bismuth::Controller>(*m_plasmaApi);
|
||||
m_tsProxy = std::make_unique<TSProxy>(m_engine, *m_controller, *m_plasmaApi, *m_config);
|
||||
m_qmlEngine = qmlEngine(this);
|
||||
m_plasmaApi = std::make_unique<PlasmaApi::Api>(m_qmlEngine);
|
||||
m_engine = std::make_unique<Bismuth::Engine>();
|
||||
m_controller = std::make_unique<Bismuth::Controller>(*m_plasmaApi, *m_engine);
|
||||
m_tsProxy = std::make_unique<TSProxy>(m_qmlEngine, *m_controller, *m_plasmaApi, *m_config);
|
||||
m_controller->setProxy(m_tsProxy.get());
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "config.hpp"
|
||||
#include "controller.hpp"
|
||||
#include "engine/engine.hpp"
|
||||
#include "plasma-api/api.hpp"
|
||||
#include "ts-proxy.hpp"
|
||||
|
||||
@ -44,10 +45,11 @@ public:
|
||||
TSProxy *tsProxy() const;
|
||||
|
||||
private:
|
||||
QQmlEngine *m_engine; ///< Pointer to the engine, that is currently using the Core element
|
||||
QQmlEngine *m_qmlEngine; ///< Pointer to the engine, that is currently using the Core element
|
||||
|
||||
std::unique_ptr<Bismuth::Controller> m_controller; ///< Legacy TS Backend proxy
|
||||
std::unique_ptr<TSProxy> m_tsProxy; ///< Legacy TS Backend proxy
|
||||
std::unique_ptr<Bismuth::Config> m_config;
|
||||
std::unique_ptr<PlasmaApi::Api> m_plasmaApi;
|
||||
std::unique_ptr<Bismuth::Engine> m_engine;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user