c35adfa3620a88484fafbbe37dc4d99b19319308

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

Message

fixup: chase hyprland render context changes

Diff

This diff is truncated to protect this page.

  1diff --git a/flake.lock b/flake.lock
  2index 893d38c030400a5820e38a4dcf368bb537cbe3bf..4fa615f81e3a1b11fd62e91b01225d8f71a7d22a 100644
  3--- a/flake.lock
  4+++ b/flake.lock
  5@@ -20,11 +20,11 @@
  6         ]
  7       },
  8       "locked": {
  9-        "lastModified": 1788444081,
 10-        "narHash": "sha256-I8i97p9WBQaZQyyBaHFMt8e01VfgfFZSaO+vAUd0u0A=",
 11+        "lastModified": 1791041429,
 12+        "narHash": "sha256-Y/Q4JtMo6nHB6XS1LPSfK7Y4AnuNl9jci/5sCps1MRc=",
 13         "owner": "hyprwm",
 14         "repo": "aquamarine",
 15-        "rev": "36b66db4ddd708ad19f5db850af6a478d8a19b2a",
 16+        "rev": "52ea11f06dd492f34b3cc0b39a9c805beecafcff",
 17         "type": "github"
 18       },
 19       "original": {
 20@@ -93,6 +93,38 @@
 21           "systems"
 22         ]
 23       },
 24+      "locked": {
 25+        "lastModified": 1791066858,
 26+        "narHash": "sha256-hLh6ALHrGpgYm8viWCo1pO+ErC22YDGdAvVPcfYsXA8=",
 27+        "owner": "hyprwm",
 28+        "repo": "hyprgraphics",
 29+        "rev": "80c7d00f2236732853e390019ff8d79d17fa3612",
 30+        "type": "github"
 31+      },
 32+      "original": {
 33+        "owner": "hyprwm",
 34+        "repo": "hyprgraphics",
 35+        "type": "github"
 36+      }
 37+    },
 38+    "hyprgraphics_2": {
 39+      "inputs": {
 40+        "hyprutils": [
 41+          "hyprland",
 42+          "xdph",
 43+          "hyprutils"
 44+        ],
 45+        "nixpkgs": [
 46+          "hyprland",
 47+          "xdph",
 48+          "nixpkgs"
 49+        ],
 50+        "systems": [
 51+          "hyprland",
 52+          "xdph",
 53+          "systems"
 54+        ]
 55+      },
 56       "locked": {
 57         "lastModified": 1786464367,
 58         "narHash": "sha256-k58p4wbzIXWyRWrW84pP8tD+iaZSSYiiM+fr0Auk4oU=",
 59@@ -115,6 +147,7 @@
 60         "hyprland-guiutils": "hyprland-guiutils",
 61         "hyprland-protocols": "hyprland-protocols",
 62         "hyprlang": "hyprlang",
 63+        "hyprtoolkit": "hyprtoolkit",
 64         "hyprutils": "hyprutils",
 65         "hyprwayland-scanner": "hyprwayland-scanner",
 66         "hyprwire": "hyprwire",
 67@@ -124,17 +157,17 @@
 68         "xdph": "xdph"
 69       },
 70       "locked": {
 71-        "lastModified": 1788962582,
 72-        "narHash": "sha256-o4ZJYn3xlt2YUayObZfC5cV9ZtlcCfJjfvk648nub6Q=",
 73+        "lastModified": 1791545463,
 74+        "narHash": "sha256-EuTde/DbLBZ0nm8Ctj4Il3M5SKsWAKeDITvUuatu5+g=",
 75         "owner": "hyprwm",
 76         "repo": "hyprland",
 77-        "rev": "e9e2f64ccfd53c5e0729f8266608c937bffebf7c",
 78+        "rev": "663b29b846e4bad17cfa29941f6d2fbb6b61f139",
 79         "type": "github"
 80       },
 81       "original": {
 82         "owner": "hyprwm",
 83         "repo": "hyprland",
 84-        "rev": "e9e2f64ccfd53c5e0729f8266608c937bffebf7c",
 85+        "rev": "663b29b846e4bad17cfa29941f6d2fbb6b61f139",
 86         "type": "github"
 87       }
 88     },
 89@@ -152,7 +185,10 @@
 90           "hyprland",
 91           "hyprlang"
 92         ],
 93-        "hyprtoolkit": "hyprtoolkit",
 94+        "hyprtoolkit": [
 95+          "hyprland",
 96+          "hyprtoolkit"
 97+        ],
 98         "hyprutils": [
 99           "hyprland",
100           "hyprutils"
101@@ -196,11 +232,11 @@
102         ]
103       },
104       "locked": {
105diff --git a/flake.nix b/flake.nix
106index 17ee421f44ba395053114f46dcb3b472ee2b924c..8333134703478b032bcd6bbbd48347d3613e9c42 100644
107--- a/flake.nix
108+++ b/flake.nix
109@@ -1,6 +1,6 @@
110 {
111   inputs = {
112-    hyprland.url = "github:hyprwm/hyprland/e9e2f64ccfd53c5e0729f8266608c937bffebf7c";
113+    hyprland.url = "github:hyprwm/hyprland/663b29b846e4bad17cfa29941f6d2fbb6b61f139";
114   };
115 
116   outputs = {
117diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp
118index 447222bee39f1252ad62974eeb1fcea8c4d50e0e..617fb5425894af93e8d2d5c1bb05bc15a551ac78 100644
119--- a/src/TabGroup.cpp
120+++ b/src/TabGroup.cpp
121@@ -29,6 +29,7 @@
122 #include "log.hpp"
123 #include "globals.hpp"
124 #include "render.hpp"
125+#include "render/Context.hpp"
126 #include "render/Renderer.hpp"
127 #include "render/pass/PassElement.hpp"
128 
129@@ -185,7 +186,7 @@ bool Hy3TabBarEntry::shouldRemove() {
130 	return this->destroying && (this->vertical_pos->value() == 1.0 || this->width->value() == 0.0);
131 }
132 
133-void Hy3TabBarEntry::render(float scale, CBox& box, float opacity_mul) {
134+void Hy3TabBarEntry::render(Render::CRenderContext& ctx, float scale, CBox& box, float opacity_mul) {
135 	auto opacity = opacity_mul * this->fade_opacity->value();
136 
137 	// clang-format off
138@@ -224,9 +225,10 @@ void Hy3TabBarEntry::render(float scale, CBox& box, float opacity_mul) {
139 	box.round();
140 
141 	// sometimes enabled before our renderer is called
142-	Render::GL::g_pHyprOpenGL->scissor(nullptr);
143+	Render::GL::g_pHyprOpenGL->scissor(ctx, nullptr);
144 
145 	Hy3Render::renderTab(
146+	    ctx,
147 	    box,
148 	    opacity * *s_opacity,
149 	    *blur,
150@@ -236,10 +238,10 @@ void Hy3TabBarEntry::render(float scale, CBox& box, float opacity_mul) {
151 	    radius
152 	);
153 
154-	this->renderText(scale, box, opacity);
155+	this->renderText(ctx, scale, box, opacity);
156 }
157 
158-void Hy3TabBarEntry::renderText(float scale, CBox& box, float opacity) {
159+void Hy3TabBarEntry::renderText(Render::CRenderContext& ctx, float scale, CBox& box, float opacity) {
160 	// clang-format off
161 	static const auto render_text = CConfigValue<Config::INTEGER>("plugin:hy3:tabs:render_text");
162 	static const auto text_center = CConfigValue<Config::INTEGER>("plugin:hy3:tabs:text_center");
163@@ -366,7 +368,7 @@ void Hy3TabBarEntry::renderText(float scale, CBox& box, float opacity) {
164 	glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_SRC_ALPHA);
165 	glBlendColor(c.r, c.g, c.b, c.a);
166 
167-	Render::GL::g_pHyprOpenGL->renderTexture(this->texture, texture_box, { .a = opacity });
168+	Render::GL::g_pHyprOpenGL->renderTexture(ctx, this->texture, texture_box, { .a = opacity });
169 
170 	glBlendColor(1, 1, 1, 1);
171 	glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
172@@ -724,8 +726,8 @@ void Hy3TabGroup::tick() {
173 	}
174 }
175 
176-std::pair<CBox, CBox> Hy3TabGroup::getRenderBB() const {
177-	auto* monitor = g_pHyprRenderer->m_renderData.pMonitor.get();
178+std::pair<CBox, CBox> Hy3TabGroup::getRenderBB(Render::CRenderContext& ctx) const {
179+	auto* monitor = ctx.m_data.pMonitor.get();
180 	auto scale = monitor->m_scale;
181 
182 	auto pos = this->pos->value() - monitor->m_position;
183@@ -741,14 +743,14 @@ std::pair<CBox, CBox> Hy3TabGroup::getRenderBB() const {
184 	return std::make_pair(box, scaledBox);
185 }
186 
187-void Hy3TabGroup::renderTabBar() {
188+void Hy3TabGroup::renderTabBar(Render::CRenderContext& ctx) {
189 	static const auto window_rounding = CConfigValue<Config::INTEGER>("decoration:rounding");
190 	static const auto enter_from_top = CConfigValue<Config::INTEGER>("plugin:hy3:tabs:from_top");
191 	static const auto padding = CConfigValue<Config::INTEGER>("plugin:hy3:tabs:padding");
192 
193-	auto [box, scaledBox] = this->getRenderBB();
194+	auto [box, scaledBox] = this->getRenderBB(ctx);
195 
196-	auto* monitor = g_pHyprRenderer->m_renderData.pMonitor.get();
197+	auto* monitor = ctx.m_data.pMonitor.get();
198 	auto scale = monitor->m_scale;
199 
200 	if (!this->bar.damaged) {
201@@ -757,7 +759,7 @@ void Hy3TabGroup::renderTabBar() {
202 
203 		pixman_region32_intersect_rect(
204 		    &damage,
205-		    g_pHyprRenderer->m_renderData.damage.pixman(),
206+		    ctx.m_data.damage.pixman(),
207 		    scaledBox.x,
208 		    scaledBox.y,
209 		    scaledBox.width,
210@@ -785,7 +787,7 @@ void Hy3TabGroup::renderTabBar() {
211 	}
212 
213 	if (render_stencil) {
214-		g_pHyprRenderer->m_renderData.currentFB->bind();
215+		ctx.m_data.currentFB->bind();
216 		glEnable(GL_STENCIL_TEST);
217 		glStencilMask(0xff);
218 		glClearStencil(0);
219@@ -812,7 +814,7 @@ void Hy3TabGroup::renderTabBar() {
220 			window_box.scale(scale);
221diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp
222index be3d794f6e459ae73c6d18dabcaa69c01aefb84b..cfc8dbdb9548a355a949017ebbcb614d803f40ed 100644
223--- a/src/TabGroup.hpp
224+++ b/src/TabGroup.hpp
225@@ -78,10 +78,10 @@ struct Hy3TabBarEntry {
226 	void beginDestroy();
227 	void unDestroy();
228 	bool shouldRemove();
229-	void render(float scale, CBox& box, float opacity_mul);
230+	void render(Render::CRenderContext& ctx, float scale, CBox& box, float opacity_mul);
231 
232 private:
233-	void renderText(float scale, CBox& box, float opacity);
234+	void renderText(Render::CRenderContext& ctx, float scale, CBox& box, float opacity);
235 	CHyprColor mergeColors(
236 	    const CHyprColor& active,
237 	    const CHyprColor& focused,
238@@ -126,11 +126,11 @@ public:
239 	Hy3TabPassElement(Hy3TabGroup* group): group(group) {}
240 
241 	const char* passName() override { return "Hy3TabPassElement"; }
242-	std::vector<UP<IPassElement>> draw() override;
243-	bool needsLiveBlur() override { return false; }
244+	std::vector<UP<IPassElement>> draw(Render::CRenderContext& ctx) override;
245+	bool needsLiveBlur(Render::CRenderContext& ctx) override { return false; }
246 	ePassElementType type() override { return EK_CUSTOM; }
247-	bool needsPrecomputeBlur() override;
248-	std::optional<CBox> boundingBox() override;
249+	bool needsPrecomputeBlur(Render::CRenderContext& ctx) override;
250+	std::optional<CBox> boundingBox(Render::CRenderContext& ctx) override;
251 
252 private:
253 	Hy3TabGroup* group;
254@@ -155,9 +155,9 @@ public:
255 	// update tab bar with node position and data. UB if node is not a group.
256 	void updateWithGroup(Hy3Node&, bool warp);
257 	void tick();
258-	std::pair<CBox, CBox> getRenderBB() const;
259+	std::pair<CBox, CBox> getRenderBB(Render::CRenderContext& ctx) const;
260 	// render the scaled tab bar on the current monitor.
261-	void renderTabBar();
262+	void renderTabBar(Render::CRenderContext& ctx);
263 
264 private:
265 	std::vector<PHLWINDOWREF> stencil_windows;
266diff --git a/src/main.cpp b/src/main.cpp
267index 288e70a8a5c2c0c8bd5634719b6276cae9aca276..91fd96a0198a446bb0a6a39c1f8d2ec9ca4caf91 100644
268--- a/src/main.cpp
269+++ b/src/main.cpp
270@@ -84,27 +84,27 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
271 		return makeUnique<Hy3Layout>();
272 	});
273 
274-	g_renderListener = Event::bus()->m_events.render.stage.listen([](eRenderStage stage) {
275+	g_renderListener = Event::bus()->m_events.render.stage.listen([](const Event::SRenderStageEvent& event) {
276 		static bool rendering_normally = false;
277 		static std::vector<Hy3TabGroup*> rendered_groups;
278 
279-		switch (stage) {
280+		switch (event.stage) {
281 		case RENDER_PRE_WINDOWS:
282 			rendering_normally = true;
283 			rendered_groups.clear();
284 			break;
285 		case RENDER_POST_WINDOW:
286-			if (!rendering_normally) break;
287+			if (!rendering_normally || !event.context) break;
288 
289 			for (auto& wp: g_tabGroups) {
290 				auto* entry = wp.get();
291 				if (!entry) continue;
292 				if (!entry->hidden
293-				    && entry->target_window == g_pHyprRenderer->m_renderData.currentWindow.lock()
294+				    && entry->target_window == event.context->get().m_data.currentWindow.lock()
295 				    && std::find(rendered_groups.begin(), rendered_groups.end(), entry)
296 				           == rendered_groups.end())
297 				{
298-					g_pHyprRenderer->m_renderPass.add(makeUnique<Hy3TabPassElement>(entry));
299+					g_pHyprRenderer->addPassElement(event.context->get(), makeUnique<Hy3TabPassElement>(entry));
300 					rendered_groups.push_back(entry);
301 				}
302 			}
303diff --git a/src/render.cpp b/src/render.cpp
304index b507605820473b053a4b5786a6a0101657e6b5d0..0d77e47e3629b1135a67140d43078c9eb76c4f09 100644
305--- a/src/render.cpp
306+++ b/src/render.cpp
307@@ -8,6 +8,7 @@
308 #include <hyprutils/math/Misc.hpp>
309 #include <hyprutils/math/Vector2D.hpp>
310 
311+#include "render/Context.hpp"
312 #include "render/Renderer.hpp"
313 #include "render/Texture.hpp"
314 #include "shaders.hpp"
315@@ -16,6 +17,7 @@ using Render::GL::g_pHyprOpenGL;
316 using Hyprutils::Math::CBox;
317 
318 void Hy3Render::renderTab(
319+    Render::CRenderContext& ctx,
320     const CBox& box,
321     float opacity,
322     bool blur,
323@@ -25,7 +27,7 @@ void Hy3Render::renderTab(
324     int radius
325 ) {
326 	static auto& shader = Hy3Shaders::instance()->tab;
327-	auto& rdata = g_pHyprRenderer->m_renderData;
328+	auto& rdata = ctx.m_data;
329 
330 	auto rbox = box;
331 	rdata.renderModif.applyToBox(rbox);
332@@ -33,7 +35,7 @@ void Hy3Render::renderTab(
333 	const auto& monitorSize = rdata.pMonitor->m_transformedSize;
334 	auto monitorBox = CBox {Vector2D(), monitorSize};
335 
336-	auto glMatrix = g_pHyprRenderer->projectBoxToTarget(monitorBox, Hyprutils::Math::HYPRUTILS_TRANSFORM_NORMAL);
337+	auto glMatrix = g_pHyprRenderer->projectBoxToTarget(ctx, monitorBox, Hyprutils::Math::HYPRUTILS_TRANSFORM_NORMAL);
338 
339 	g_pHyprOpenGL->useShader(shader.program);
340 
341@@ -47,7 +49,7 @@ void Hy3Render::renderTab(
342 	WP<Render::ITexture> blurTex;
343 
344 	if (blur) {
345-		blurTex = rdata.pMonitor->resources()->m_blurFB->getTexture();
346+		blurTex = g_pHyprRenderer->getBlurTexture(ctx);
347 		if (!blurTex) blur = false;
348 	}
349 
350diff --git a/src/render.hpp b/src/render.hpp
351index be387202246cc0e429d49c2dcaaf1f439ee5eca6..5950a78fdf0b2398aa3402f1796c5a6c8331dbda 100644
352--- a/src/render.hpp
353+++ b/src/render.hpp
354@@ -2,9 +2,14 @@
355 #include <hyprland/src/helpers/Color.hpp>
356 #include <hyprutils/math/Box.hpp>
357 
358+namespace Render {
359+class CRenderContext;
360+}
361+
362 class Hy3Render {
363 public:
364 	static void renderTab(
365+	    Render::CRenderContext& ctx,
366 	    const Hyprutils::Math::CBox& box,
367 	    float opacity,
368 	    bool blur,