do not use wl_event_loop for signal handling
ΔSLOC: -4 Fixes: https://github.com/djpohly/dwl/issues/456 Fixes: https://github.com/djpohly/dwl/issues/459
This commit is contained in:
parent
76ba2cdab0
commit
ca4a97b933
1 changed files with 10 additions and 13 deletions
23
dwl.c
23
dwl.c
|
@ -260,7 +260,7 @@ static void focusmon(const Arg *arg);
|
|||
static void focusstack(const Arg *arg);
|
||||
static Client *focustop(Monitor *m);
|
||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||
static int handlesig(int signo, void *data);
|
||||
static void handlesig(int signo);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void inputdevice(struct wl_listener *listener, void *data);
|
||||
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
||||
|
@ -326,8 +326,6 @@ static pid_t child_pid = -1;
|
|||
static int locked;
|
||||
static void *exclusive_focus;
|
||||
static struct wl_display *dpy;
|
||||
static struct wl_event_loop *eventloop;
|
||||
static struct wl_event_source *sighandler[4];
|
||||
static struct wlr_backend *backend;
|
||||
static struct wlr_scene *scene;
|
||||
static struct wlr_scene_tree *layers[NUM_LAYERS];
|
||||
|
@ -654,7 +652,6 @@ checkidleinhibitor(struct wlr_surface *exclude)
|
|||
void
|
||||
cleanup(void)
|
||||
{
|
||||
int i;
|
||||
#ifdef XWAYLAND
|
||||
wlr_xwayland_destroy(xwayland);
|
||||
#endif
|
||||
|
@ -671,8 +668,6 @@ cleanup(void)
|
|||
wlr_cursor_destroy(cursor);
|
||||
wlr_output_layout_destroy(output_layout);
|
||||
wlr_seat_destroy(seat);
|
||||
for (i = 0; i < LENGTH(sighandler); i++)
|
||||
wl_event_source_remove(sighandler[i]);
|
||||
wl_display_destroy(dpy);
|
||||
}
|
||||
|
||||
|
@ -826,7 +821,8 @@ createkeyboard(struct wlr_keyboard *keyboard)
|
|||
|
||||
wlr_seat_set_keyboard(seat, keyboard);
|
||||
|
||||
kb->key_repeat_source = wl_event_loop_add_timer(eventloop, keyrepeat, kb);
|
||||
kb->key_repeat_source = wl_event_loop_add_timer(
|
||||
wl_display_get_event_loop(dpy), keyrepeat, kb);
|
||||
|
||||
/* And add the keyboard to our list of keyboards */
|
||||
wl_list_insert(&keyboards, &kb->link);
|
||||
|
@ -1338,8 +1334,8 @@ fullscreennotify(struct wl_listener *listener, void *data)
|
|||
setfullscreen(c, client_wants_fullscreen(c));
|
||||
}
|
||||
|
||||
int
|
||||
handlesig(int signo, void *data)
|
||||
void
|
||||
handlesig(int signo)
|
||||
{
|
||||
if (signo == SIGCHLD) {
|
||||
#ifdef XWAYLAND
|
||||
|
@ -1357,7 +1353,6 @@ handlesig(int signo, void *data)
|
|||
} else if (signo == SIGINT || signo == SIGTERM) {
|
||||
quit(NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2143,13 +2138,15 @@ void
|
|||
setup(void)
|
||||
{
|
||||
int i, sig[] = {SIGCHLD, SIGINT, SIGTERM, SIGPIPE};
|
||||
struct sigaction sa = {.sa_flags = SA_RESTART, .sa_handler = handlesig};
|
||||
sigemptyset(&sa.sa_mask);
|
||||
|
||||
for (i = 0; i < LENGTH(sig); i++)
|
||||
sigaction(sig[i], &sa, NULL);
|
||||
|
||||
/* The Wayland display is managed by libwayland. It handles accepting
|
||||
* clients from the Unix socket, manging Wayland globals, and so on. */
|
||||
dpy = wl_display_create();
|
||||
eventloop = wl_display_get_event_loop(dpy);
|
||||
for (i = 0; i < LENGTH(sighandler); i++)
|
||||
sighandler[i] = wl_event_loop_add_signal(eventloop, sig[i], handlesig, NULL);
|
||||
|
||||
/* The backend is a wlroots feature which abstracts the underlying input and
|
||||
* output hardware. The autocreate option will choose the most suitable
|
||||
|
|
Loading…
Reference in a new issue