mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-19 05:33:44 -04:00
wayland: integrate directly with the FDM
This commit is contained in:
parent
61cc8c3c55
commit
1e75b89552
2 changed files with 23 additions and 17 deletions
16
main.c
16
main.c
|
|
@ -44,20 +44,6 @@
|
||||||
#define min(x, y) ((x) < (y) ? (x) : (y))
|
#define min(x, y) ((x) < (y) ? (x) : (y))
|
||||||
#define max(x, y) ((x) > (y) ? (x) : (y))
|
#define max(x, y) ((x) > (y) ? (x) : (y))
|
||||||
|
|
||||||
static bool
|
|
||||||
fdm_wayl(struct fdm *fdm, int fd, int events, void *data)
|
|
||||||
{
|
|
||||||
struct wayland *wayl = data;
|
|
||||||
int event_count = wl_display_dispatch(wayl->display);
|
|
||||||
|
|
||||||
if (events & EPOLLHUP) {
|
|
||||||
LOG_ERR("disconnected from Wayland");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return event_count != -1 && !wayl->term->quit;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
fdm_ptmx(struct fdm *fdm, int fd, int events, void *data)
|
fdm_ptmx(struct fdm *fdm, int fd, int events, void *data)
|
||||||
{
|
{
|
||||||
|
|
@ -650,7 +636,6 @@ main(int argc, char *const *argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fdm_add(fdm, wl_display_get_fd(term.wl->display), EPOLLIN, &fdm_wayl, term.wl);
|
|
||||||
fdm_add(fdm, term.ptmx, EPOLLIN, &fdm_ptmx, &term);
|
fdm_add(fdm, term.ptmx, EPOLLIN, &fdm_ptmx, &term);
|
||||||
fdm_add(fdm, term.wl->kbd.repeat.fd, EPOLLIN, &fdm_repeat, term.wl);
|
fdm_add(fdm, term.wl->kbd.repeat.fd, EPOLLIN, &fdm_repeat, term.wl);
|
||||||
fdm_add(fdm, term.flash.fd, EPOLLIN, &fdm_flash, &term);
|
fdm_add(fdm, term.flash.fd, EPOLLIN, &fdm_flash, &term);
|
||||||
|
|
@ -669,7 +654,6 @@ main(int argc, char *const *argv)
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (fdm != NULL) {
|
if (fdm != NULL) {
|
||||||
fdm_del(fdm, wl_display_get_fd(term.wl->display));
|
|
||||||
fdm_del(fdm, term.ptmx);
|
fdm_del(fdm, term.ptmx);
|
||||||
fdm_del(fdm, term.wl->kbd.repeat.fd);
|
fdm_del(fdm, term.wl->kbd.repeat.fd);
|
||||||
fdm_del(fdm, term.flash.fd);
|
fdm_del(fdm, term.flash.fd);
|
||||||
|
|
|
||||||
24
wayland.c
24
wayland.c
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/timerfd.h>
|
#include <sys/timerfd.h>
|
||||||
|
#include <sys/epoll.h>
|
||||||
|
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-cursor.h>
|
#include <wayland-cursor.h>
|
||||||
|
|
@ -378,6 +379,20 @@ static const struct wl_registry_listener registry_listener = {
|
||||||
.global_remove = &handle_global_remove,
|
.global_remove = &handle_global_remove,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool
|
||||||
|
fdm_wayl(struct fdm *fdm, int fd, int events, void *data)
|
||||||
|
{
|
||||||
|
struct wayland *wayl = data;
|
||||||
|
int event_count = wl_display_dispatch(wayl->display);
|
||||||
|
|
||||||
|
if (events & EPOLLHUP) {
|
||||||
|
LOG_ERR("disconnected from Wayland");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return event_count != -1 && !wayl->term->quit;
|
||||||
|
}
|
||||||
|
|
||||||
struct wayland *
|
struct wayland *
|
||||||
wayl_init(struct fdm *fdm)
|
wayl_init(struct fdm *fdm)
|
||||||
{
|
{
|
||||||
|
|
@ -476,6 +491,11 @@ wayl_init(struct fdm *fdm)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!fdm_add(fdm, wl_display_get_fd(wayl->display), EPOLLIN, &fdm_wayl, wayl)) {
|
||||||
|
LOG_ERR("failed to register Wayland connection with the FDM");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
return wayl;
|
return wayl;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
@ -553,8 +573,10 @@ wayl_destroy(struct wayland *wayl)
|
||||||
wl_compositor_destroy(wayl->compositor);
|
wl_compositor_destroy(wayl->compositor);
|
||||||
if (wayl->registry != NULL)
|
if (wayl->registry != NULL)
|
||||||
wl_registry_destroy(wayl->registry);
|
wl_registry_destroy(wayl->registry);
|
||||||
if (wayl->display != NULL)
|
if (wayl->display != NULL) {
|
||||||
|
fdm_del(wayl->fdm, wl_display_get_fd(wayl->display));
|
||||||
wl_display_disconnect(wayl->display);
|
wl_display_disconnect(wayl->display);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wl_window *
|
struct wl_window *
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue