Merge pull request #4543 from mbroemme/2025-wlr-taskbar-evenly-distribute-buttons

feat(wlr/taskbar): add `homogeneous` option to evenly distribute button widths
This commit is contained in:
Alexis Rouillard
2026-07-04 00:51:24 +02:00
committed by GitHub
2 changed files with 21 additions and 3 deletions
+5
View File
@@ -70,6 +70,11 @@ Addressed by *wlr/taskbar*
default: false ++ default: false ++
If set to true, group tasks by their app_id. Cannot be used with 'active-first'. If set to true, group tasks by their app_id. Cannot be used with 'active-first'.
*homogeneous*: ++
typeof: bool ++
default: false ++
If set to true, distribute every task button evenly across the taskbar's allocated width. Buttons will automatically resize so that 'N' visible tasks each take '1/N' of the width.
*justify*: ++ *justify*: ++
typeof: string ++ typeof: string ++
The alignment of the text within the module's box, allowing options 'left', 'right', or 'center' to define the positioning. The alignment of the text within the module's box, allowing options 'left', 'right', or 'center' to define the positioning.
+16 -3
View File
@@ -635,6 +635,12 @@ Taskbar::Taskbar(const std::string& id, const waybar::Bar& bar, const Json::Valu
box_.get_style_context()->add_class("empty"); box_.get_style_context()->add_class("empty");
event_box_.add(box_); event_box_.add(box_);
// Make task buttons distribute evenly across the available width.
if (config_["homogeneous"].isBool() && config_["homogeneous"].asBool()) {
box_.set_homogeneous(true);
box_.set_hexpand(true);
}
struct wl_display* display = Client::inst()->wl_display; struct wl_display* display = Client::inst()->wl_display;
struct wl_registry* registry = wl_display_get_registry(display); struct wl_registry* registry = wl_display_get_registry(display);
@@ -948,11 +954,18 @@ void Taskbar::handle_workspace_removed(struct ext_workspace_handle_v1* handle) {
} }
void Taskbar::add_button(Gtk::Button& bt) { void Taskbar::add_button(Gtk::Button& bt) {
/* Only let the buttons expand to fill the taskbar when "expand" is enabled /* When "homogeneous" is enabled, let every child expand and fill so the buttons
* and the bar is horizontal (see the Task constructor for details). */ * divide the available width equally. Otherwise, only let the buttons expand to
* fill the taskbar when "expand" is enabled and the bar is horizontal (see the
* Task constructor for details). */
const bool homogeneous = config_["homogeneous"].isBool() && config_["homogeneous"].asBool();
bool expand = config_["expand"].isBool() && config_["expand"].asBool(); bool expand = config_["expand"].isBool() && config_["expand"].asBool();
bool horizontal = bar_.orientation == Gtk::ORIENTATION_HORIZONTAL; bool horizontal = bar_.orientation == Gtk::ORIENTATION_HORIZONTAL;
if (expand && horizontal) { if (homogeneous) {
box_.pack_start(bt, true, true);
bt.set_hexpand(true);
bt.set_halign(Gtk::ALIGN_FILL);
} else if (expand && horizontal) {
box_.pack_start(bt, true, true); box_.pack_start(bt, true, true);
} else { } else {
box_.pack_start(bt, false, false); box_.pack_start(bt, false, false);