swaylock: fix display_event to not block

This commit is contained in:
Ian Fan 2018-11-01 23:57:13 +00:00 committed by emersion
parent 6e2dccc2e9
commit 6358de3827
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48

View file

@ -366,15 +366,22 @@ static int handle_signal(int sig, void *data) {
} }
static int display_event(int fd, uint32_t mask, void *data) { static int display_event(int fd, uint32_t mask, void *data) {
if (mask & WL_EVENT_HANGUP) { if ((mask & WL_EVENT_HANGUP) || (mask & WL_EVENT_ERROR)) {
sway_terminate(0); sway_terminate(0);
} }
if (wl_display_dispatch(state.display) < 0) {
int count = 0;
if (mask & WL_EVENT_READABLE) {
count = wl_display_dispatch(state.display);
} else {
count = wl_display_dispatch_pending(state.display);
wl_display_flush(state.display);
}
if (count < 0) {
wlr_log_errno(WLR_ERROR, "wl_display_dispatch failed, exiting"); wlr_log_errno(WLR_ERROR, "wl_display_dispatch failed, exiting");
sway_terminate(0); sway_terminate(0);
} }
wl_display_flush(state.display); return count;
return 0;
} }
static void register_idle_timeout(void *item) { static void register_idle_timeout(void *item) {