c1718d38bc21643de36f0d7de86bca4c39fd639d

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

Message

Fix longstanding fullscreen issues

Fullscreen was implemented via recalculating window bounds
with a fake node when you pressed fullscreen. The check has been moved
into `recalcSizePosRecursive` which causes the override to fire every
time a window's size is recalculated instead of only the first time.

Closes #34, #39

Diff

  1diff --git a/flake.lock b/flake.lock
  2index 2b20f17518f2400e63280634370dcbed7b81c08a..ef5e1264a401a9180cff31b1730483f0ebb1f5c4 100644
  3--- a/flake.lock
  4+++ b/flake.lock
  5@@ -9,11 +9,11 @@
  6         "xdph": "xdph"
  7       },
  8       "locked": {
  9-        "lastModified": 1698018813,
 10-        "narHash": "sha256-JMg+HRyTOZK3W8pRNyJTp7AOWYkbs+LaKqAFc+cScyM=",
 11+        "lastModified": 1698945632,
 12+        "narHash": "sha256-D49t5G6JBDLRZv5nrMoOoC4J611z1S0LQ7RkNImpGI0=",
 13         "owner": "hyprwm",
 14         "repo": "Hyprland",
 15-        "rev": "015664eb4cde5ab93cfacbfd8c2e831eeb876634",
 16+        "rev": "f10996b5753bfc854b019f6889d6bc0c91961e3f",
 17         "type": "github"
 18       },
 19       "original": {
 20@@ -49,11 +49,11 @@
 21     },
 22     "nixpkgs": {
 23       "locked": {
 24-        "lastModified": 1694767346,
 25-        "narHash": "sha256-5uH27SiVFUwsTsqC5rs3kS7pBoNhtoy9QfTP9BmknGk=",
 26+        "lastModified": 1698134075,
 27+        "narHash": "sha256-foCD+nuKzfh49bIoiCBur4+Fx1nozo+4C/6k8BYk4sg=",
 28         "owner": "NixOS",
 29         "repo": "nixpkgs",
 30-        "rev": "ace5093e36ab1e95cb9463863491bee90d5a4183",
 31+        "rev": "8efd5d1e283604f75a808a20e6cde0ef313d07d4",
 32         "type": "github"
 33       },
 34       "original": {
 35@@ -87,18 +87,18 @@
 36       "flake": false,
 37       "locked": {
 38         "host": "gitlab.freedesktop.org",
 39-        "lastModified": 1696410538,
 40-        "narHash": "sha256-ecDhdYLXWHsxMv+EWG36mCNDvzRbu9qfjH7dLxL7aGM=",
 41+        "lastModified": 1697909146,
 42+        "narHash": "sha256-jU0I6FoCKnj4zIBL4daosFWh81U1fM719Z6cae8PxSY=",
 43         "owner": "wlroots",
 44         "repo": "wlroots",
 45-        "rev": "3406c1b17a4a7e6d4e2a7d9c1176affa72bce1bc",
 46+        "rev": "47bf87ade2bd32395615a385ebde1fefbcdf79a2",
 47         "type": "gitlab"
 48       },
 49       "original": {
 50         "host": "gitlab.freedesktop.org",
 51         "owner": "wlroots",
 52         "repo": "wlroots",
 53-        "rev": "3406c1b17a4a7e6d4e2a7d9c1176affa72bce1bc",
 54+        "rev": "47bf87ade2bd32395615a385ebde1fefbcdf79a2",
 55         "type": "gitlab"
 56       }
 57     },
 58@@ -118,11 +118,11 @@
 59         ]
 60       },
 61       "locked": {
 62-        "lastModified": 1694628480,
 63-        "narHash": "sha256-Qg9hstRw0pvjGu5hStkr2UX1D73RYcQ9Ns/KnZMIm9w=",
 64+        "lastModified": 1697981233,
 65+        "narHash": "sha256-y8q4XUwx+gVK7i2eLjfR32lVo7TYvEslyzrmzYEaPZU=",
 66         "owner": "hyprwm",
 67         "repo": "xdg-desktop-portal-hyprland",
 68-        "rev": "8f45a6435069b9e24ebd3160eda736d7a391cbf2",
 69+        "rev": "22e7a65ff9633e1dedfa5317fdffc49f68de2ff2",
 70         "type": "github"
 71       },
 72       "original": {
 73diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
 74index e15d9422c458cf9a6e4d21f3340c917ec9cb9199..eec358a5bc57cbc7ae5ef21f1a61436e32c6b833 100644
 75--- a/src/Hy3Layout.cpp
 76+++ b/src/Hy3Layout.cpp
 77@@ -336,46 +336,6 @@ void Hy3Layout::recalculateMonitor(const int& monitor_id) {
 78 			top_node->recalcSizePosRecursive();
 79 		}
 80 	}
 81-
 82-	if (workspace->m_bHasFullscreenWindow) {
 83-		const auto window = g_pCompositor->getFullscreenWindowOnWorkspace(workspace->m_iID);
 84-
 85-		if (workspace->m_efFullscreenMode == FULLSCREEN_FULL) {
 86-			window->m_vRealPosition = monitor->vecPosition;
 87-			window->m_vRealSize = monitor->vecSize;
 88-		} else {
 89-			// Vaxry's hack from below, but again
 90-
 91-			// clang-format off
 92-			static const auto* gaps_in = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_in")->intValue;
 93-			static const auto* gaps_out = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_out")->intValue;
 94-			// clang-format on
 95-
 96-			int outer_gaps = -(*gaps_in - *gaps_out);
 97-			auto gap_topleft_offset = Vector2D(outer_gaps, outer_gaps);
 98-			auto gap_bottomright_offset = Vector2D(outer_gaps, outer_gaps);
 99-
100-			Hy3Node fakeNode = {
101-			    .data = window,
102-			    .position = monitor->vecPosition + monitor->vecReservedTopLeft,
103-			    .size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight,
104-			    .gap_topleft_offset = gap_topleft_offset,
105-			    .gap_bottomright_offset = gap_bottomright_offset,
106-			    .workspace_id = window->m_iWorkspaceID,
107-			};
108-
109-			this->applyNodeDataToWindow(&fakeNode);
110-		}
111-	} else {
112-		const auto top_node = this->getWorkspaceRootGroup(monitor->activeWorkspace);
113-
114-		if (top_node != nullptr) {
115-			top_node->position = monitor->vecPosition + monitor->vecReservedTopLeft;
116-			top_node->size =
117-			    monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight;
118-			top_node->recalcSizePosRecursive();
119-		}
120-	}
121 }
122 
123 void Hy3Layout::recalculateWindow(CWindow* window) {
124diff --git a/src/Hy3Node.cpp b/src/Hy3Node.cpp
125index f4304de6bf0e1f5e9123dea10dada122c0986b90..33c56637bda1df31169fe70fa4237ee1405f3544 100644
126--- a/src/Hy3Node.cpp
127+++ b/src/Hy3Node.cpp
128@@ -272,6 +272,34 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
129 	static const auto* tab_bar_padding = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:padding")->intValue;
130 	// clang-format on
131 
132+	if (this->data.type == Hy3NodeType::Window && this->data.as_window->m_bIsFullscreen) {
133+		auto* workspace = g_pCompositor->getWorkspaceByID(this->workspace_id);
134+		auto* monitor = g_pCompositor->getMonitorFromID(workspace->m_iMonitorID);
135+
136+		if (workspace->m_efFullscreenMode == FULLSCREEN_FULL) {
137+			this->data.as_window->m_vRealPosition = monitor->vecPosition;
138+			this->data.as_window->m_vRealSize = monitor->vecSize;
139+			return;
140+		}
141+
142+		int outer_gaps = -(*gaps_in - *gaps_out);
143+
144+		auto gap_topleft_offset = Vector2D(outer_gaps, outer_gaps);
145+		auto gap_bottomright_offset = Vector2D(outer_gaps, outer_gaps);
146+
147+		Hy3Node fake_node = {
148+		    .data = this->data.as_window,
149+		    .position = monitor->vecPosition + monitor->vecReservedTopLeft,
150+		    .size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight,
151+		    .gap_topleft_offset = gap_topleft_offset,
152+		    .gap_bottomright_offset = gap_bottomright_offset,
153+		    .workspace_id = this->workspace_id,
154+		};
155+
156+		this->layout->applyNodeDataToWindow(&fake_node);
157+		return;
158+	}
159+
160 	int outer_gaps = 0;
161 	Vector2D gap_topleft_offset;
162 	Vector2D gap_bottomright_offset;
163@@ -290,7 +318,7 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
164 
165 	double tab_height_offset = *tab_bar_height + *tab_bar_padding;
166 
167-	if (this->data.type != Hy3NodeType::Group) {
168+	if (this->data.type == Hy3NodeType::Window) {
169 		this->data.as_window->setHidden(this->hidden);
170 		this->layout->applyNodeDataToWindow(this, no_animation);
171 		return;