7a7a8c79af81c2044484c1d1fa598ad3e03ba69a

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

Message

Handle "urgent" window state in tab bar

Diff

 1diff --git a/README.md b/README.md
 2index e16db10614442d98e9eff1e08d5d5381a1d8638e..f2fd39a697d6fc5e49c4f460cc7308b11f611d15 100644
 3--- a/README.md
 4+++ b/README.md
 5@@ -55,6 +55,9 @@ plugin {
 6 	  # active tab bar segment color
 7 	  col.active = <color>
 8 
 9+	  # urgent tab bar segment color
10+	  col.urgent = <color>
11+
12 	  # inactive tab bar segment color
13 	  col.inactive = <color>
14 
15diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp
16index 7101a32c193581cbe6275fbdb648511fe4a6305d..3c002a05620c5d4e117d77151b5521e500b1025d 100644
17--- a/src/TabGroup.cpp
18+++ b/src/TabGroup.cpp
19@@ -50,6 +50,7 @@ void Hy3TabBarEntry::setUrgent(bool urgent) {
20 void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) {
21 	static const auto* rounding_setting = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:rounding")->intValue;
22 	static const auto* col_active = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:col.active")->intValue;
23+	static const auto* col_urgent = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:col.urgent")->intValue;
24 	static const auto* col_inactive = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:col.inactive")->intValue;
25 
26 	auto width = box.width;
27@@ -78,14 +79,17 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) {
28 		cairo_restore(cairo);
29 
30 		// set brush
31+		CColor c;
32 		if (this->focused) {
33-			auto c = CColor(*col_active);
34-			cairo_set_source_rgba(cairo, c.r, c.g, c.b, c.a);
35+			c = CColor(*col_active);
36+		} else if (this->urgent) {
37+			c = CColor(*col_urgent);
38 		} else {
39-			auto c = CColor(*col_inactive);
40-			cairo_set_source_rgba(cairo, c.r, c.g, c.b, c.a);
41+			c = CColor(*col_inactive);
42 		}
43 
44+		cairo_set_source_rgba(cairo, c.r, c.g, c.b, c.a);
45+
46 		// outline bar shape
47 		cairo_move_to(cairo, 0, rounding);
48 		cairo_arc(cairo, rounding, rounding, rounding, -180.0 * (M_PI / 180.0), -90.0 * (M_PI / 180.0));
49diff --git a/src/main.cpp b/src/main.cpp
50index 8f5ab4329d2686be6fce250fe611e998bd52ae71..50d4c829a6703e481e0efac9f0f6a709bc7ba95f 100644
51--- a/src/main.cpp
52+++ b/src/main.cpp
53@@ -109,6 +109,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
54 	HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:height", SConfigValue{.intValue = 15});
55 	HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:padding", SConfigValue{.intValue = 5});
56 	HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.active", SConfigValue{.intValue = 0xff32b4ff});
57+	HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.urgent", SConfigValue{.intValue = 0xffff4f4f});
58 	HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.inactive", SConfigValue{.intValue = 0x80808080});
59 	HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:from_top", SConfigValue{.intValue = 0});
60 	HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:rounding", SConfigValue{.intValue = 3});