aboutsummaryrefslogtreecommitdiff
path: root/swaylock/main.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-10-24 18:54:22 +0200
committerGitHub <noreply@github.com>2018-10-24 18:54:22 +0200
commit41f744c224eb07990c2b202fde14d93c2474f343 (patch)
treefde160e685990c6d749d1ad8fa0cdddb4ee287b2 /swaylock/main.c
parent9658d4bcc564dd7c5c82aa1b8795cccedfaabb70 (diff)
parent9afcda59dba5787817b50a74c254ccb790549e3c (diff)
Merge pull request #2925 from ianyfan/swaylock
swaylock: exit early if unable to get input inhibitor
Diffstat (limited to 'swaylock/main.c')
-rw-r--r--swaylock/main.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/swaylock/main.c b/swaylock/main.c
index f88663c2..9b74b671 100644
--- a/swaylock/main.c
+++ b/swaylock/main.c
@@ -2,6 +2,7 @@
#define _POSIX_C_SOURCE 200112L
#include <assert.h>
#include <ctype.h>
+#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdbool.h>
@@ -844,7 +845,9 @@ static int load_config(char *path, struct swaylock_state *state,
static struct swaylock_state state;
static void display_in(int fd, short mask, void *data) {
- wl_display_dispatch(state.display);
+ if (wl_display_dispatch(state.display) == -1) {
+ state.run_display = false;
+ }
}
int main(int argc, char **argv) {
@@ -928,6 +931,11 @@ int main(int argc, char **argv) {
}
zwlr_input_inhibit_manager_v1_get_inhibitor(state.input_inhibit_manager);
+ if (wl_display_roundtrip(state.display) == -1) {
+ wlr_log(WLR_ERROR, "Exiting - failed to inhibit input:"
+ " is another lockscreen already running?");
+ return 2;
+ }
if (state.zxdg_output_manager) {
struct swaylock_surface *surface;
@@ -959,7 +967,10 @@ int main(int argc, char **argv) {
state.run_display = true;
while (state.run_display) {
- wl_display_flush(state.display);
+ errno = 0;
+ if (wl_display_flush(state.display) == -1 && errno != EAGAIN) {
+ break;
+ }
loop_poll(state.eventloop);
}