mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-20 03:35:41 +02:00
module/i3: detect 'current' workspace while iterating workspaces
This commit is contained in:
parent
330ad48dfd
commit
d631e47a5e
1 changed files with 16 additions and 34 deletions
48
modules/i3.c
48
modules/i3.c
|
@ -763,6 +763,8 @@ content(struct module *mod)
|
||||||
struct exposable *particles[m->workspaces.count + 1];
|
struct exposable *particles[m->workspaces.count + 1];
|
||||||
|
|
||||||
size_t particle_count = 0;
|
size_t particle_count = 0;
|
||||||
|
struct exposable *current = NULL;
|
||||||
|
|
||||||
for (size_t i = 0; i < m->workspaces.count; i++) {
|
for (size_t i = 0; i < m->workspaces.count; i++) {
|
||||||
const struct workspace *ws = &m->workspaces.v[i];
|
const struct workspace *ws = &m->workspaces.v[i];
|
||||||
const struct ws_content *template = NULL;
|
const struct ws_content *template = NULL;
|
||||||
|
@ -776,11 +778,6 @@ content(struct module *mod)
|
||||||
template = ws_content_for_name(m, "");
|
template = ws_content_for_name(m, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (template == NULL) {
|
|
||||||
LOG_WARN("no ws template for %s, and no default template available", ws->name);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *state =
|
const char *state =
|
||||||
ws->urgent ? "urgent" :
|
ws->urgent ? "urgent" :
|
||||||
ws->visible ? ws->focused ? "focused" : "unfocused" :
|
ws->visible ? ws->focused ? "focused" : "unfocused" :
|
||||||
|
@ -800,40 +797,25 @@ content(struct module *mod)
|
||||||
.count = 7,
|
.count = 7,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (ws->focused) {
|
||||||
|
const struct ws_content *cur = ws_content_for_name(m, "current");
|
||||||
|
current = cur->content->instantiate(cur->content, &tags);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (template == NULL) {
|
||||||
|
LOG_WARN(
|
||||||
|
"no ws template for %s, and no default template available",
|
||||||
|
ws->name);
|
||||||
|
} else {
|
||||||
particles[particle_count++] = template->content->instantiate(
|
particles[particle_count++] = template->content->instantiate(
|
||||||
template->content, &tags);
|
template->content, &tags);
|
||||||
|
}
|
||||||
|
|
||||||
tag_set_destroy(&tags);
|
tag_set_destroy(&tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find currently focused workspace */
|
if (current != NULL)
|
||||||
const struct workspace *ws = NULL;
|
particles[particle_count++] = current;
|
||||||
size_t count = 0;
|
|
||||||
for (size_t i = 0; i < m->workspaces.count; i++) {
|
|
||||||
if (m->workspaces.v[i].focused) {
|
|
||||||
ws = &m->workspaces.v[i];
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(count <= 1);
|
|
||||||
assert(count == 0 || ws != NULL);
|
|
||||||
|
|
||||||
const struct ws_content *template = ws_content_for_name(m, "current");
|
|
||||||
|
|
||||||
if (ws != NULL && template != NULL) {
|
|
||||||
struct tag_set tags = {
|
|
||||||
.tags = (struct tag *[]){
|
|
||||||
tag_new_string(mod, "application", ws->window.application),
|
|
||||||
tag_new_string(mod, "title", ws->window.title),
|
|
||||||
},
|
|
||||||
.count = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
particles[particle_count++] = template->content->instantiate(
|
|
||||||
template->content, &tags);
|
|
||||||
tag_set_destroy(&tags);
|
|
||||||
}
|
|
||||||
|
|
||||||
mtx_unlock(&mod->lock);
|
mtx_unlock(&mod->lock);
|
||||||
return dynlist_exposable_new(
|
return dynlist_exposable_new(
|
||||||
|
|
Loading…
Add table
Reference in a new issue