88b0c3a68c6efd1e2c420208b3464ace70008a6f

Author
outfoxxed <outfoxxed@outfoxxed.me>
Committer
outfoxxed <outfoxxed@outfoxxed.me>
Date

Message

Merge branch 'master' into tabs

Diff

This diff is truncated to protect this page.

  1diff --git a/README.md b/README.md
  2index 66a11467a3388fc82168f7291bdc11c4ffcb2597..ecf3278a5c287012f9a07840cc08a7db567ab651 100644
  3--- a/README.md
  4+++ b/README.md
  5@@ -31,6 +31,16 @@ In your hyprland config replace the following dispatchers:
  6 
  7 You can use `hy3:makegroup` to create a new split.
  8 
  9+### Config fields
 10+```conf
 11+plugin {
 12+  hy3 {
 13+    # disable gaps when only one window is onscreen
 14+    no_gaps_when_only = <bool>
 15+  }
 16+}
 17+```
 18+
 19 ### Dispatcher list
 20  - `hy3:makegroup, <h | v | opposite>` - make a vertical or horizontal split
 21  - `hy3:movefocus, <l | u | d | r | left | down | up | right>` - move the focus left, up, down, or right
 22diff --git a/flake.lock b/flake.lock
 23index 2764e8b3b414f521f602bc6b50ca932b84b46451..a52171dd0949b2329b2635d9184de86bf20a9f84 100644
 24--- a/flake.lock
 25+++ b/flake.lock
 26@@ -8,11 +8,11 @@
 27         "xdph": "xdph"
 28       },
 29       "locked": {
 30-        "lastModified": 1684167111,
 31-        "narHash": "sha256-0JKyr8WOpcXJP5XaLnUSI7e1d7N5Rcpyf72+N4ZEtjo=",
 32+        "lastModified": 1685105343,
 33+        "narHash": "sha256-ypXKGzTQWJqbHHrPnSHLo4b2vNtfOFyh6sDdNPi7/WQ=",
 34         "owner": "hyprwm",
 35         "repo": "Hyprland",
 36-        "rev": "5b84b0fb445bc4485510bba516c84141aaeafd04",
 37+        "rev": "5f4659afef5856c509d53957e62b7f6c38d39f41",
 38         "type": "github"
 39       },
 40       "original": {
 41diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
 42index 358013abd66f1c2394ad7f15f897f2d914a0e44a..38f828ab76256a2be461aeda50dd2a5f31ef0e81 100644
 43--- a/src/Hy3Layout.cpp
 44+++ b/src/Hy3Layout.cpp
 45@@ -5,6 +5,8 @@
 46 #include <hyprland/src/Compositor.hpp>
 47 #include <hyprland/src/plugins/PluginAPI.hpp>
 48 
 49+#include <sstream>
 50+
 51 void errorNotif() {
 52 	HyprlandAPI::addNotificationV2(PHANDLE, {
 53 		{"text", "Something has gone very wrong. Check the log for details."},
 54@@ -192,7 +194,7 @@ void Hy3Node::recalcSizePosRecursive(bool force) {
 55 			child->size.y = this->size.y - tab_height_offset;
 56 			child->position.x = this->position.x;
 57 			child->size.x = this->size.x;
 58-			//child->setHidden(group->lastFocusedChild != child);
 59+			//child->setHidden(group->focused_child != child);
 60 			break;
 61 		}
 62 
 63@@ -244,10 +246,10 @@ std::string Hy3Node::getTitle() {
 64 			break;
 65 		}
 66 
 67-		if (this->data.as_group.lastFocusedChild == nullptr) {
 68+		if (this->data.as_group.focused_child == nullptr) {
 69 			title += "Group";
 70 		} else {
 71-			title += this->data.as_group.lastFocusedChild->getTitle();
 72+			title += this->data.as_group.focused_child->getTitle();
 73 		}
 74 
 75 		return title;
 76@@ -266,11 +268,13 @@ void Hy3Node::markFocused() {
 77 
 78 	// update focus
 79 	if (this->data.type == Hy3NodeData::Group) {
 80-		this->data.as_group.lastFocusedChild = nullptr;
 81+		this->data.as_group.group_focused = true;
 82+		this->data.as_group.focused_child = nullptr;
 83 	}
 84 
 85 	while (node->parent != nullptr) {
 86-		node->parent->data.as_group.lastFocusedChild = node;
 87+		node->parent->data.as_group.focused_child = node;
 88+		node->parent->data.as_group.group_focused = false;
 89 		node = node->parent;
 90 	}
 91 
 92@@ -311,10 +315,10 @@ Hy3Node* Hy3Node::getFocusedNode() {
 93 	case Hy3NodeData::Window:
 94 		return this;
 95 	case Hy3NodeData::Group:
 96-		if (this->data.as_group.lastFocusedChild == nullptr) {
 97+		if (this->data.as_group.focused_child == nullptr || this->data.as_group.group_focused) {
 98 			return this;
 99 		} else {
100-			return this->data.as_group.lastFocusedChild->getFocusedNode();
101+			return this->data.as_group.focused_child->getFocusedNode();
102 		}
103 	}
104 }
105@@ -362,10 +366,11 @@ Hy3Node* Hy3Node::removeFromParentRecursive() {
106 		if (group.children.size() > 2) {
107 			auto iter = std::find(group.children.begin(), group.children.end(), child);
108 
109+			group.group_focused = false;
110 			if (iter == group.children.begin()) {
111-				group.lastFocusedChild = *std::next(iter);
112+				group.focused_child = *std::next(iter);
113 			} else {
114-				group.lastFocusedChild = *std::prev(iter);
115+				group.focused_child = *std::prev(iter);
116 			}
117 		}
118 
119@@ -375,8 +380,9 @@ Hy3Node* Hy3Node::removeFromParentRecursive() {
120 			return nullptr;
121 		}
122 
123+		group.group_focused = false;
124 		if (group.children.size() == 1) {
125-			group.lastFocusedChild = group.children.front();
126+			group.focused_child = group.children.front();
127 		}
128 
129 		auto child_size_ratio = child->size_ratio;
130@@ -418,7 +424,8 @@ Hy3Node* Hy3Node::intoGroup(Hy3GroupLayout layout) {
131 
132 	this->data = layout;
133 	this->data.as_group.children.push_back(node);
134-	this->data.as_group.lastFocusedChild = node;
135+	this->data.as_group.group_focused = false;
136+	this->data.as_group.focused_child = node;
137 	this->recalcSizePosRecursive();
138 
139 	return node;
140@@ -533,10 +540,10 @@ void Hy3Layout::applyNodeDataToWindow(Hy3Node* node, bool force) {
141 	const bool display_top    = STICKS(node->position.y, monitor->vecPosition.y + monitor->vecReservedTopLeft.y);
142 	const bool display_bottom = STICKS(node->position.y + node->size.y, monitor->vecPosition.y + monitor->vecSize.y - monitor->vecReservedBottomRight.y);
143 
144-	const auto* border_size = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
145diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp
146index 8e044d284c56b9dcfe2d2a5c7b9bf76f81a9c009..f4377a87a4454846d539b6513aac1d9c148bd20f 100644
147--- a/src/Hy3Layout.hpp
148+++ b/src/Hy3Layout.hpp
149@@ -25,7 +25,8 @@ enum class ShiftDirection {
150 struct Hy3GroupData {
151 	Hy3GroupLayout layout = Hy3GroupLayout::SplitH;
152 	std::list<Hy3Node*> children;
153-	Hy3Node* lastFocusedChild = nullptr;
154+	bool group_focused = true;
155+	Hy3Node* focused_child = nullptr;
156 	std::unique_ptr<Hy3TabGroup> tab_bar;
157 
158 	bool hasChild(Hy3Node* child);
159diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp
160index b04ce91cc38adebfa069ee8d9328b5f0ad5aafe6..aaa0b9c1ef265189c611f79044d1f1b73cdeef52 100644
161--- a/src/TabGroup.cpp
162+++ b/src/TabGroup.cpp
163@@ -84,7 +84,7 @@ void Hy3TabBar::updateNodeList(std::list<Hy3Node*>& nodes) {
164 				this->entries.splice(std::next(entry), removed_entries, moved);
165 				entry = moved;
166 			} else {
167-				entry = this->entries.insert(std::next(entry), Hy3TabBarEntry(*this, **node));
168+				entry = this->entries.emplace(std::next(entry), *this, **node);
169 			}
170 		}
171 
172@@ -222,8 +222,8 @@ void Hy3TabGroup::updateWithGroup(Hy3Node& node) {
173 
174 	this->bar.updateNodeList(node.data.as_group.children);
175 
176-	if (node.data.as_group.lastFocusedChild != nullptr) {
177-		this->updateStencilWindows(*node.data.as_group.lastFocusedChild);
178+	if (node.data.as_group.focused_child != nullptr) {
179+		this->updateStencilWindows(*node.data.as_group.focused_child);
180 	}
181 }
182