From ba7b9e6244d5f28ffc6220190fec2c7b5548234b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 2 Aug 2021 19:31:01 +0200 Subject: [PATCH] =?UTF-8?q?module/river:=20add=20=E2=80=98per-output?= =?UTF-8?q?=E2=80=99=20attribute?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When set, river tags and seats’ view titles apply to the output yambar is on, only. The default is disabled, which implements the old behavior, where river tags and seats’ view titles represent the union of all outputs. --- CHANGELOG.md | 1 + doc/yambar-modules-river.5.scd | 14 +++++++++---- modules/river.c | 38 +++++++++++++++++++++++++++------- 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9475062..6d27aea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ individually. `border.width` is now a short-hand for setting all four borders to the same value (https://codeberg.org/dnkl/yambar/issues/77). +* river: `per-output: false|true`. ### Changed diff --git a/doc/yambar-modules-river.5.scd b/doc/yambar-modules-river.5.scd index 46607a2..570e8a5 100644 --- a/doc/yambar-modules-river.5.scd +++ b/doc/yambar-modules-river.5.scd @@ -12,8 +12,8 @@ about the river tags. It has an interface similar to the i3/sway module. The configuration for the river module specifies one _title_ particle, -which will be instantiated with tags representing the currently active -seat and the currently focused view's title. +which will be instantiated once for each seat, with tags representing +the seats' name and the title of the seats' currently focused view. It also specifies a _content_ template particle, which is instantiated once for all 32 river tags. This means you probably want to use a @@ -41,10 +41,10 @@ once for all 32 river tags. This means you probably want to use a : Set to *focused* if _focused_ is true, *unfocused* if _visible_ is true, but _focused_ is false, or *invisible* if the river tag is not visible on any monitors. | seat : string -: The name of the currently active seat (*title* particle only, see CONFIGURATION) +: The name of the seat (*title* particle only, see CONFIGURATION) | title : string -: The focused view's title (*title* particle only, see CONFIGURATION) +: The seat's focused view's title (*title* particle only, see CONFIGURATION) # CONFIGURATION @@ -60,6 +60,12 @@ once for all 32 river tags. This means you probably want to use a : particle : yes : Template particle that will be instantiated once for all of the 32 river tags. +| per-output +: bool +: no +: When set to false (the default), tags reflect the union of all + outputs. When set to true, tags reflect river tags and seats for + the output yambar is on only. # EXAMPLES diff --git a/modules/river.c b/modules/river.c index 0cdab38..9b494f3 100644 --- a/modules/river.c +++ b/modules/river.c @@ -48,6 +48,7 @@ struct private { struct zriver_status_manager_v1 *status_manager; struct particle *template; struct particle *title; + bool per_output; bool is_starting_up; tll(struct output) outputs; @@ -76,6 +77,8 @@ content(struct module *mod) { const struct private *m = mod->private; + const char *output_bar_is_on = mod->bar->output_name(mod->bar); + mtx_lock(&m->mod->lock); uint32_t output_focused = 0; @@ -85,6 +88,13 @@ content(struct module *mod) tll_foreach(m->outputs, it) { const struct output *output = &it->item; + if (m->per_output && + output_bar_is_on != NULL && output->name != NULL && + strcmp(output->name, output_bar_is_on) != 0) + { + continue; + } + output_focused |= output->focused; occupied |= output->occupied; @@ -348,7 +358,6 @@ unfocused_output(void *data, struct zriver_seat_status_v1 *zriver_seat_status_v1 mtx_lock(&mod->lock); { - struct output *output = NULL; tll_foreach(m->outputs, it) { if (it->item.wl_output == wl_output) { @@ -382,13 +391,21 @@ focused_view(void *data, struct zriver_seat_status_v1 *zriver_seat_status_v1, LOG_DBG("seat: %s: focused view: %s", seat->name, title); - mtx_lock(&mod->lock); + const char *output_bar_is_on = mod->bar->output_name(mod->bar); + + if (!seat->m->per_output || + (output_bar_is_on != NULL && + seat->output != NULL && seat->output->name != NULL && + strcmp(output_bar_is_on, seat->output->name) == 0)) { - free(seat->title); - seat->title = title != NULL ? strdup(title) : NULL; + mtx_lock(&mod->lock); + { + free(seat->title); + seat->title = title != NULL ? strdup(title) : NULL; + } + mtx_unlock(&mod->lock); + mod->bar->refresh(mod->bar); } - mtx_unlock(&mod->lock); - mod->bar->refresh(mod->bar); } static const struct zriver_seat_status_v1_listener river_seat_status_listener = { @@ -646,11 +663,12 @@ out: } static struct module * -river_new(struct particle *template, struct particle *title) +river_new(struct particle *template, struct particle *title, bool per_output) { struct private *m = calloc(1, sizeof(*m)); m->template = template; m->title = title; + m->per_output = per_output; m->is_starting_up = true; struct module *mod = module_common_new(); @@ -668,9 +686,12 @@ from_conf(const struct yml_node *node, struct conf_inherit inherited) { const struct yml_node *c = yml_get_value(node, "content"); const struct yml_node *title = yml_get_value(node, "title"); + const struct yml_node *per_output = yml_get_value(node, "per-output"); + return river_new( conf_to_particle(c, inherited), - title != NULL ? conf_to_particle(title, inherited) : NULL); + title != NULL ? conf_to_particle(title, inherited) : NULL, + per_output != NULL ? yml_value_as_bool(per_output) : false); } static bool @@ -678,6 +699,7 @@ verify_conf(keychain_t *chain, const struct yml_node *node) { static const struct attr_info attrs[] = { {"title", false, &conf_verify_particle}, + {"per-output", false, &conf_verify_bool}, MODULE_COMMON_ATTRS, };