021b746d11d5a16737f5c7c290e65e4aff229d73

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

Message

set tab pass bb and blur flags correctly

Diff

This diff is truncated to protect this page.

  1diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp
  2index c82186fdddda44c10e13c163a8591d50405cbac5..1ee60c259ba58993117c0c47ebeac76261a49e5e 100644
  3--- a/src/TabGroup.cpp
  4+++ b/src/TabGroup.cpp
  5@@ -1,4 +1,6 @@
  6 #include "TabGroup.hpp"
  7+#include <optional>
  8+#include <utility>
  9 
 10 #include <GLES2/gl2.h>
 11 #include <cairo/cairo.h>
 12@@ -631,12 +633,8 @@ void Hy3TabGroup::tick() {
 13 	}
 14 }
 15 
 16-void Hy3TabGroup::renderTabBar() {
 17-	static const auto window_rounding = ConfigValue<Hyprlang::INT>("decoration:rounding");
 18-	static const auto enter_from_top = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:from_top");
 19-	static const auto padding = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:padding");
 20-
 21-	PHLMONITORREF monitor = g_pHyprOpenGL->m_RenderData.pMonitor;
 22+std::pair<CBox, CBox> Hy3TabGroup::getRenderBB() const {
 23+	auto* monitor = g_pHyprOpenGL->m_RenderData.pMonitor.get();
 24 	auto scale = monitor->scale;
 25 
 26 	auto monitor_size = monitor->vecSize;
 27@@ -647,14 +645,21 @@ void Hy3TabGroup::renderTabBar() {
 28 		pos = pos + this->workspace->m_vRenderOffset->value();
 29 	}
 30 
 31-	auto scaled_pos = Vector2D(std::round(pos.x * scale), std::round(pos.y * scale));
 32-	auto scaled_size = Vector2D(std::round(size.x * scale), std::round(size.y * scale));
 33-	CBox box = {scaled_pos.x, scaled_pos.y, scaled_size.x, scaled_size.y};
 34+	auto box = CBox(pos, size);
 35+	auto scaledBox = box.copy().scale(scale);
 36 
 37-	// monitor size is not scaled
 38-	if (pos.x > monitor_size.x || pos.y > monitor_size.y || scaled_pos.x + scaled_size.x < 0
 39-	    || scaled_pos.y + scaled_size.y < 0)
 40-		return;
 41+	return std::make_pair(box, scaledBox);
 42+}
 43+
 44+void Hy3TabGroup::renderTabBar() {
 45+	static const auto window_rounding = ConfigValue<Hyprlang::INT>("decoration:rounding");
 46+	static const auto enter_from_top = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:from_top");
 47+	static const auto padding = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:padding");
 48+
 49+	auto [box, scaledBox] = this->getRenderBB();
 50+
 51+	auto* monitor = g_pHyprOpenGL->m_RenderData.pMonitor.get();
 52+	auto scale = monitor->scale;
 53 
 54 	if (!this->bar.damaged) {
 55 		pixman_region32 damage;
 56@@ -663,10 +668,10 @@ void Hy3TabGroup::renderTabBar() {
 57 		pixman_region32_intersect_rect(
 58 		    &damage,
 59 		    g_pHyprOpenGL->m_RenderData.damage.pixman(),
 60-		    box.x,
 61-		    box.y,
 62-		    box.width,
 63-		    box.height
 64+		    scaledBox.x,
 65+		    scaledBox.y,
 66+		    scaledBox.width,
 67+		    scaledBox.height
 68 		);
 69 
 70 		this->bar.damaged = pixman_region32_not_empty(&damage);
 71@@ -676,7 +681,7 @@ void Hy3TabGroup::renderTabBar() {
 72 	if (!this->bar.damaged || this->bar.destroy) return;
 73 	this->bar.damaged = false;
 74 
 75-	this->bar.setSize(scaled_size);
 76+	this->bar.setSize(scaledBox.size());
 77 
 78 	auto render_stencil = this->bar.fade_opacity->isBeingAnimated();
 79 
 80@@ -729,12 +734,12 @@ void Hy3TabGroup::renderTabBar() {
 81 
 82 	auto render_entry = [&](Hy3TabBarEntry& entry) {
 83 		Vector2D entry_pos = {
 84-		    (pos.x + (entry.offset->value() * size.x) + (*padding * 0.5)) * scale,
 85-		    scaled_pos.y
 86-		        + ((entry.vertical_pos->value() * (size.y + *padding) * scale)
 87+		    (box.x + (entry.offset->value() * box.w) + (*padding * 0.5)) * scale,
 88+		    scaledBox.y
 89+		        + ((entry.vertical_pos->value() * (box.h + *padding) * scale)
 90 		           * (*enter_from_top ? -1 : 1)),
 91 		};
 92-		Vector2D entry_size = {((entry.width->value() * size.x) - *padding) * scale, scaled_size.y};
 93+		Vector2D entry_size = {((entry.width->value() * box.w) - *padding) * scale, scaledBox.h};
 94 		if (entry_size.x < 0 || entry_size.y < 0 || fade_opacity == 0.0) return;
 95 
 96 		CBox box = {
 97@@ -769,6 +774,28 @@ void Hy3TabGroup::renderTabBar() {
 98 
 99 void Hy3TabPassElement::draw(const CRegion& damage) { this->group->renderTabBar(); }
100 
101+bool Hy3TabPassElement::needsPrecomputeBlur() {
102+	// clang-format off
103+	static const auto s_opacity = ConfigValue<Hyprlang::FLOAT>("plugin:hy3:tabs:opacity");
104+	static const auto blur = ConfigValue<Hyprlang::INT>("plugin:hy3:tabs:blur");
105diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp
106index b05a43d7fb09ecb1f35046bf8d9f814309f178fc..28c7c043e6a2bb470b12333796d88b889478545a 100644
107--- a/src/TabGroup.hpp
108+++ b/src/TabGroup.hpp
109@@ -1,5 +1,7 @@
110 #pragma once
111 
112+#include <optional>
113+#include <utility>
114 class Hy3TabGroup;
115 class Hy3TabBar;
116 
117@@ -90,10 +92,11 @@ class Hy3TabPassElement: public IPassElement {
118 public:
119 	Hy3TabPassElement(Hy3TabGroup* group): group(group) {}
120 
121+	const char* passName() override { return "Hy3TabPassElement"; }
122 	void draw(const CRegion& damage) override;
123 	bool needsLiveBlur() override { return false; }
124-	bool needsPrecomputeBlur() override { return false; }
125-	const char* passName() override { return "Hy3TabPassElement"; }
126+	bool needsPrecomputeBlur() override;
127+	std::optional<CBox> boundingBox() override;
128 
129 private:
130 	Hy3TabGroup* group;
131@@ -114,6 +117,7 @@ public:
132 	// update tab bar with node position and data. UB if node is not a group.
133 	void updateWithGroup(Hy3Node&, bool warp);
134 	void tick();
135+	std::pair<CBox, CBox> getRenderBB() const;
136 	// render the scaled tab bar on the current monitor.
137 	void renderTabBar();
138