From 50dc6989b84ee8b4c2337a11b3d295208723251a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 1 Dec 2010 16:43:56 -0500 Subject: [PATCH] compositor: Shut down properly so we remove the socket --- compositor/compositor-x11.c | 2 +- compositor/compositor.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/compositor/compositor-x11.c b/compositor/compositor-x11.c index 3f6d842..4cf9bf8 100644 --- a/compositor/compositor-x11.c +++ b/compositor/compositor-x11.c @@ -581,7 +581,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data) client_message = (xcb_client_message_event_t *) event; atom = client_message->data.data32[0]; if (atom == c->atom.wm_delete_window) - exit(1); + wl_display_terminate(c->base.wl_display); break; default: diff --git a/compositor/compositor.c b/compositor/compositor.c index bca2095..28f16dd 100644 --- a/compositor/compositor.c +++ b/compositor/compositor.c @@ -1395,10 +1395,18 @@ wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display) return 0; } +static void on_term_signal(int signal_number, void *data) +{ + struct wlsc_compositor *ec = data; + + wl_display_terminate(ec->wl_display); +} + int main(int argc, char *argv[]) { struct wl_display *display; struct wlsc_compositor *ec; + struct wl_event_loop *loop; GError *error = NULL; GOptionContext *context; int width, height; @@ -1436,6 +1444,10 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } + loop = wl_display_get_event_loop(ec->wl_display); + wl_event_loop_add_signal(loop, SIGTERM, on_term_signal, ec); + wl_event_loop_add_signal(loop, SIGINT, on_term_signal, ec); + wl_display_run(display); wl_display_destroy(display); -- 2.7.4