mirror of
https://github.com/Trensa-Organization/hy3.git
synced 2025-03-16 03:03:40 +01:00
Add node tree debug dispatcher
This commit is contained in:
parent
be3bd8c535
commit
1121d0aa66
3 changed files with 60 additions and 1 deletions
|
@ -1139,3 +1139,47 @@ Hy3Node* shiftOrGetFocus(Hy3Node& node, ShiftDirection direction, bool shift) {
|
|||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string Hy3Node::debugNode() {
|
||||
std::stringstream buf;
|
||||
std::string addr = "0x" + std::to_string((size_t)this);
|
||||
switch (this->data.type) {
|
||||
case Hy3NodeData::Window:
|
||||
buf << "window(";
|
||||
buf << std::hex << this;
|
||||
buf << ") [hypr ";
|
||||
buf << this->data.as_window;
|
||||
buf << "]";
|
||||
break;
|
||||
case Hy3NodeData::Group:
|
||||
buf << "group(";
|
||||
buf << std::hex << this;
|
||||
buf << ") [";
|
||||
|
||||
switch (this->data.as_group.layout) {
|
||||
case Hy3GroupLayout::SplitH:
|
||||
buf << "splith";
|
||||
break;
|
||||
case Hy3GroupLayout::SplitV:
|
||||
buf << "splitv";
|
||||
break;
|
||||
case Hy3GroupLayout::Tabbed:
|
||||
buf << "tabs";
|
||||
break;
|
||||
}
|
||||
|
||||
buf << "]";
|
||||
for (auto* child: this->data.as_group.children) {
|
||||
buf << "\n|-";
|
||||
// this is terrible
|
||||
for (char c: child->debugNode()) {
|
||||
buf << c;
|
||||
if (c == '\n') buf << " ";
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return buf.str();
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ struct Hy3Node {
|
|||
Hy3Layout* layout = nullptr;
|
||||
|
||||
void recalcSizePosRecursive(bool force = false);
|
||||
std::string debugNode();
|
||||
|
||||
bool operator==(const Hy3Node&) const;
|
||||
};
|
||||
|
@ -104,6 +105,8 @@ public:
|
|||
void shiftWindow(CWindow*, ShiftDirection);
|
||||
void shiftFocus(CWindow*, ShiftDirection);
|
||||
|
||||
Hy3Node* getWorkspaceRootGroup(const int&);
|
||||
|
||||
std::list<Hy3Node> nodes;
|
||||
private:
|
||||
CWindow* lastActiveWindow = nullptr;
|
||||
|
@ -116,7 +119,6 @@ private:
|
|||
|
||||
int getWorkspaceNodeCount(const int&);
|
||||
Hy3Node* getNodeFromWindow(CWindow*);
|
||||
Hy3Node* getWorkspaceRootGroup(const int&);
|
||||
void applyNodeDataToWindow(Hy3Node*, bool force = false);
|
||||
|
||||
friend struct Hy3Node;
|
||||
|
|
13
src/main.cpp
13
src/main.cpp
|
@ -66,6 +66,18 @@ void dispatch_movefocus(std::string arg) {
|
|||
}
|
||||
}
|
||||
|
||||
void dispatch_debug(std::string arg) {
|
||||
CWindow* window = window_for_action();
|
||||
if (window == nullptr) return;
|
||||
|
||||
auto* root = g_Hy3Layout->getWorkspaceRootGroup(window->m_iWorkspaceID);
|
||||
if (window == nullptr) {
|
||||
Debug::log(LOG, "DEBUG NODES: no nodes on workspace");
|
||||
} else {
|
||||
Debug::log(LOG, "DEBUG NODES\n%s", root->debugNode().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
||||
PHANDLE = handle;
|
||||
|
||||
|
@ -77,6 +89,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
|||
HyprlandAPI::addDispatcher(PHANDLE, "hy3_makegroup", dispatch_makegroup);
|
||||
HyprlandAPI::addDispatcher(PHANDLE, "hy3_movefocus", dispatch_movefocus);
|
||||
HyprlandAPI::addDispatcher(PHANDLE, "hy3_movewindow", dispatch_movewindow);
|
||||
HyprlandAPI::addDispatcher(PHANDLE, "hy3_debugnodes", dispatch_debug);
|
||||
|
||||
return {"hy3", "i3 like layout for hyprland", "outfoxxed", "0.1"};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue