34846efb8ff520663be5d7a55acc95a3e3f13f87

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

Message

Fix incorrect space allocation when breaking groups

Caused extra padding at the end of a group and windows getting clipped
off the edge of the monitor.

Diff

 1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
 2index 9d8b4bd579286ed5bccde0bab59b59328f29836a..193cb34c44c53887804bd53ac8127f0171795cdb 100644
 3--- a/src/Hy3Layout.cpp
 4+++ b/src/Hy3Layout.cpp
 5@@ -339,7 +339,12 @@ Hy3Node* Hy3Node::removeFromParentRecursive() {
 6 		}
 7 
 8 		if (!group.children.empty()) {
 9-			auto splitmod = -((1.0 - child->size_ratio) / group.children.size());
10+			auto child_count = group.children.size();
11+			if (std::find(group.children.begin(), group.children.end(), this) != group.children.end()) {
12+				child_count -= 1;
13+			}
14+
15+			auto splitmod = -((1.0 - child->size_ratio) / child_count);
16 
17 			for (auto* child: group.children) {
18 				child->size_ratio += splitmod;
19@@ -1363,7 +1368,8 @@ std::string Hy3Node::debugNode() {
20 		buf << std::hex << this;
21 		buf << ") [hypr ";
22 		buf << this->data.as_window;
23-		buf << "]";
24+		buf << "] size ratio: ";
25+		buf << this->size_ratio;
26 		break;
27 	case Hy3NodeData::Group:
28 		buf << "group(";
29@@ -1382,13 +1388,18 @@ std::string Hy3Node::debugNode() {
30 			break;
31 		}
32 
33-		buf << "]";
34+		buf << "] size ratio: ";
35+		buf << this->size_ratio;
36 		for (auto* child: this->data.as_group.children) {
37 			buf << "\n|-";
38-			// this is terrible
39-			for (char c: child->debugNode()) {
40-				buf << c;
41-				if (c == '\n') buf << "  ";
42+			if (child == nullptr) {
43+				buf << "nullptr";
44+			} else {
45+				// this is terrible
46+				for (char c: child->debugNode()) {
47+					buf << c;
48+					if (c == '\n') buf << "  ";
49+				}
50 			}
51 		}
52