Fix urgent state in tab bars

This commit is contained in:
outfoxxed 2023-06-09 01:19:13 -07:00
parent 4323e901c7
commit 1fa5ce199b
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
3 changed files with 22 additions and 23 deletions

View file

@ -1320,7 +1320,9 @@ void Hy3Layout::replaceWindowDataWith(CWindow* from, CWindow* to) {
std::unique_ptr<HOOK_CALLBACK_FN> renderHookPtr
= std::make_unique<HOOK_CALLBACK_FN>(Hy3Layout::renderHook);
std::unique_ptr<HOOK_CALLBACK_FN> windowTitleHookPtr
= std::make_unique<HOOK_CALLBACK_FN>(Hy3Layout::windowTitleHook);
= std::make_unique<HOOK_CALLBACK_FN>(Hy3Layout::windowGroupUpdateRecursiveHook);
std::unique_ptr<HOOK_CALLBACK_FN> urgentHookPtr
= std::make_unique<HOOK_CALLBACK_FN>(Hy3Layout::windowGroupUrgentHook);
std::unique_ptr<HOOK_CALLBACK_FN> tickHookPtr
= std::make_unique<HOOK_CALLBACK_FN>(Hy3Layout::tickHook);
@ -1334,6 +1336,7 @@ void Hy3Layout::onEnable() {
HyprlandAPI::registerCallbackStatic(PHANDLE, "render", renderHookPtr.get());
HyprlandAPI::registerCallbackStatic(PHANDLE, "windowTitle", windowTitleHookPtr.get());
HyprlandAPI::registerCallbackStatic(PHANDLE, "urgent", urgentHookPtr.get());
HyprlandAPI::registerCallbackStatic(PHANDLE, "tick", tickHookPtr.get());
selection_hook::enable();
}
@ -1341,6 +1344,7 @@ void Hy3Layout::onEnable() {
void Hy3Layout::onDisable() {
HyprlandAPI::unregisterCallback(PHANDLE, renderHookPtr.get());
HyprlandAPI::unregisterCallback(PHANDLE, windowTitleHookPtr.get());
HyprlandAPI::unregisterCallback(PHANDLE, urgentHookPtr.get());
HyprlandAPI::unregisterCallback(PHANDLE, tickHookPtr.get());
selection_hook::disable();
this->nodes.clear();
@ -1744,7 +1748,14 @@ void Hy3Layout::renderHook(void*, std::any data) {
}
}
void Hy3Layout::windowTitleHook(void*, std::any data) {
void Hy3Layout::windowGroupUrgentHook(void* p, std::any data) {
CWindow* window = std::any_cast<CWindow*>(data);
if (window == nullptr) return;
window->m_bIsUrgent = true;
Hy3Layout::windowGroupUpdateRecursiveHook(p, data);
}
void Hy3Layout::windowGroupUpdateRecursiveHook(void*, std::any data) {
CWindow* window = std::any_cast<CWindow*>(data);
if (window == nullptr) return;
auto* node = g_Hy3Layout->getNodeFromWindow(window);

View file

@ -145,7 +145,8 @@ public:
Hy3Node* getWorkspaceFocusedNode(const int&);
static void renderHook(void*, std::any);
static void windowTitleHook(void*, std::any);
static void windowGroupUrgentHook(void*, std::any);
static void windowGroupUpdateRecursiveHook(void*, std::any);
static void tickHook(void*, std::any);
std::list<Hy3Node> nodes;

View file

@ -189,16 +189,11 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) {
cairo_restore(cairo);
// set brush
CColor c;
if (this->focused.fl() > 0.0) {
c = (CColor(*col_active) * this->focused.fl())
+ (CColor(*col_inactive) * (1.0 - this->focused.fl()));
} else if (this->urgent.fl() > 0.0) {
c = (CColor(*col_urgent) * this->urgent.fl())
+ (CColor(*col_inactive) * (1.0 - this->urgent.fl()));
} else {
c = CColor(*col_inactive);
}
auto focused = this->focused.fl();
auto urgent = this->urgent.fl();
auto inactive = 1.0 - (focused + urgent);
auto c = (CColor(*col_active) * focused) + (CColor(*col_urgent) * urgent)
+ (CColor(*col_inactive) * inactive);
cairo_set_source_rgba(cairo, c.r, c.g, c.b, c.a);
@ -239,16 +234,8 @@ void Hy3TabBarEntry::prepareTexture(float scale, wlr_box& box) {
pango_layout_set_width(layout, width * PANGO_SCALE);
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
CColor c;
if (this->focused.fl() > 0.0) {
c = (CColor(*col_text_active) * this->focused.fl())
+ (CColor(*col_text_inactive) * (1.0 - this->focused.fl()));
} else if (this->urgent.fl() > 0.0) {
c = (CColor(*col_text_urgent) * this->urgent.fl())
+ (CColor(*col_text_inactive) * (1.0 - this->urgent.fl()));
} else {
c = CColor(*col_text_inactive);
}
auto c = (CColor(*col_text_active) * focused) + (CColor(*col_text_urgent) * urgent)
+ (CColor(*col_text_inactive) * inactive);
cairo_set_source_rgba(cairo, c.r, c.g, c.b, c.a);