feat: implement hide vacant for river

This commit is contained in:
twistedlogic
2024-12-11 22:18:00 -04:00
parent e959f1d230
commit 43af1b9ea0
2 changed files with 19 additions and 0 deletions

View File

@ -31,6 +31,11 @@ Addressed by *river/tags*
default: false ++
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
```

View File

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