aad4ea397b3d49f1378de5e3e0ea3d562b999cf0

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

Message

Fix gaps

Diff

This diff is truncated to protect this page.

  1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
  2index 2dec836fe3ab9aedfff52965360ae25d4513e851..7f70d69ec395acb3971b92e314fd03fdeaedf817 100644
  3--- a/src/Hy3Layout.cpp
  4+++ b/src/Hy3Layout.cpp
  5@@ -112,8 +112,17 @@ bool Hy3Node::operator==(const Hy3Node& rhs) const {
  6 void Hy3Node::recalcSizePosRecursive(bool force) {
  7 	static const auto* gaps_in = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_in")->intValue;
  8 	static const auto* gaps_out = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_out")->intValue;
  9+
 10+	int outer_gaps = 0;
 11+	if (this->parent == nullptr) {
 12+		outer_gaps = *gaps_out - *gaps_in;
 13+	}
 14+
 15+	auto tpos = this->position + Vector2D(outer_gaps, outer_gaps);
 16+	auto tsize = this->size - Vector2D(outer_gaps * 2, outer_gaps * 2);
 17+
 18 	static const auto* tab_bar_height = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:bar_height")->intValue;
 19-	double tab_height_offset = *gaps_in * 2 + *tab_bar_height;
 20+	double tab_height_offset = *gaps_in + *tab_bar_height;
 21 
 22 	if (this->data.type != Hy3NodeData::Group) {
 23 		this->data.as_window->setHidden(this->hidden);
 24@@ -131,37 +140,24 @@ void Hy3Node::recalcSizePosRecursive(bool force) {
 25 			errorNotif();
 26 		}
 27 
 28-		double distort_out;
 29-		double distort_in;
 30-
 31-		if (gaps_in > gaps_out) {
 32-			distort_out = *gaps_out - 1.0;
 33-		} else {
 34-			distort_out = *gaps_in - 1.0;
 35-		}
 36-
 37-		if (distort_out < 0) distort_out = 0.0;
 38-
 39-		distort_in = *gaps_in * 2;
 40-
 41 		switch (group->layout) {
 42 		case Hy3GroupLayout::SplitH:
 43-			child->position.x = this->position.x - distort_out;
 44-			child->size.x = this->size.x - distort_in;
 45-			child->position.y = this->position.y;
 46-			child->size.y = this->size.y;
 47+			child->position.x = tpos.x;
 48+			child->size.x = tsize.x;
 49+			child->position.y = tpos.y;
 50+			child->size.y = tsize.y;
 51 			break;
 52 		case Hy3GroupLayout::SplitV:
 53-			child->position.y = this->position.y - distort_out;
 54-			child->size.y = this->size.y - distort_in;
 55-			child->position.x = this->position.x;
 56-			child->size.x = this->size.x;
 57+			child->position.y = tpos.y;
 58+			child->size.y = tsize.y;
 59+			child->position.x = tpos.x;
 60+			child->size.x = tsize.x;
 61 			break;
 62 		case Hy3GroupLayout::Tabbed:
 63-			child->position.y = this->position.y + tab_height_offset;
 64-			child->size.y = this->size.y - tab_height_offset;
 65-			child->position.x = this->position.x;
 66-			child->size.x = this->size.x;
 67+			child->position.y = tpos.y + tab_height_offset;
 68+			child->size.y = tsize.y - tab_height_offset;
 69+			child->position.x = tpos.x;
 70+			child->size.x = tsize.x;
 71 			break;
 72 		}
 73 
 74@@ -176,17 +172,16 @@ void Hy3Node::recalcSizePosRecursive(bool force) {
 75 	int constraint;
 76 	switch (group->layout) {
 77 	case Hy3GroupLayout::SplitH:
 78-		constraint = this->size.x;
 79+		constraint = tsize.x;
 80 		break;
 81 	case Hy3GroupLayout::SplitV:
 82-		constraint = this->size.y;
 83+		constraint = tsize.y;
 84 		break;
 85 	case Hy3GroupLayout::Tabbed:
 86 		break;
 87 	}
 88 
 89 	double ratio_mul = group->layout != Hy3GroupLayout::Tabbed ? group->children.empty() ? 0 : constraint / group->children.size() : 0;
 90-
 91 	double offset = 0;
 92 
 93 	if (group->layout == Hy3GroupLayout::Tabbed && group->focused_child != nullptr) {
 94@@ -196,28 +191,28 @@ void Hy3Node::recalcSizePosRecursive(bool force) {
 95 	for(auto* child: group->children) {
 96 		switch (group->layout) {
 97 		case Hy3GroupLayout::SplitH:
 98-			child->position.x = this->position.x + offset;
 99+			child->position.x = tpos.x + offset;
100 			child->size.x = child->size_ratio * ratio_mul;
101 			offset += child->size.x;
102-			child->position.y = this->position.y;
103-			child->size.y = this->size.y;
104+			child->position.y = tpos.y;
105diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp
106index 42012697eddd91923e22cdd85b15138a8d3972fb..6374163838111ecc84f0a91d7be9bf46e669ab5a 100644
107--- a/src/TabGroup.cpp
108+++ b/src/TabGroup.cpp
109@@ -267,10 +267,12 @@ Hy3TabGroup::Hy3TabGroup(Hy3Node& node) {
110 void Hy3TabGroup::updateWithGroup(Hy3Node& node) {
111 	Debug::log(LOG, "updated tab bar for %p", &node);
112 	static const auto* gaps_in = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_in")->intValue;
113+	static const auto* gaps_out = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_out")->intValue;
114 	static const auto* bar_height = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:bar_height")->intValue;
115 
116-	auto tpos = node.position + Vector2D(*gaps_in, *gaps_in);
117-	auto tsize = Vector2D(node.size.x - *gaps_in * 2, *bar_height);
118+	auto gaps = node.parent == nullptr ? *gaps_out : *gaps_in;
119+	auto tpos = node.position + Vector2D(gaps, gaps);
120+	auto tsize = Vector2D(node.size.x - gaps * 2, *bar_height);
121 
122 	this->hidden = node.hidden;
123 	if (this->pos.goalv() != tpos) this->pos = tpos;