Merge pull request #3823 from thetwistedlogic/feature/river-hide-vacant

Hide vacant tags config option on River
This commit is contained in:
Alexis Rouillard
2025-01-12 11:32:45 +01:00
committed by GitHub
2 changed files with 35 additions and 0 deletions

View File

@ -31,6 +31,11 @@ Addressed by *river/tags*
default: false ++ default: false ++
Enables this module to consume all left over space dynamically. Enables this module to consume all left over space dynamically.
*hide-vacant*: ++
typeof: bool ++
default: false ++
Only show relevant tags: tags that are either focused or have a window on them.
# EXAMPLE # EXAMPLE
``` ```

View File

@ -189,10 +189,20 @@ bool Tags::handle_button_press(GdkEventButton *event_button, uint32_t tag) {
} }
void Tags::handle_focused_tags(uint32_t tags) { void Tags::handle_focused_tags(uint32_t tags) {
auto hide_vacant = config_["hide-vacant"].asBool();
for (size_t i = 0; i < buttons_.size(); ++i) { for (size_t i = 0; i < buttons_.size(); ++i) {
bool visible = buttons_[i].is_visible();
bool occupied = buttons_[i].get_style_context()->has_class("occupied");
bool urgent = buttons_[i].get_style_context()->has_class("urgent");
if ((1 << i) & tags) { if ((1 << i) & tags) {
if (hide_vacant && !visible) {
buttons_[i].set_visible(true);
}
buttons_[i].get_style_context()->add_class("focused"); buttons_[i].get_style_context()->add_class("focused");
} else { } else {
if (hide_vacant && !(occupied || urgent)) {
buttons_[i].set_visible(false);
}
buttons_[i].get_style_context()->remove_class("focused"); buttons_[i].get_style_context()->remove_class("focused");
} }
} }
@ -205,20 +215,40 @@ void Tags::handle_view_tags(struct wl_array *view_tags) {
for (; view_tag < end; ++view_tag) { for (; view_tag < end; ++view_tag) {
tags |= *view_tag; tags |= *view_tag;
} }
auto hide_vacant = config_["hide-vacant"].asBool();
for (size_t i = 0; i < buttons_.size(); ++i) { for (size_t i = 0; i < buttons_.size(); ++i) {
bool visible = buttons_[i].is_visible();
bool focused = buttons_[i].get_style_context()->has_class("focused");
bool urgent = buttons_[i].get_style_context()->has_class("urgent");
if ((1 << i) & tags) { if ((1 << i) & tags) {
if (hide_vacant && !visible) {
buttons_[i].set_visible(true);
}
buttons_[i].get_style_context()->add_class("occupied"); buttons_[i].get_style_context()->add_class("occupied");
} else { } else {
if (hide_vacant && !(focused || urgent)) {
buttons_[i].set_visible(false);
}
buttons_[i].get_style_context()->remove_class("occupied"); buttons_[i].get_style_context()->remove_class("occupied");
} }
} }
} }
void Tags::handle_urgent_tags(uint32_t tags) { void Tags::handle_urgent_tags(uint32_t tags) {
auto hide_vacant = config_["hide-vacant"].asBool();
for (size_t i = 0; i < buttons_.size(); ++i) { for (size_t i = 0; i < buttons_.size(); ++i) {
bool visible = buttons_[i].is_visible();
bool occupied = buttons_[i].get_style_context()->has_class("occupied");
bool focused = buttons_[i].get_style_context()->has_class("focused");
if ((1 << i) & tags) { if ((1 << i) & tags) {
if (hide_vacant && !visible) {
buttons_[i].set_visible(true);
}
buttons_[i].get_style_context()->add_class("urgent"); buttons_[i].get_style_context()->add_class("urgent");
} else { } else {
if (hide_vacant && !(occupied || focused)) {
buttons_[i].set_visible(false);
}
buttons_[i].get_style_context()->remove_class("urgent"); buttons_[i].get_style_context()->remove_class("urgent");
} }
} }