From 293a12d0b748e0ac0e02db385717aac2f7bcd962 Mon Sep 17 00:00:00 2001 From: LordGrimmauld Date: Mon, 11 Mar 2024 10:42:19 +0100 Subject: [PATCH] Fix scratchpad support (i was an idiot) --- tree/swaytree.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tree/swaytree.h b/tree/swaytree.h index be73449..0c37022 100644 --- a/tree/swaytree.h +++ b/tree/swaytree.h @@ -88,7 +88,7 @@ struct SwayRecord { explicit SwayRecord(const json &rep) : id(rep["id"]), - name(rep["name"].is_null() ? "untitled container" : rep["name"]), + name(getName(rep)), type(NodeType::fromString(rep["type"])), border(rep["border"]), current_border_width(rep["current_border_width"]), @@ -115,6 +115,17 @@ struct SwayRecord { [[nodiscard]] bool operator==(const SwayRecord &other) const { return this->id == other.id; } +private: + static std::string getName(const json& rep) { + if(rep["name"].is_null()) + return "Untitled Container"; + std::string internal = rep["name"]; + if (internal == "__i3" && NodeType::fromString(rep["type"]) == NodeType::output) + return "Virtual Display"; + if (internal == "__i3_scratch" && NodeType::fromString(rep["type"]) == NodeType::workspace) + return "Scratchpad"; + return internal; + } }; class SwayTreeNode : public AbstractTreeNode { @@ -128,12 +139,10 @@ public: this->appendChild(childNode); } - /* for (const auto &child: rep["floating_nodes"]) { auto childNode = std::make_unique(child, this); this->appendChild(childNode); } - */ } explicit SwayTreeNode(SwayTreeNode *parent = nullptr) : node(SwayRecord()), AbstractTreeNode(parent) {};