#include "monitor.hpp" #include #include #include #include #include #include #include "controller.hpp" #include "workspace.hpp" namespace qs::i3::ipc { I3Monitor::I3Monitor(I3IpcController* ipc): QObject(ipc), ipc(ipc) { // clang-format off this->bFocused.setBinding([this]() { return this->ipc->bindableFocusedMonitor().value() == this; }); // clang-format on } QVariantMap I3Monitor::lastIpcObject() const { return this->mLastIpcObject; }; void I3Monitor::updateFromObject(const QVariantMap& obj) { if (obj != this->mLastIpcObject) { this->mLastIpcObject = obj; emit this->lastIpcObjectChanged(); } auto activeWorkspaceName = obj.value("current_workspace").value(); auto rect = obj.value("rect").toMap(); Qt::beginPropertyUpdateGroup(); this->bId = obj.value("id").value(); this->bName = obj.value("name").value(); this->bPower = obj.value("power").value(); this->bX = rect.value("x").value(); this->bY = rect.value("y").value(); this->bWidth = rect.value("width").value(); this->bHeight = rect.value("height").value(); this->bScale = obj.value("scale").value(); if (!this->bActiveWorkspace || activeWorkspaceName != this->bActiveWorkspace->bindableName().value()) { if (activeWorkspaceName.isEmpty()) { this->bActiveWorkspace = nullptr; } else { this->bActiveWorkspace = this->ipc->findWorkspaceByName(activeWorkspaceName); } }; Qt::endPropertyUpdateGroup(); } void I3Monitor::updateInitial(const QString& name) { this->bName = name; } void I3Monitor::setFocusedWorkspace(I3Workspace* workspace) { this->bActiveWorkspace = workspace; }; } // namespace qs::i3::ipc