Diff
1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
2index 967acd5b5381045ff6fecc5fd359e7d872919b60..048e7d0ad9ac51d8635045f7c88f63af668c850c 100644
3--- a/src/Hy3Layout.cpp
4+++ b/src/Hy3Layout.cpp
5@@ -1139,3 +1139,47 @@ Hy3Node* shiftOrGetFocus(Hy3Node& node, ShiftDirection direction, bool shift) {
6
7 return nullptr;
8 }
9+
10+std::string Hy3Node::debugNode() {
11+ std::stringstream buf;
12+ std::string addr = "0x" + std::to_string((size_t)this);
13+ switch (this->data.type) {
14+ case Hy3NodeData::Window:
15+ buf << "window(";
16+ buf << std::hex << this;
17+ buf << ") [hypr ";
18+ buf << this->data.as_window;
19+ buf << "]";
20+ break;
21+ case Hy3NodeData::Group:
22+ buf << "group(";
23+ buf << std::hex << this;
24+ buf << ") [";
25+
26+ switch (this->data.as_group.layout) {
27+ case Hy3GroupLayout::SplitH:
28+ buf << "splith";
29+ break;
30+ case Hy3GroupLayout::SplitV:
31+ buf << "splitv";
32+ break;
33+ case Hy3GroupLayout::Tabbed:
34+ buf << "tabs";
35+ break;
36+ }
37+
38+ buf << "]";
39+ for (auto* child: this->data.as_group.children) {
40+ buf << "\n|-";
41+ // this is terrible
42+ for (char c: child->debugNode()) {
43+ buf << c;
44+ if (c == '\n') buf << " ";
45+ }
46+ }
47+
48+ break;
49+ }
50+
51+ return buf.str();
52+}
53diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp
54index c33c97c5e88b21848293cfd9303796851df4f370..ec6523e3f0b352aa325287eade5766be3fadc43d 100644
55--- a/src/Hy3Layout.hpp
56+++ b/src/Hy3Layout.hpp
57@@ -74,6 +74,7 @@ struct Hy3Node {
58 Hy3Layout* layout = nullptr;
59
60 void recalcSizePosRecursive(bool force = false);
61+ std::string debugNode();
62
63 bool operator==(const Hy3Node&) const;
64 };
65@@ -104,6 +105,8 @@ public:
66 void shiftWindow(CWindow*, ShiftDirection);
67 void shiftFocus(CWindow*, ShiftDirection);
68
69+ Hy3Node* getWorkspaceRootGroup(const int&);
70+
71 std::list<Hy3Node> nodes;
72 private:
73 CWindow* lastActiveWindow = nullptr;
74@@ -116,7 +119,6 @@ private:
75
76 int getWorkspaceNodeCount(const int&);
77 Hy3Node* getNodeFromWindow(CWindow*);
78- Hy3Node* getWorkspaceRootGroup(const int&);
79 void applyNodeDataToWindow(Hy3Node*, bool force = false);
80
81 friend struct Hy3Node;
82diff --git a/src/main.cpp b/src/main.cpp
83index ca9ce62de09c88da8c51bc56e3176137a72eba81..f00359d1a8d18f102107b1c0552cb226d467f0bd 100644
84--- a/src/main.cpp
85+++ b/src/main.cpp
86@@ -66,6 +66,18 @@ void dispatch_movefocus(std::string arg) {
87 }
88 }
89
90+void dispatch_debug(std::string arg) {
91+ CWindow* window = window_for_action();
92+ if (window == nullptr) return;
93+
94+ auto* root = g_Hy3Layout->getWorkspaceRootGroup(window->m_iWorkspaceID);
95+ if (window == nullptr) {
96+ Debug::log(LOG, "DEBUG NODES: no nodes on workspace");
97+ } else {
98+ Debug::log(LOG, "DEBUG NODES\n%s", root->debugNode().c_str());
99+ }
100+}
101+
102 APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
103 PHANDLE = handle;
104
105@@ -77,6 +89,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
106 HyprlandAPI::addDispatcher(PHANDLE, "hy3_makegroup", dispatch_makegroup);
107 HyprlandAPI::addDispatcher(PHANDLE, "hy3_movefocus", dispatch_movefocus);
108 HyprlandAPI::addDispatcher(PHANDLE, "hy3_movewindow", dispatch_movewindow);
109+ HyprlandAPI::addDispatcher(PHANDLE, "hy3_debugnodes", dispatch_debug);
110
111 return {"hy3", "i3 like layout for hyprland", "outfoxxed", "0.1"};
112 }