Merge pull request #421 from emersion/parent-compositor-exit

Terminate on parent compositor exit
This commit is contained in:
Tony Crisci 2017-11-16 06:27:37 -05:00 committed by GitHub
commit 57a355a6a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 7 deletions

View File

@ -12,10 +12,15 @@
#include "backend/wayland.h" #include "backend/wayland.h"
#include "xdg-shell-unstable-v6-client-protocol.h" #include "xdg-shell-unstable-v6-client-protocol.h"
static int dispatch_events(int fd, uint32_t mask, void *data) { static int dispatch_events(int fd, uint32_t mask, void *data) {
struct wlr_wl_backend *backend = data; struct wlr_wl_backend *backend = data;
int count = 0; int count = 0;
if ((mask & WL_EVENT_HANGUP) || (mask & WL_EVENT_ERROR)) {
wl_display_terminate(backend->local_display);
return 0;
}
if (mask & WL_EVENT_READABLE) { if (mask & WL_EVENT_READABLE) {
count = wl_display_dispatch(backend->remote_display); count = wl_display_dispatch(backend->remote_display);
} }
@ -36,7 +41,7 @@ static bool wlr_wl_backend_start(struct wlr_backend *_backend) {
wlr_log(L_INFO, "Initializating wayland backend"); wlr_log(L_INFO, "Initializating wayland backend");
wlr_wl_registry_poll(backend); wlr_wl_registry_poll(backend);
if (!(backend->compositor) || (!(backend->shell))) { if (!backend->compositor || !backend->shell) {
wlr_log_errno(L_ERROR, "Could not obtain retrieve required globals"); wlr_log_errno(L_ERROR, "Could not obtain retrieve required globals");
return false; return false;
} }
@ -49,10 +54,9 @@ static bool wlr_wl_backend_start(struct wlr_backend *_backend) {
struct wl_event_loop *loop = wl_display_get_event_loop(backend->local_display); struct wl_event_loop *loop = wl_display_get_event_loop(backend->local_display);
int fd = wl_display_get_fd(backend->remote_display); int fd = wl_display_get_fd(backend->remote_display);
int events = WL_EVENT_READABLE | WL_EVENT_ERROR | int events = WL_EVENT_READABLE | WL_EVENT_ERROR | WL_EVENT_HANGUP;
WL_EVENT_HANGUP;
backend->remote_display_src = wl_event_loop_add_fd(loop, fd, events, backend->remote_display_src = wl_event_loop_add_fd(loop, fd, events,
dispatch_events, backend); dispatch_events, backend);
wl_event_source_check(backend->remote_display_src); wl_event_source_check(backend->remote_display_src);
return true; return true;

View File

@ -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) { static int x11_event(int fd, uint32_t mask, void *data) {
struct wlr_x11_backend *x11 = 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; xcb_generic_event_t *e;
bool quit = false; bool quit = false;
while (!quit && (e = xcb_poll_for_event(x11->xcb_conn))) { while (!quit && (e = xcb_poll_for_event(x11->xcb_conn))) {
quit = handle_x11_event(x11, e); quit = handle_x11_event(x11, e);
free(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); int fd = xcb_get_file_descriptor(x11->xcb_conn);
struct wl_event_loop *ev = wl_display_get_event_loop(display); 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) { if (!x11->event_source) {
wlr_log(L_ERROR, "Could not create event source"); wlr_log(L_ERROR, "Could not create event source");
goto error_x11; goto error_x11;