f6bcdc39273a91c48ea78858c5f2cab659f3c339
- Author
- outfoxxed <outfoxxed@outfoxxed.me>
- Committer
- outfoxxed <outfoxxed@outfoxxed.me>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
2index 4d0a863e1e56e75648300e9fbbe88bcb9aa3326d..1118d2fc2cf0bec929309bf81f4d29c3b24eab6f 100644
3--- a/src/Hy3Layout.cpp
4+++ b/src/Hy3Layout.cpp
5@@ -197,7 +197,7 @@ void Hy3Node::recalcSizePosRecursive(bool force) {
6 }
7 }
8
9-bool swallowGroup(Hy3Node* into) {
10+bool Hy3Node::swallowGroups(Hy3Node* into) {
11 if (into == nullptr
12 || into->parent == nullptr
13 || into->data.type != Hy3NodeData::Group
14@@ -207,16 +207,16 @@ bool swallowGroup(Hy3Node* into) {
15 auto* child = into->data.as_group.children.front();
16
17 Debug::log(LOG, "Swallowing %p into %p", child, into);
18- swapNodeData(*into, *child);
19+ Hy3Node::swapData(*into, *child);
20 into->layout->nodes.remove(*child);
21
22 return true;
23 }
24
25-Hy3Node* removeFromParentRecursive(Hy3Node* node) {
26- Hy3Node* parent = node;
27+Hy3Node* Hy3Node::removeFromParentRecursive() {
28+ Hy3Node* parent = this;
29
30- Debug::log(LOG, "Recursively removing parent nodes of %p", node);
31+ Debug::log(LOG, "Recursively removing parent nodes of %p", parent);
32
33 while (parent->parent != nullptr) {
34 auto* child = parent;
35@@ -240,7 +240,7 @@ Hy3Node* removeFromParentRecursive(Hy3Node* node) {
36 group.lastFocusedChild = group.children.front();
37 }
38
39- if (child != node) {
40+ if (child != this) {
41 parent->layout->nodes.remove(*child);
42 }
43
44@@ -271,7 +271,7 @@ bool Hy3GroupData::hasChild(Hy3Node* node) {
45 return false;
46 }
47
48-void swapNodeData(Hy3Node& a, Hy3Node& b) {
49+void Hy3Node::swapData(Hy3Node& a, Hy3Node& b) {
50 Hy3NodeData aData = std::move(a.data);
51 a.data = b.data;
52 b.data = aData;
53@@ -516,7 +516,7 @@ void Hy3Layout::onWindowRemovedTiling(CWindow* window) {
54 g_pCompositor->setWindowFullscreen(window, false, FULLSCREEN_FULL);
55 }
56
57- auto* parent = removeFromParentRecursive(node);
58+ auto* parent = node->removeFromParentRecursive();
59 this->nodes.remove(*node);
60
61 if (parent != nullptr) {
62@@ -526,7 +526,7 @@ void Hy3Layout::onWindowRemovedTiling(CWindow* window) {
63 && parent->data.as_group.children.front()->data.type == Hy3NodeData::Group)
64 {
65 auto* target_parent = parent;
66- while (target_parent != nullptr && swallowGroup(target_parent)) {
67+ while (target_parent != nullptr && Hy3Node::swallowGroups(target_parent)) {
68 target_parent = target_parent->parent;
69 }
70
71@@ -961,7 +961,7 @@ void Hy3Layout::shiftFocus(CWindow* window, ShiftDirection direction) {
72 if (node == nullptr) return;
73
74 Hy3Node* target;
75- if ((target = shiftOrGetFocus(*node, direction, false))) {
76+ if ((target = Hy3Layout::shiftOrGetFocus(*node, direction, false))) {
77 g_pCompositor->focusWindow(target->data.as_window);
78 }
79 }
80@@ -972,38 +972,14 @@ void Hy3Layout::shiftWindow(CWindow* window, ShiftDirection direction) {
81 if (node == nullptr) return;
82
83
84- shiftOrGetFocus(*node, direction, true);
85-}
86-
87-Hy3Node* findCommonParentNode(Hy3Node& a, Hy3Node& b) {
88- Hy3Node* last_node = nullptr;
89- Hy3Node* searcher = &a;
90-
91- while (searcher != nullptr) {
92- if (searcher->data.type == Hy3NodeData::Group) {
93- for (auto child: searcher->data.as_group.children) {
94- if (last_node == child) continue; // dont rescan already scanned tree
95- if (child == &b) return searcher;
96- if (child->data.type == Hy3NodeData::Group && child->data.as_group.hasChild(&b)) {
97- return searcher;
98- }
99- }
100- }
101-
102- last_node = searcher;
103- searcher = searcher->parent;
104- }
105diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp
106index 301adef8fd254df70acfbd6dcda48feece30851c..7eb2cf00c9b59291fd9cf6afb6c171d52944527e 100644
107--- a/src/Hy3Layout.hpp
108+++ b/src/Hy3Layout.hpp
109@@ -35,8 +35,6 @@ private:
110 friend class Hy3NodeData;
111 };
112
113-void swapNodeData(Hy3Node& a, Hy3Node& b);
114-
115 class Hy3NodeData {
116 public:
117 enum { Group, Window } type;
118@@ -59,8 +57,6 @@ public:
119 Hy3NodeData(const Hy3NodeData&);
120 Hy3NodeData(Hy3NodeData&&);
121 Hy3NodeData& operator=(const Hy3NodeData&);
122-
123- friend void swapNodeData(Hy3Node&, Hy3Node&);
124 };
125
126 struct Hy3Node {
127@@ -77,13 +73,15 @@ struct Hy3Node {
128 std::string debugNode();
129
130 bool operator==(const Hy3Node&) const;
131-};
132
133-// Attempt to swallow a group. returns true if swallowed
134-Hy3Node* swallowGroups(Hy3Node*);
135-// Remove this node from its parent, deleting the parent if it was
136-// the only child and recursing if the parent was the only child of it's parent.
137-Hy3Node* removeFromParentRecursive(Hy3Node*);
138+ // Attempt to swallow a group. returns true if swallowed
139+ static bool swallowGroups(Hy3Node*);
140+ // Remove this node from its parent, deleting the parent if it was
141+ // the only child and recursing if the parent was the only child of it's parent.
142+ Hy3Node* removeFromParentRecursive();
143+
144+ static void swapData(Hy3Node&, Hy3Node&);
145+};
146
147 class Hy3Layout: public IHyprLayout {
148 public:
149@@ -125,5 +123,9 @@ private:
150 Hy3Node* getNodeFromWindow(CWindow*);
151 void applyNodeDataToWindow(Hy3Node*, bool force = false);
152
153+ // if shift is true, shift the window in the given direction, returning nullptr,
154+ // if shift is false, return the window in the given direction or nullptr.
155+ static Hy3Node* shiftOrGetFocus(Hy3Node&, ShiftDirection, bool);
156+
157 friend struct Hy3Node;
158 };