summaryrefslogtreecommitdiffstats
path: root/swaylock
diff options
context:
space:
mode:
authorLibravatar Ian Fan <ianfan0@gmail.com>2018-10-23 11:46:51 +0100
committerLibravatar Ian Fan <ianfan0@gmail.com>2018-10-23 11:49:33 +0100
commitebfb1388e2b178ecee1c1e1f4b5160af0efe2db6 (patch)
treef6242e2d098774e20618542bfeff411d0a75d79b /swaylock
parentswaylock: exit early if unable to inhibit input (diff)
downloadsway-ebfb1388e2b178ecee1c1e1f4b5160af0efe2db6.tar.gz
sway-ebfb1388e2b178ecee1c1e1f4b5160af0efe2db6.tar.zst
sway-ebfb1388e2b178ecee1c1e1f4b5160af0efe2db6.zip
swaylock: exit on display error
Diffstat (limited to 'swaylock')
-rw-r--r--swaylock/main.c10
-rw-r--r--swaylock/password.c6
2 files changed, 13 insertions, 3 deletions
diff --git a/swaylock/main.c b/swaylock/main.c
index 8ed8adf5..ebc2b263 100644
--- a/swaylock/main.c
+++ b/swaylock/main.c
@@ -2,6 +2,7 @@
2#define _POSIX_C_SOURCE 200112L 2#define _POSIX_C_SOURCE 200112L
3#include <assert.h> 3#include <assert.h>
4#include <ctype.h> 4#include <ctype.h>
5#include <errno.h>
5#include <fcntl.h> 6#include <fcntl.h>
6#include <getopt.h> 7#include <getopt.h>
7#include <stdbool.h> 8#include <stdbool.h>
@@ -841,7 +842,9 @@ static int load_config(char *path, struct swaylock_state *state,
841static struct swaylock_state state; 842static struct swaylock_state state;
842 843
843static void display_in(int fd, short mask, void *data) { 844static void display_in(int fd, short mask, void *data) {
844 wl_display_dispatch(state.display); 845 if (wl_display_dispatch(state.display) == -1) {
846 state.run_display = false;
847 }
845} 848}
846 849
847int main(int argc, char **argv) { 850int main(int argc, char **argv) {
@@ -961,7 +964,10 @@ int main(int argc, char **argv) {
961 964
962 state.run_display = true; 965 state.run_display = true;
963 while (state.run_display) { 966 while (state.run_display) {
964 wl_display_flush(state.display); 967 errno = 0;
968 if (wl_display_flush(state.display) == -1 && errno != EAGAIN) {
969 break;
970 }
965 loop_poll(state.eventloop); 971 loop_poll(state.eventloop);
966 } 972 }
967 973
diff --git a/swaylock/password.c b/swaylock/password.c
index fecaecbf..6138e1fe 100644
--- a/swaylock/password.c
+++ b/swaylock/password.c
@@ -1,5 +1,6 @@
1#define _XOPEN_SOURCE 500 1#define _XOPEN_SOURCE 500
2#include <assert.h> 2#include <assert.h>
3#include <errno.h>
3#include <pwd.h> 4#include <pwd.h>
4#include <stdlib.h> 5#include <stdlib.h>
5#include <string.h> 6#include <string.h>
@@ -97,7 +98,10 @@ void swaylock_handle_key(struct swaylock_state *state,
97 state->eventloop, 50, handle_preverify_timeout, state); 98 state->eventloop, 50, handle_preverify_timeout, state);
98 99
99 while (state->run_display && state->verify_password_timer) { 100 while (state->run_display && state->verify_password_timer) {
100 wl_display_flush(state->display); 101 errno = 0;
102 if (wl_display_flush(state->display) == -1 && errno != EAGAIN) {
103 break;
104 }
101 loop_poll(state->eventloop); 105 loop_poll(state->eventloop);
102 106
103 bool ok = 1; 107 bool ok = 1;