aboutsummaryrefslogtreecommitdiff
path: root/backend/x11/backend.c
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-11-16 06:27:37 -0500
committerGitHub <noreply@github.com>2017-11-16 06:27:37 -0500
commit57a355a6a778c1b23de8728f407b10cc2e481758 (patch)
treed5c14929f792c33f4f0a069f345600213c7f10f0 /backend/x11/backend.c
parentac78c6642a1c742c896f08282ee31c4f0d3acd51 (diff)
parent7d847efe403c01a842a3e237b49249c95372d9de (diff)
Merge pull request #421 from emersion/parent-compositor-exit
Terminate on parent compositor exit
Diffstat (limited to 'backend/x11/backend.c')
-rw-r--r--backend/x11/backend.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index 97b0dd8c..b798daf6 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -155,9 +155,14 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e
static int x11_event(int fd, uint32_t mask, void *data) {
struct wlr_x11_backend *x11 = data;
+
+ if ((mask & WL_EVENT_HANGUP) || (mask & WL_EVENT_ERROR)) {
+ wl_display_terminate(x11->wl_display);
+ return 0;
+ }
+
xcb_generic_event_t *e;
bool quit = false;
-
while (!quit && (e = xcb_poll_for_event(x11->xcb_conn))) {
quit = handle_x11_event(x11, e);
free(e);
@@ -205,7 +210,8 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
int fd = xcb_get_file_descriptor(x11->xcb_conn);
struct wl_event_loop *ev = wl_display_get_event_loop(display);
- x11->event_source = wl_event_loop_add_fd(ev, fd, WL_EVENT_READABLE, x11_event, x11);
+ int events = WL_EVENT_READABLE | WL_EVENT_ERROR | WL_EVENT_HANGUP;
+ x11->event_source = wl_event_loop_add_fd(ev, fd, events, x11_event, x11);
if (!x11->event_source) {
wlr_log(L_ERROR, "Could not create event source");
goto error_x11;