mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-19 19:25:41 +02:00
module/river: add support for ‘layout’ events
This commit is contained in:
parent
f75168796a
commit
134ae847dc
4 changed files with 79 additions and 10 deletions
|
@ -13,7 +13,8 @@
|
||||||
## Unreleased
|
## Unreleased
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
* field width tag format option ([#246][246])
|
* Field width tag format option ([#246][246])
|
||||||
|
* river: support for ‘layout’ events.
|
||||||
|
|
||||||
[246]: https://codeberg.org/dnkl/yambar/issues/246
|
[246]: https://codeberg.org/dnkl/yambar/issues/246
|
||||||
|
|
||||||
|
|
|
@ -54,14 +54,16 @@ once for all 32 river tags. This means you probably want to use a
|
||||||
:< *Description*
|
:< *Description*
|
||||||
| seat
|
| seat
|
||||||
: string
|
: string
|
||||||
: The name of the seat (*title* particle only, see CONFIGURATION)
|
: The name of the seat.
|
||||||
| title
|
| title
|
||||||
: string
|
: string
|
||||||
: The seat's focused view's title (*title* particle only, see CONFIGURATION)
|
: The seat's focused view's title.
|
||||||
| mode
|
| mode
|
||||||
: string
|
: string
|
||||||
: The seat's current mode (entered with e.g. *riverctl enter-mode foobar*)
|
: The seat's current mode (entered with e.g. *riverctl enter-mode foobar*).
|
||||||
|
| layout
|
||||||
|
: string
|
||||||
|
: Current layout of the output currently focused by the seat.
|
||||||
|
|
||||||
# CONFIGURATION
|
# CONFIGURATION
|
||||||
|
|
||||||
|
@ -90,7 +92,7 @@ once for all 32 river tags. This means you probably want to use a
|
||||||
bar:
|
bar:
|
||||||
left:
|
left:
|
||||||
- river:
|
- river:
|
||||||
title: {string: { text: "{seat} - {title} ({mode})" }}
|
title: {string: { text: "{seat} - {title} ({layout}/{mode})" }}
|
||||||
content:
|
content:
|
||||||
map:
|
map:
|
||||||
conditions:
|
conditions:
|
||||||
|
|
19
external/river-status-unstable-v1.xml
vendored
19
external/river-status-unstable-v1.xml
vendored
|
@ -16,7 +16,7 @@
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
</copyright>
|
</copyright>
|
||||||
|
|
||||||
<interface name="zriver_status_manager_v1" version="3">
|
<interface name="zriver_status_manager_v1" version="4">
|
||||||
<description summary="manage river status objects">
|
<description summary="manage river status objects">
|
||||||
A global factory for objects that receive status information specific
|
A global factory for objects that receive status information specific
|
||||||
to river. It could be used to implement, for example, a status bar.
|
to river. It could be used to implement, for example, a status bar.
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
</request>
|
</request>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
<interface name="zriver_output_status_v1" version="2">
|
<interface name="zriver_output_status_v1" version="4">
|
||||||
<description summary="track output tags and focus">
|
<description summary="track output tags and focus">
|
||||||
This interface allows clients to receive information about the current
|
This interface allows clients to receive information about the current
|
||||||
windowing state of an output.
|
windowing state of an output.
|
||||||
|
@ -83,6 +83,21 @@
|
||||||
</description>
|
</description>
|
||||||
<arg name="tags" type="uint" summary="32-bit bitfield"/>
|
<arg name="tags" type="uint" summary="32-bit bitfield"/>
|
||||||
</event>
|
</event>
|
||||||
|
|
||||||
|
<event name="layout_name" since="4">
|
||||||
|
<description summary="name of the layout">
|
||||||
|
Sent once on binding the interface should a layout name exist and again
|
||||||
|
whenever the name changes.
|
||||||
|
</description>
|
||||||
|
<arg name="name" type="string" summary="layout name"/>
|
||||||
|
</event>
|
||||||
|
|
||||||
|
<event name="layout_name_clear" since="4">
|
||||||
|
<description summary="name of the layout">
|
||||||
|
Sent when the current layout name has been removed without a new one
|
||||||
|
being set, for example when the active layout generator disconnects.
|
||||||
|
</description>
|
||||||
|
</event>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
<interface name="zriver_seat_status_v1" version="3">
|
<interface name="zriver_seat_status_v1" version="3">
|
||||||
|
|
|
@ -32,6 +32,9 @@ struct output {
|
||||||
uint32_t occupied;
|
uint32_t occupied;
|
||||||
uint32_t focused;
|
uint32_t focused;
|
||||||
uint32_t urgent;
|
uint32_t urgent;
|
||||||
|
|
||||||
|
/* Layout */
|
||||||
|
char *layout;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct seat {
|
struct seat {
|
||||||
|
@ -154,14 +157,19 @@ content(struct module *mod)
|
||||||
size_t i = 32;
|
size_t i = 32;
|
||||||
tll_foreach(m->seats, it) {
|
tll_foreach(m->seats, it) {
|
||||||
const struct seat *seat = &it->item;
|
const struct seat *seat = &it->item;
|
||||||
|
const char *layout =
|
||||||
|
seat->output != NULL && seat->output->layout != NULL
|
||||||
|
? seat->output->layout
|
||||||
|
: "";
|
||||||
|
|
||||||
struct tag_set tags = {
|
struct tag_set tags = {
|
||||||
.tags = (struct tag *[]){
|
.tags = (struct tag *[]){
|
||||||
tag_new_string(mod, "seat", seat->name),
|
tag_new_string(mod, "seat", seat->name),
|
||||||
tag_new_string(mod, "title", seat->title),
|
tag_new_string(mod, "title", seat->title),
|
||||||
tag_new_string(mod, "mode", seat->mode),
|
tag_new_string(mod, "mode", seat->mode),
|
||||||
|
tag_new_string(mod, "layout", layout),
|
||||||
},
|
},
|
||||||
.count = 3,
|
.count = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
tag_parts[i++] = m->title->instantiate(m->title, &tags);
|
tag_parts[i++] = m->title->instantiate(m->title, &tags);
|
||||||
|
@ -193,6 +201,7 @@ output_destroy(struct output *output)
|
||||||
seat->output = NULL;
|
seat->output = NULL;
|
||||||
}
|
}
|
||||||
free(output->name);
|
free(output->name);
|
||||||
|
free(output->layout);
|
||||||
if (output->status != NULL)
|
if (output->status != NULL)
|
||||||
zriver_output_status_v1_destroy(output->status);
|
zriver_output_status_v1_destroy(output->status);
|
||||||
if (output->xdg_output != NULL)
|
if (output->xdg_output != NULL)
|
||||||
|
@ -270,11 +279,53 @@ urgent_tags(void *data, struct zriver_output_status_v1 *zriver_output_status_v1,
|
||||||
mod->bar->refresh(mod->bar);
|
mod->bar->refresh(mod->bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(ZRIVER_OUTPUT_STATUS_V1_LAYOUT_NAME_SINCE_VERSION)
|
||||||
|
static void
|
||||||
|
layout_name(void *data,
|
||||||
|
struct zriver_output_status_v1 *zriver_output_status_v1,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
struct output *output = data;
|
||||||
|
struct module *mod = output->m->mod;
|
||||||
|
|
||||||
|
mtx_lock(&mod->lock);
|
||||||
|
{
|
||||||
|
free(output->layout);
|
||||||
|
output->layout = name != NULL ? strdup(name) : NULL;
|
||||||
|
}
|
||||||
|
mtx_unlock(&mod->lock);
|
||||||
|
mod->bar->refresh(mod->bar);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ZRIVER_OUTPUT_STATUS_V1_LAYOUT_NAME_CLEAR_SINCE_VERSION)
|
||||||
|
static void
|
||||||
|
layout_name_clear(void *data,
|
||||||
|
struct zriver_output_status_v1 *zriver_output_status_v1)
|
||||||
|
{
|
||||||
|
struct output *output = data;
|
||||||
|
struct module *mod = output->m->mod;
|
||||||
|
|
||||||
|
mtx_lock(&mod->lock);
|
||||||
|
{
|
||||||
|
free(output->layout);
|
||||||
|
output->layout = NULL;
|
||||||
|
}
|
||||||
|
mtx_unlock(&mod->lock);
|
||||||
|
mod->bar->refresh(mod->bar);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static const struct zriver_output_status_v1_listener river_status_output_listener = {
|
static const struct zriver_output_status_v1_listener river_status_output_listener = {
|
||||||
.focused_tags = &focused_tags,
|
.focused_tags = &focused_tags,
|
||||||
.view_tags = &view_tags,
|
.view_tags = &view_tags,
|
||||||
.urgent_tags = &urgent_tags,
|
.urgent_tags = &urgent_tags,
|
||||||
|
#if defined(ZRIVER_OUTPUT_STATUS_V1_LAYOUT_NAME_SINCE_VERSION)
|
||||||
|
.layout_name = &layout_name,
|
||||||
|
#endif
|
||||||
|
#if defined(ZRIVER_OUTPUT_STATUS_V1_LAYOUT_NAME_CLEAR_SINCE_VERSION)
|
||||||
|
.layout_name_clear = &layout_name_clear,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -599,7 +650,7 @@ handle_global(void *data, struct wl_registry *registry,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m->status_manager = wl_registry_bind(
|
m->status_manager = wl_registry_bind(
|
||||||
registry, name, &zriver_status_manager_v1_interface, min(version, 3));
|
registry, name, &zriver_status_manager_v1_interface, min(version, 4));
|
||||||
|
|
||||||
mtx_lock(&m->mod->lock);
|
mtx_lock(&m->mod->lock);
|
||||||
tll_foreach(m->outputs, it)
|
tll_foreach(m->outputs, it)
|
||||||
|
|
Loading…
Add table
Reference in a new issue