From 7a7a8c79af81c2044484c1d1fa598ad3e03ba69a Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sat, 3 Jun 2023 02:00:50 -0700 Subject: [PATCH] Handle "urgent" window state in tab bar --- README.md | 3 +++ src/TabGroup.cpp | 12 ++++++++---- src/main.cpp | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e16db10..f2fd39a 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,9 @@ plugin { # active tab bar segment color col.active = + # urgent tab bar segment color + col.urgent = + # inactive tab bar segment color col.inactive = diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 7101a32..3c002a0 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -50,6 +50,7 @@ void Hy3TabBarEntry::setUrgent(bool urgent) { void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) { static const auto* rounding_setting = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:rounding")->intValue; static const auto* col_active = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:col.active")->intValue; + static const auto* col_urgent = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:col.urgent")->intValue; static const auto* col_inactive = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:col.inactive")->intValue; auto width = box.width; @@ -78,14 +79,17 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) { cairo_restore(cairo); // set brush + CColor c; if (this->focused) { - auto c = CColor(*col_active); - cairo_set_source_rgba(cairo, c.r, c.g, c.b, c.a); + c = CColor(*col_active); + } else if (this->urgent) { + c = CColor(*col_urgent); } else { - auto c = CColor(*col_inactive); - cairo_set_source_rgba(cairo, c.r, c.g, c.b, c.a); + c = CColor(*col_inactive); } + cairo_set_source_rgba(cairo, c.r, c.g, c.b, c.a); + // outline bar shape cairo_move_to(cairo, 0, rounding); cairo_arc(cairo, rounding, rounding, rounding, -180.0 * (M_PI / 180.0), -90.0 * (M_PI / 180.0)); diff --git a/src/main.cpp b/src/main.cpp index 8f5ab43..50d4c82 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -109,6 +109,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:height", SConfigValue{.intValue = 15}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:padding", SConfigValue{.intValue = 5}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.active", SConfigValue{.intValue = 0xff32b4ff}); + HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.urgent", SConfigValue{.intValue = 0xffff4f4f}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:col.inactive", SConfigValue{.intValue = 0x80808080}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:from_top", SConfigValue{.intValue = 0}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:rounding", SConfigValue{.intValue = 3});