aboutsummaryrefslogtreecommitdiffstats
path: root/swaylock/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaylock/main.c')
-rw-r--r--swaylock/main.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/swaylock/main.c b/swaylock/main.c
index f2bb5c3e..9b74b671 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>
@@ -279,7 +280,10 @@ static void handle_global(void *data, struct wl_registry *registry,
279 } else if (strcmp(interface, wl_seat_interface.name) == 0) { 280 } else if (strcmp(interface, wl_seat_interface.name) == 0) {
280 struct wl_seat *seat = wl_registry_bind( 281 struct wl_seat *seat = wl_registry_bind(
281 registry, name, &wl_seat_interface, 3); 282 registry, name, &wl_seat_interface, 3);
282 wl_seat_add_listener(seat, &seat_listener, state); 283 struct swaylock_seat *swaylock_seat =
284 calloc(1, sizeof(struct swaylock_seat));
285 swaylock_seat->state = state;
286 wl_seat_add_listener(seat, &seat_listener, swaylock_seat);
283 } else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) { 287 } else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) {
284 state->layer_shell = wl_registry_bind( 288 state->layer_shell = wl_registry_bind(
285 registry, name, &zwlr_layer_shell_v1_interface, 1); 289 registry, name, &zwlr_layer_shell_v1_interface, 1);
@@ -841,7 +845,9 @@ static int load_config(char *path, struct swaylock_state *state,
841static struct swaylock_state state; 845static struct swaylock_state state;
842 846
843static void display_in(int fd, short mask, void *data) { 847static void display_in(int fd, short mask, void *data) {
844 wl_display_dispatch(state.display); 848 if (wl_display_dispatch(state.display) == -1) {
849 state.run_display = false;
850 }
845} 851}
846 852
847int main(int argc, char **argv) { 853int main(int argc, char **argv) {
@@ -925,6 +931,11 @@ int main(int argc, char **argv) {
925 } 931 }
926 932
927 zwlr_input_inhibit_manager_v1_get_inhibitor(state.input_inhibit_manager); 933 zwlr_input_inhibit_manager_v1_get_inhibitor(state.input_inhibit_manager);
934 if (wl_display_roundtrip(state.display) == -1) {
935 wlr_log(WLR_ERROR, "Exiting - failed to inhibit input:"
936 " is another lockscreen already running?");
937 return 2;
938 }
928 939
929 if (state.zxdg_output_manager) { 940 if (state.zxdg_output_manager) {
930 struct swaylock_surface *surface; 941 struct swaylock_surface *surface;
@@ -956,7 +967,10 @@ int main(int argc, char **argv) {
956 967
957 state.run_display = true; 968 state.run_display = true;
958 while (state.run_display) { 969 while (state.run_display) {
959 wl_display_flush(state.display); 970 errno = 0;
971 if (wl_display_flush(state.display) == -1 && errno != EAGAIN) {
972 break;
973 }
960 loop_poll(state.eventloop); 974 loop_poll(state.eventloop);
961 } 975 }
962 976