wlr/taskbar: add homogeneous to evenly distribute button widths
This commit is contained in:
@@ -57,6 +57,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.
|
||||||
|
|
||||||
*on-click*: ++
|
*on-click*: ++
|
||||||
typeof: string ++
|
typeof: string ++
|
||||||
The action which should be triggered when clicking on the application button with the left mouse button.
|
The action which should be triggered when clicking on the application button with the left mouse button.
|
||||||
|
|||||||
@@ -575,6 +575,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);
|
||||||
|
|
||||||
@@ -716,7 +722,14 @@ void Taskbar::handle_finished() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Taskbar::add_button(Gtk::Button &bt) {
|
void Taskbar::add_button(Gtk::Button &bt) {
|
||||||
box_.pack_start(bt, false, false);
|
|
||||||
|
// When homogeneous is enabled, allow children to expand and fill so they divide space equally.
|
||||||
|
const bool homogeneous = (config_["homogeneous"].isBool() && config_["homogeneous"].asBool());
|
||||||
|
box_.pack_start(bt, homogeneous, homogeneous);
|
||||||
|
if (homogeneous) {
|
||||||
|
bt.set_hexpand(true);
|
||||||
|
bt.set_halign(Gtk::ALIGN_FILL);
|
||||||
|
}
|
||||||
box_.get_style_context()->remove_class("empty");
|
box_.get_style_context()->remove_class("empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user