mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-04 07:15:29 -04:00
wayland: track multiple terminals
The wayland 'term' member is gone and replaced by a list, 'terms'. This list contains all currently running terminal (windows).
This commit is contained in:
parent
e084bf2b0f
commit
445bbe3469
4 changed files with 26 additions and 15 deletions
12
main.c
12
main.c
|
|
@ -146,20 +146,22 @@ main(int argc, char *const *argv)
|
||||||
if ((term = term_init(&conf, fdm, wayl, argc, argv)) == NULL)
|
if ((term = term_init(&conf, fdm, wayl, argc, argv)) == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
while (true) {
|
while (tll_length(wayl->terms) > 0) {
|
||||||
wl_display_flush(term->wl->display); /* TODO: figure out how to get rid of this */
|
wl_display_flush(wayl->display); /* TODO: figure out how to get rid of this */
|
||||||
|
|
||||||
if (!fdm_poll(fdm))
|
if (!fdm_poll(fdm))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (term->quit)
|
ret = tll_length(wayl->terms) == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
ret = EXIT_SUCCESS;
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
shm_fini();
|
shm_fini();
|
||||||
|
|
||||||
int child_ret = term_destroy(term);
|
int child_ret = EXIT_SUCCESS;
|
||||||
|
tll_foreach(wayl->terms, it)
|
||||||
|
child_ret = term_destroy(it->item);
|
||||||
|
|
||||||
wayl_destroy(wayl);
|
wayl_destroy(wayl);
|
||||||
fdm_destroy(fdm);
|
fdm_destroy(fdm);
|
||||||
config_free(conf);
|
config_free(conf);
|
||||||
|
|
|
||||||
|
|
@ -472,7 +472,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl,
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
wayl->term = term;
|
tll_push_back(wayl->terms, term);
|
||||||
return term;
|
return term;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
|
|
||||||
24
wayland.c
24
wayland.c
|
|
@ -123,8 +123,8 @@ output_scale(void *data, struct wl_output *wl_output, int32_t factor)
|
||||||
|
|
||||||
mon->scale = factor;
|
mon->scale = factor;
|
||||||
|
|
||||||
struct terminal *term = mon->wayl->term;
|
tll_foreach(mon->wayl->terms, it) {
|
||||||
if (term != NULL) {
|
struct terminal *term = it->item;
|
||||||
render_resize(term, term->width / term->scale, term->height / term->scale);
|
render_resize(term, term->width / term->scale, term->height / term->scale);
|
||||||
wayl_reload_cursor_theme(mon->wayl, term);
|
wayl_reload_cursor_theme(mon->wayl, term);
|
||||||
}
|
}
|
||||||
|
|
@ -394,7 +394,7 @@ fdm_wayl(struct fdm *fdm, int fd, int events, void *data)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return event_count != -1 && !wayl->term->quit;
|
return event_count != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
@ -763,14 +763,24 @@ wayl_update_cursor_surface(struct wayland *wayl, struct terminal *term)
|
||||||
struct terminal *
|
struct terminal *
|
||||||
wayl_terminal_from_surface(struct wayland *wayl, struct wl_surface *surface)
|
wayl_terminal_from_surface(struct wayland *wayl, struct wl_surface *surface)
|
||||||
{
|
{
|
||||||
assert(surface == wayl->term->window->surface);
|
tll_foreach(wayl->terms, it) {
|
||||||
return wayl->term;
|
if (it->item->window->surface == surface)
|
||||||
|
return it->item;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(false);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct terminal *
|
struct terminal *
|
||||||
wayl_terminal_from_xdg_toplevel(struct wayland *wayl,
|
wayl_terminal_from_xdg_toplevel(struct wayland *wayl,
|
||||||
struct xdg_toplevel *toplevel)
|
struct xdg_toplevel *toplevel)
|
||||||
{
|
{
|
||||||
assert(toplevel == wayl->term->window->xdg_toplevel);
|
tll_foreach(wayl->terms, it) {
|
||||||
return wayl->term;
|
if (it->item->window->xdg_toplevel == toplevel)
|
||||||
|
return it->item;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(false);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -145,8 +145,7 @@ struct wayland {
|
||||||
bool have_argb8888;
|
bool have_argb8888;
|
||||||
tll(struct monitor) monitors; /* All available outputs */
|
tll(struct monitor) monitors; /* All available outputs */
|
||||||
|
|
||||||
/* TODO: turn into a list to support multiple windows */
|
tll(struct terminal *) terms;
|
||||||
struct terminal *term;
|
|
||||||
struct terminal *focused;
|
struct terminal *focused;
|
||||||
struct terminal *moused;
|
struct terminal *moused;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue