summaryrefslogtreecommitdiff
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
commit28e5138fad79774d8d432012b9b5afa2fefe6dba (patch)
tree82e13ab801da2a4858b59d8e42b0760af60055c7
parentd7ffed8b49689a3be55d390346e7d12e94e47677 (diff)
parent274179a804e67e0f191312350c52c10778c6e5c7 (diff)
Merge pull request #2925 from ianyfan/swaylock
swaylock: exit early if unable to get input inhibitor
-rw-r--r--main.c15
-rw-r--r--password.c6
2 files changed, 18 insertions, 3 deletions
diff --git a/main.c b/main.c
index f88663c..9b74b67 100644
--- a/main.c
+++ b/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);
}
diff --git a/password.c b/password.c
index fecaecb..6138e1f 100644
--- a/password.c
+++ b/password.c
@@ -1,5 +1,6 @@
#define _XOPEN_SOURCE 500
#include <assert.h>
+#include <errno.h>
#include <pwd.h>
#include <stdlib.h>
#include <string.h>
@@ -97,7 +98,10 @@ void swaylock_handle_key(struct swaylock_state *state,
state->eventloop, 50, handle_preverify_timeout, state);
while (state->run_display && state->verify_password_timer) {
- wl_display_flush(state->display);
+ errno = 0;
+ if (wl_display_flush(state->display) == -1 && errno != EAGAIN) {
+ break;
+ }
loop_poll(state->eventloop);
bool ok = 1;