From 805229a182d0f4eab328b4c27b910789550cc649 Mon Sep 17 00:00:00 2001 From: Mikhail Zolotukhin Date: Sat, 26 Mar 2022 16:07:19 +0300 Subject: [PATCH] chore: connect workspace signals to cxx controller --- src/core/controller.cpp | 44 ++++++++++++++++++++++++++++++++++++++ src/core/controller.hpp | 6 ++++++ src/core/engine/engine.cpp | 8 +++++++ src/core/engine/engine.hpp | 6 ++++++ 4 files changed, 64 insertions(+) diff --git a/src/core/controller.cpp b/src/core/controller.cpp index 97109936..31f2b657 100644 --- a/src/core/controller.cpp +++ b/src/core/controller.cpp @@ -27,6 +27,11 @@ Controller::Controller(PlasmaApi::Api &api, Engine &engine) , m_engine(engine) { bindEvents(); + // TODO: Bind shortcuts + + loadExistingWindows(); + + m_engine.arrange(); } void Controller::bindEvents() @@ -37,6 +42,25 @@ void Controller::bindEvents() connect(&workspace, &PlasmaApi::Workspace::screenResized, this, &Controller::onSurfaceUpdate); connect(&workspace, &PlasmaApi::Workspace::currentActivityChanged, this, &Controller::onCurrentSurfaceChanged); connect(&workspace, &PlasmaApi::Workspace::clientAdded, this, &Controller::onClientAdded); + connect(&workspace, &PlasmaApi::Workspace::clientRemoved, this, &Controller::onClientRemoved); + connect(&workspace, &PlasmaApi::Workspace::clientMaximizeSet, this, [this](PlasmaApi::Client client, bool h, bool v) { + if (h == true && v == true) { + onClientMaximized(client); + } else if (h == false && v == false) { + onClientUnmaximized(client); + } + }); + connect(&workspace, &PlasmaApi::Workspace::clientMinimized, this, &Controller::onClientMinimized); + connect(&workspace, &PlasmaApi::Workspace::clientUnminimized, this, &Controller::onClientUnminimized); +} + +void Controller::loadExistingWindows() +{ + auto clients = m_plasmaApi.workspace().clientList(); + + for (auto client : clients) { + m_engine.addWindow(client); + } } void Controller::registerAction(const Action &data) @@ -85,6 +109,26 @@ void Controller::onClientAdded(PlasmaApi::Client client) m_engine.addWindow(client); } +void Controller::onClientRemoved(PlasmaApi::Client) +{ +} + +void Controller::onClientMaximized(PlasmaApi::Client) +{ +} + +void Controller::onClientUnmaximized(PlasmaApi::Client) +{ +} + +void Controller::onClientMinimized(PlasmaApi::Client) +{ +} + +void Controller::onClientUnminimized(PlasmaApi::Client) +{ +} + void Controller::setProxy(TSProxy *proxy) { m_proxy = proxy; diff --git a/src/core/controller.hpp b/src/core/controller.hpp index 206164fe..65e7d02d 100644 --- a/src/core/controller.hpp +++ b/src/core/controller.hpp @@ -36,6 +36,7 @@ public: Controller(PlasmaApi::Api &, Engine &); void bindEvents(); + void loadExistingWindows(); void registerAction(const Action &); void setProxy(TSProxy *); @@ -44,6 +45,11 @@ public Q_SLOTS: void onCurrentSurfaceChanged(); void onSurfaceUpdate(); void onClientAdded(PlasmaApi::Client); + void onClientRemoved(PlasmaApi::Client); + void onClientMaximized(PlasmaApi::Client); + void onClientUnmaximized(PlasmaApi::Client); + void onClientMinimized(PlasmaApi::Client); + void onClientUnminimized(PlasmaApi::Client); private: std::vector m_registeredShortcuts{}; diff --git a/src/core/engine/engine.cpp b/src/core/engine/engine.cpp index be182e4a..b7fe9414 100644 --- a/src/core/engine/engine.cpp +++ b/src/core/engine/engine.cpp @@ -14,4 +14,12 @@ void Engine::addWindow(PlasmaApi::Client client) m_windows.add(client); // Bind events of this window } + +void Engine::removeWindow(PlasmaApi::Client client) +{ +} + +void Engine::arrange() +{ +} } diff --git a/src/core/engine/engine.hpp b/src/core/engine/engine.hpp index e55df491..f095cab7 100644 --- a/src/core/engine/engine.hpp +++ b/src/core/engine/engine.hpp @@ -14,6 +14,12 @@ public: Engine(); void addWindow(PlasmaApi::Client); + void removeWindow(PlasmaApi::Client); + + /** + * Arrange the windows on all visible surfaces + */ + void arrange(); private: WindowsList m_windows{};