diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 91a0adce..a3eb378f 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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}) diff --git a/src/core/controller.cpp b/src/core/controller.cpp index 8ab9fb34..97109936 100644 --- a/src/core/controller.cpp +++ b/src/core/controller.cpp @@ -13,6 +13,7 @@ #include +#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; diff --git a/src/core/controller.hpp b/src/core/controller.hpp index 62d9681d..206164fe 100644 --- a/src/core/controller.hpp +++ b/src/core/controller.hpp @@ -11,7 +11,9 @@ #include #include +#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 m_registeredShortcuts{}; PlasmaApi::Api &m_plasmaApi; TSProxy *m_proxy; + Engine &m_engine; }; } diff --git a/src/core/engine/CMakeLists.txt b/src/core/engine/CMakeLists.txt new file mode 100644 index 00000000..b694cd81 --- /dev/null +++ b/src/core/engine/CMakeLists.txt @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin +# SPDX-License-Identifier: MIT + +target_sources(bismuth_core PRIVATE engine.cpp windows_list.cpp window.cpp) diff --git a/src/core/engine/engine.cpp b/src/core/engine/engine.cpp new file mode 100644 index 00000000..be182e4a --- /dev/null +++ b/src/core/engine/engine.cpp @@ -0,0 +1,17 @@ +// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin +// 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 +} +} diff --git a/src/core/engine/engine.hpp b/src/core/engine/engine.hpp new file mode 100644 index 00000000..e55df491 --- /dev/null +++ b/src/core/engine/engine.hpp @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin +// 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{}; +}; +} diff --git a/src/core/engine/window.cpp b/src/core/engine/window.cpp new file mode 100644 index 00000000..57588209 --- /dev/null +++ b/src/core/engine/window.cpp @@ -0,0 +1,9 @@ +// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin +// SPDX-License-Identifier: MIT + +#include "window.hpp" + +namespace Bismuth +{ + +} diff --git a/src/core/engine/window.hpp b/src/core/engine/window.hpp new file mode 100644 index 00000000..63e44655 --- /dev/null +++ b/src/core/engine/window.hpp @@ -0,0 +1,11 @@ +// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin +// SPDX-License-Identifier: MIT + +#pragma once + +namespace Bismuth +{ +class Window +{ +}; +} diff --git a/src/core/engine/windows_list.cpp b/src/core/engine/windows_list.cpp new file mode 100644 index 00000000..1d54112b --- /dev/null +++ b/src/core/engine/windows_list.cpp @@ -0,0 +1,14 @@ +// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin +// SPDX-License-Identifier: MIT + +#include "windows_list.hpp" +#include "logger.hpp" + +namespace Bismuth +{ + +void WindowsList::add(PlasmaApi::Client) +{ + qDebug(Bi) << "Adding window... (CXX)"; +} +} diff --git a/src/core/engine/windows_list.hpp b/src/core/engine/windows_list.hpp new file mode 100644 index 00000000..ff6be7de --- /dev/null +++ b/src/core/engine/windows_list.hpp @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin +// 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 m_windowMap{}; +}; +} diff --git a/src/core/qml-plugin.cpp b/src/core/qml-plugin.cpp index 7d56fb82..c528565f 100644 --- a/src/core/qml-plugin.cpp +++ b/src/core/qml-plugin.cpp @@ -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(); - m_engine = qmlEngine(this); - m_plasmaApi = std::make_unique(m_engine); - m_controller = std::make_unique(*m_plasmaApi); - m_tsProxy = std::make_unique(m_engine, *m_controller, *m_plasmaApi, *m_config); + m_qmlEngine = qmlEngine(this); + m_plasmaApi = std::make_unique(m_qmlEngine); + m_engine = std::make_unique(); + m_controller = std::make_unique(*m_plasmaApi, *m_engine); + m_tsProxy = std::make_unique(m_qmlEngine, *m_controller, *m_plasmaApi, *m_config); m_controller->setProxy(m_tsProxy.get()); } diff --git a/src/core/qml-plugin.hpp b/src/core/qml-plugin.hpp index af26c2c5..30350ec1 100644 --- a/src/core/qml-plugin.hpp +++ b/src/core/qml-plugin.hpp @@ -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 m_controller; ///< Legacy TS Backend proxy std::unique_ptr m_tsProxy; ///< Legacy TS Backend proxy std::unique_ptr m_config; std::unique_ptr m_plasmaApi; + std::unique_ptr m_engine; };