commit 1da0ef1

Michael Forney  ·  2016-02-09 17:27:42 +0000 UTC
parent 4926291
xserver: Handle xwayland client destroy

If the xwayland client process dies or quits, libwayland-server will
automatically destroy the client. When this happens, make sure not to
try to destroy it again.

Fixes michaelforney/velox#19.
1 files changed,  +12, -1
+12, -1
 1@@ -196,6 +196,15 @@ handle_usr1(int signal_number, void *data)
 2 	return 0;
 3 }
 4 
 5+static void
 6+handle_client_destroy(struct wl_listener *listener, void *data) {
 7+	swc_xserver.client = NULL;
 8+}
 9+
10+static struct wl_listener client_destroy_listener = {
11+	.notify = handle_client_destroy,
12+};
13+
14 bool
15 xserver_initialize(void)
16 {
17@@ -229,6 +238,7 @@ xserver_initialize(void)
18 	if (!(swc_xserver.client = wl_client_create(swc.display, wl[0])))
19 		goto error4;
20 
21+	wl_client_add_destroy_listener(swc_xserver.client, &client_destroy_listener);
22 	xserver.wm_fd = wm[0];
23 
24 	/* Start the X server */
25@@ -304,6 +314,7 @@ xserver_finalize(void)
26 {
27 	if (xserver.xwm_initialized)
28 		xwm_finalize();
29+	if (swc_xserver.client)
30+		wl_client_destroy(swc_xserver.client);
31 	close_display();
32-	wl_client_destroy(swc_xserver.client);
33 }