Merge pull request #5017 from nonamescm/add-static-river-tag-classes

River/tags: Add static CSS classes for all available tags.
This commit is contained in:
Alexis Rouillard
2026-07-04 00:14:54 +02:00
committed by GitHub
3 changed files with 9 additions and 7 deletions
+3 -3
View File
@@ -20,8 +20,8 @@ class Tags : public waybar::AModule {
void handle_focused_tags(uint32_t tags); void handle_focused_tags(uint32_t tags);
void handle_view_tags(struct wl_array* tags); void handle_view_tags(struct wl_array* tags);
void handle_urgent_tags(uint32_t tags); void handle_urgent_tags(uint32_t tags);
void handle_focused_output(struct wl_output *output); void handle_focused_output(struct wl_output* output);
void handle_unfocused_output(struct wl_output *output); void handle_unfocused_output(struct wl_output* output);
void handle_show(); void handle_show();
void handle_primary_clicked(uint32_t tag); void handle_primary_clicked(uint32_t tag);
@@ -33,7 +33,7 @@ class Tags : public waybar::AModule {
private: private:
const waybar::Bar& bar_; const waybar::Bar& bar_;
struct wl_output *output_; // stores the output this module belongs to struct wl_output* output_; // stores the output this module belongs to
Gtk::Box box_; Gtk::Box box_;
std::vector<Gtk::Button> buttons_; std::vector<Gtk::Button> buttons_;
struct zriver_output_status_v1* output_status_; struct zriver_output_status_v1* output_status_;
+1
View File
@@ -59,6 +59,7 @@ Addressed by *river/tags*
- *#tags button.focused* - *#tags button.focused*
- *#tags button.urgent* - *#tags button.urgent*
- *#tags button.output* - *#tags button.output*
- *#tags button.tag-N*
Note that occupied/focused/urgent/output status may overlap. That is, a tag may be Note that occupied/focused/urgent/output status may overlap. That is, a tag may be
both occupied and focused at the same time. both occupied and focused at the same time.
+5 -4
View File
@@ -35,12 +35,12 @@ static const zriver_output_status_v1_listener output_status_listener_impl{
static void listen_focused_output(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1, static void listen_focused_output(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1,
struct wl_output* output) { struct wl_output* output) {
static_cast<Tags *>(data)->handle_focused_output(output); static_cast<Tags*>(data)->handle_focused_output(output);
} }
static void listen_unfocused_output(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1, static void listen_unfocused_output(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1,
struct wl_output* output) { struct wl_output* output) {
static_cast<Tags *>(data)->handle_unfocused_output(output); static_cast<Tags*>(data)->handle_unfocused_output(output);
} }
static void listen_focused_view(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1, static void listen_focused_view(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1,
@@ -183,6 +183,7 @@ Tags::Tags(const std::string& id, const waybar::Bar& bar, const Json::Value& con
button.signal_button_press_event().connect( button.signal_button_press_event().connect(
sigc::bind(sigc::mem_fun(*this, &Tags::handle_button_press), (1 << tag))); sigc::bind(sigc::mem_fun(*this, &Tags::handle_button_press), (1 << tag)));
} }
button.get_style_context()->add_class("tag-" + std::to_string(tag + 1));
button.show(); button.show();
} }
@@ -306,7 +307,7 @@ void Tags::handle_urgent_tags(uint32_t tags) {
} }
} }
void Tags::handle_focused_output(struct wl_output *output) { void Tags::handle_focused_output(struct wl_output* output) {
if (output_ == output) { if (output_ == output) {
for (size_t i = 0; i < buttons_.size(); ++i) { for (size_t i = 0; i < buttons_.size(); ++i) {
buttons_[i].get_style_context()->add_class("output"); buttons_[i].get_style_context()->add_class("output");
@@ -314,7 +315,7 @@ void Tags::handle_focused_output(struct wl_output *output) {
} }
} }
void Tags::handle_unfocused_output(struct wl_output *output) { void Tags::handle_unfocused_output(struct wl_output* output) {
if (output_ == output) { if (output_ == output) {
for (size_t i = 0; i < buttons_.size(); ++i) { for (size_t i = 0; i < buttons_.size(); ++i) {
buttons_[i].get_style_context()->remove_class("output"); buttons_[i].get_style_context()->remove_class("output");