aboutsummaryrefslogtreecommitdiff
path: root/swayidle
diff options
context:
space:
mode:
authorIan Fan <ianfan0@gmail.com>2018-11-01 23:57:13 +0000
committeremersion <contact@emersion.fr>2018-11-24 23:10:05 +0100
commit6358de382793a5e28f445c87bb3baf138f4810af (patch)
tree11d31aea58fa68e83fd57b262510a24bb52a10b5 /swayidle
parent6e2dccc2e96a9e7d5ff7da6ad097c0360ece2693 (diff)
swaylock: fix display_event to not block
Diffstat (limited to 'swayidle')
-rw-r--r--swayidle/main.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/swayidle/main.c b/swayidle/main.c
index 4e850c92..2e202ce1 100644
--- a/swayidle/main.c
+++ b/swayidle/main.c
@@ -366,15 +366,22 @@ static int handle_signal(int sig, 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);
}
- 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");
sway_terminate(0);
}
- wl_display_flush(state.display);
- return 0;
+ return count;
}
static void register_idle_timeout(void *item) {