aboutsummaryrefslogtreecommitdiff
path: root/dwl.c
diff options
context:
space:
mode:
authorLeonardo Hernández Hernández <leohdz172@proton.me>2023-07-13 19:36:26 -0600
committerLeonardo Hernández <leohdz172@proton.me>2023-07-13 22:32:48 -0600
commitca4a97b9335296c40f558baa1ead14578b166d70 (patch)
tree7396cefd006e20a513e916ec21505615da65ce8d /dwl.c
parent76ba2cdab04a952d8cd0503a5f2afc7a18f53538 (diff)
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
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/dwl.c b/dwl.c
index f323d1b..93f66ef 100644
--- a/dwl.c
+++ b/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