acd07dee93b004b600dab9b5b1c3b54374ad8011

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

Message

Fix expand mode shrink animation

Diff

This diff is truncated to protect this page.

  1diff --git a/flake.lock b/flake.lock
  2index 99cfb40b4149f86034e0046c5a96546b88d49836..af24f17795983eb8e624aaf43596f40dcd429f14 100644
  3--- a/flake.lock
  4+++ b/flake.lock
  5@@ -4,15 +4,16 @@
  6       "inputs": {
  7         "hyprland-protocols": "hyprland-protocols",
  8         "nixpkgs": "nixpkgs",
  9+        "systems": "systems",
 10         "wlroots": "wlroots",
 11         "xdph": "xdph"
 12       },
 13       "locked": {
 14-        "lastModified": 1691612137,
 15-        "narHash": "sha256-7nMCJIZBB2XIjUqAjImoTaZBVIg/0REripGdNsClxlQ=",
 16+        "lastModified": 1692123043,
 17+        "narHash": "sha256-6YoTjAZgtJb9OzKrZxtLxjfYiGWSqMmh1Wyh9dvwXn8=",
 18         "owner": "hyprwm",
 19         "repo": "Hyprland",
 20-        "rev": "126792584fa4eb25f6c8e3b3eb6bfb00b58a787a",
 21+        "rev": "4986d74ef201171a930c312a8e3b72a22d9b84ee",
 22         "type": "github"
 23       },
 24       "original": {
 25@@ -26,14 +27,18 @@
 26         "nixpkgs": [
 27           "hyprland",
 28           "nixpkgs"
 29+        ],
 30+        "systems": [
 31+          "hyprland",
 32+          "systems"
 33         ]
 34       },
 35       "locked": {
 36-        "lastModified": 1684265364,
 37-        "narHash": "sha256-AxNnWbthsuNx73HDQr0eBxrcE3+yfl/WsaXZqUFmkpQ=",
 38+        "lastModified": 1691753796,
 39+        "narHash": "sha256-zOEwiWoXk3j3+EoF3ySUJmberFewWlagvewDRuWYAso=",
 40         "owner": "hyprwm",
 41         "repo": "hyprland-protocols",
 42-        "rev": "8c279b9fb0f2b031427dc5ef4eab53f2ed835530",
 43+        "rev": "0c2ce70625cb30aef199cb388f99e19a61a6ce03",
 44         "type": "github"
 45       },
 46       "original": {
 47@@ -44,11 +49,11 @@
 48     },
 49     "nixpkgs": {
 50       "locked": {
 51-        "lastModified": 1690179384,
 52-        "narHash": "sha256-+arbgqFTAtoeKtepW9wCnA0njCOyoiDFyl0Q0SBSOtE=",
 53+        "lastModified": 1691654369,
 54+        "narHash": "sha256-gSILTEx1jRaJjwZxRlnu3ZwMn1FVNk80qlwiCX8kmpo=",
 55         "owner": "NixOS",
 56         "repo": "nixpkgs",
 57-        "rev": "b12803b6d90e2e583429bb79b859ca53c348b39a",
 58+        "rev": "ce5e4a6ef2e59d89a971bc434ca8ca222b9c7f5e",
 59         "type": "github"
 60       },
 61       "original": {
 62@@ -63,6 +68,21 @@
 63         "hyprland": "hyprland"
 64       }
 65     },
 66+    "systems": {
 67+      "locked": {
 68+        "lastModified": 1689347949,
 69+        "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
 70+        "owner": "nix-systems",
 71+        "repo": "default-linux",
 72+        "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
 73+        "type": "github"
 74+      },
 75+      "original": {
 76+        "owner": "nix-systems",
 77+        "repo": "default-linux",
 78+        "type": "github"
 79+      }
 80+    },
 81     "wlroots": {
 82       "flake": false,
 83       "locked": {
 84@@ -91,14 +111,18 @@
 85         "nixpkgs": [
 86           "hyprland",
 87           "nixpkgs"
 88+        ],
 89+        "systems": [
 90+          "hyprland",
 91+          "systems"
 92         ]
 93       },
 94       "locked": {
 95-        "lastModified": 1691082525,
 96-        "narHash": "sha256-C5AO0KnyAFJaCkOn+5nJfWm0kyiPn/Awh0lKTjhgr7Y=",
 97+        "lastModified": 1691841170,
 98+        "narHash": "sha256-RCTm1/MVWYPnReMgyp7tr2ogGYo/pvw38jZaFwemgPU=",
 99         "owner": "hyprwm",
100         "repo": "xdg-desktop-portal-hyprland",
101-        "rev": "42747d267ab4345c4ceb78cd4a4fe99f072d80fc",
102+        "rev": "57a3a41ba6b358109e4fc25c6a4706b5f7d93c6b",
103         "type": "github"
104       },
105diff --git a/src/Hy3Node.cpp b/src/Hy3Node.cpp
106index 327fac7d97f98bd65703095b23acdfe65dd0fbe1..9e68cc253b3157c7c5a9a8321d0b926e211af6dc 100644
107--- a/src/Hy3Node.cpp
108+++ b/src/Hy3Node.cpp
109@@ -323,26 +323,28 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
110 		g_pHyprRenderer->damageBox(&box);
111 	}
112 
113-	// TODO: fix broken start positions when using hy3:expand, base
114-	if (expand_focused) {
115-		for (auto* child: group->children) {
116-			if (child == group->focused_child) {
117-				child->position = tpos;
118-				child->size = tsize;
119-				child->setHidden(hidden);
120+	for (auto* child: group->children) {
121+		if (expand_focused && child == group->focused_child) {
122+			child->position = tpos;
123+			child->size = tsize;
124+			child->setHidden(hidden);
125 
126-				child->gap_pos_offset = gap_pos_offset;
127-				child->gap_size_offset = gap_size_offset;
128-			} else {
129-				child->setHidden(true);
130-			}
131+			child->gap_pos_offset = gap_pos_offset;
132+			child->gap_size_offset = gap_size_offset;
133 
134 			child->recalcSizePosRecursive(no_animation);
135+
136+			switch (group->layout) {
137+			case Hy3GroupLayout::SplitH: offset += child->size.x; break;
138+			case Hy3GroupLayout::SplitV: offset += child->size.y; break;
139+			case Hy3GroupLayout::Tabbed: break;
140+			}
141+
142+			continue;
143 		}
144-	}
145 
146-	for (auto* child: group->children) {
147 		if (expand_focused && child == group->focused_child) continue;
148+		auto was_hidden = child->hidden;
149 
150 		switch (group->layout) {
151 		case Hy3GroupLayout::SplitH:
152@@ -351,7 +353,8 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
153 			offset += child->size.x;
154 			child->position.y = tpos.y;
155 			child->size.y = tsize.y;
156-			child->setHidden(this->hidden || expand_focused);
157+			child->hidden = this->hidden || expand_focused;
158+			// child->setHidden(this->hidden || expand_focused);
159 
160 			if (group->children.size() == 1) {
161 				child->gap_pos_offset = gap_pos_offset;
162@@ -371,7 +374,7 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
163 				child->gap_size_offset = Vector2D(0, gap_size_offset.y);
164 			}
165 
166-			child->recalcSizePosRecursive(no_animation);
167+			child->recalcSizePosRecursive(no_animation || was_hidden);
168 			break;
169 		case Hy3GroupLayout::SplitV:
170 			child->position.y = tpos.y + offset;
171@@ -379,7 +382,8 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
172 			offset += child->size.y;
173 			child->position.x = tpos.x;
174 			child->size.x = tsize.x;
175-			child->setHidden(this->hidden || expand_focused);
176+			child->hidden = this->hidden || expand_focused;
177+			// child->setHidden(this->hidden || expand_focused);
178 
179 			if (group->children.size() == 1) {
180 				child->gap_pos_offset = gap_pos_offset;
181@@ -399,17 +403,18 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
182 				child->gap_size_offset = Vector2D(gap_size_offset.x, 0);
183 			}
184 
185-			child->recalcSizePosRecursive(no_animation);
186+			child->recalcSizePosRecursive(no_animation || was_hidden);
187 			break;
188 		case Hy3GroupLayout::Tabbed:
189 			child->position = tpos;
190 			child->size = tsize;
191-			child->setHidden(this->hidden || expand_focused || group->focused_child != child);
192+			child->hidden = this->hidden || expand_focused || group->focused_child != child;
193+			// child->setHidden(this->hidden || expand_focused || group->focused_child != child);
194 
195 			child->gap_pos_offset = Vector2D(gap_pos_offset.x, gap_pos_offset.y + tab_height_offset);
196 			child->gap_size_offset = Vector2D(gap_size_offset.x, gap_size_offset.y + tab_height_offset);
197 
198-			child->recalcSizePosRecursive(no_animation);
199+			child->recalcSizePosRecursive(no_animation || was_hidden);
200 			break;
201 		}
202 	}