mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-03 07:15:29 -04:00
wayland: use a low priority FDM hook to flush the wayland socket
This way, we don't have to manually insert flushes in code paths that may execute outside of a wl_display_dispatch_pending(). (Those that execute inside a wl_display_dispatch_pending() are subject to the flush performed at the end of the normal wayland FDM handler).
This commit is contained in:
parent
6534f64e6a
commit
4cbd894803
2 changed files with 14 additions and 3 deletions
15
wayland.c
15
wayland.c
|
|
@ -556,6 +556,13 @@ static const struct wl_registry_listener registry_listener = {
|
|||
.global_remove = &handle_global_remove,
|
||||
};
|
||||
|
||||
static void
|
||||
fdm_hook(struct fdm *fdm, void *data)
|
||||
{
|
||||
struct wayland *wayl = data;
|
||||
wayl_flush(wayl);
|
||||
}
|
||||
|
||||
static bool
|
||||
fdm_wayl(struct fdm *fdm, int fd, int events, void *data)
|
||||
{
|
||||
|
|
@ -574,7 +581,6 @@ fdm_wayl(struct fdm *fdm, int fd, int events, void *data)
|
|||
return false;
|
||||
}
|
||||
|
||||
wayl_flush(wayl);
|
||||
return event_count != -1;
|
||||
}
|
||||
|
||||
|
|
@ -730,6 +736,11 @@ wayl_init(const struct config *conf, struct fdm *fdm)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (!fdm_hook_add(fdm, &fdm_hook, wayl, FDM_HOOK_PRIORITY_LOW)) {
|
||||
LOG_ERR("failed to add FDM hook");
|
||||
goto out;
|
||||
}
|
||||
|
||||
return wayl;
|
||||
|
||||
out:
|
||||
|
|
@ -755,6 +766,8 @@ wayl_destroy(struct wayland *wayl)
|
|||
|
||||
tll_free(wayl->terms);
|
||||
|
||||
fdm_hook_del(wayl->fdm, &fdm_hook, FDM_HOOK_PRIORITY_LOW);
|
||||
|
||||
if (wayl->kbd.repeat.fd != -1)
|
||||
fdm_del(wayl->fdm, wayl->kbd.repeat.fd);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue