aboutsummaryrefslogtreecommitdiffstats
path: root/swaylock
diff options
context:
space:
mode:
Diffstat (limited to 'swaylock')
-rw-r--r--swaylock/main.c20
-rw-r--r--swaylock/password.c6
-rw-r--r--swaylock/seat.c22
3 files changed, 33 insertions, 15 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
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;
diff --git a/swaylock/seat.c b/swaylock/seat.c
index 22dd9360..7b72114f 100644
--- a/swaylock/seat.c
+++ b/swaylock/seat.c
@@ -144,22 +144,22 @@ static const struct wl_pointer_listener pointer_listener = {
144 144
145static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat, 145static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
146 enum wl_seat_capability caps) { 146 enum wl_seat_capability caps) {
147 struct swaylock_state *state = data; 147 struct swaylock_seat *seat = data;
148 if (state->pointer) { 148 if (seat->pointer) {
149 wl_pointer_release(state->pointer); 149 wl_pointer_release(seat->pointer);
150 state->pointer = NULL; 150 seat->pointer = NULL;
151 } 151 }
152 if (state->keyboard) { 152 if (seat->keyboard) {
153 wl_keyboard_release(state->keyboard); 153 wl_keyboard_release(seat->keyboard);
154 state->keyboard = NULL; 154 seat->keyboard = NULL;
155 } 155 }
156 if ((caps & WL_SEAT_CAPABILITY_POINTER)) { 156 if ((caps & WL_SEAT_CAPABILITY_POINTER)) {
157 state->pointer = wl_seat_get_pointer(wl_seat); 157 seat->pointer = wl_seat_get_pointer(wl_seat);
158 wl_pointer_add_listener(state->pointer, &pointer_listener, NULL); 158 wl_pointer_add_listener(seat->pointer, &pointer_listener, NULL);
159 } 159 }
160 if ((caps & WL_SEAT_CAPABILITY_KEYBOARD)) { 160 if ((caps & WL_SEAT_CAPABILITY_KEYBOARD)) {
161 state->keyboard = wl_seat_get_keyboard(wl_seat); 161 seat->keyboard = wl_seat_get_keyboard(wl_seat);
162 wl_keyboard_add_listener(state->keyboard, &keyboard_listener, state); 162 wl_keyboard_add_listener(seat->keyboard, &keyboard_listener, seat->state);
163 } 163 }
164} 164}
165 165