aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input
diff options
context:
space:
mode:
authorLibravatar Daniel De Graaf <code@danieldg.net>2022-03-08 21:14:26 -0500
committerLibravatar Simon Ser <contact@emersion.fr>2022-04-29 09:06:36 +0200
commit519038a7e903caae731007b276f5666a341498e9 (patch)
treeb62cb6728503c5e0940c08bb8cb30b81aab9e830 /sway/input
parentxkb_switch_layout: fix relative layout switches (diff)
downloadsway-519038a7e903caae731007b276f5666a341498e9.tar.gz
sway-519038a7e903caae731007b276f5666a341498e9.tar.zst
sway-519038a7e903caae731007b276f5666a341498e9.zip
Implement ext-session-lock-v1
Diffstat (limited to 'sway/input')
-rw-r--r--sway/input/input-manager.c4
-rw-r--r--sway/input/keyboard.c3
-rw-r--r--sway/input/seat.c27
-rw-r--r--sway/input/switch.c3
4 files changed, 30 insertions, 7 deletions
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index 8538d97c..4a0bce0e 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -289,6 +289,10 @@ static void handle_inhibit_deactivate(struct wl_listener *listener, void *data)
289 struct sway_input_manager *input_manager = wl_container_of( 289 struct sway_input_manager *input_manager = wl_container_of(
290 listener, input_manager, inhibit_deactivate); 290 listener, input_manager, inhibit_deactivate);
291 struct sway_seat *seat; 291 struct sway_seat *seat;
292 if (server.session_lock.locked) {
293 // Don't deactivate the grab of a screenlocker
294 return;
295 }
292 wl_list_for_each(seat, &input_manager->seats, link) { 296 wl_list_for_each(seat, &input_manager->seats, link) {
293 seat_set_exclusive_client(seat, NULL); 297 seat_set_exclusive_client(seat, NULL);
294 struct sway_node *previous = seat_get_focus(seat); 298 struct sway_node *previous = seat_get_focus(seat);
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index 1aa30655..8f18b8ba 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -409,7 +409,8 @@ static void handle_key_event(struct sway_keyboard *keyboard,
409 char *device_identifier = input_device_get_identifier(wlr_device); 409 char *device_identifier = input_device_get_identifier(wlr_device);
410 bool exact_identifier = wlr_device->keyboard->group != NULL; 410 bool exact_identifier = wlr_device->keyboard->group != NULL;
411 seat_idle_notify_activity(seat, IDLE_SOURCE_KEYBOARD); 411 seat_idle_notify_activity(seat, IDLE_SOURCE_KEYBOARD);
412 bool input_inhibited = seat->exclusive_client != NULL; 412 bool input_inhibited = seat->exclusive_client != NULL ||
413 server.session_lock.locked;
413 struct sway_keyboard_shortcuts_inhibitor *sway_inhibitor = 414 struct sway_keyboard_shortcuts_inhibitor *sway_inhibitor =
414 keyboard_shortcuts_inhibitor_get_for_focused_surface(seat); 415 keyboard_shortcuts_inhibitor_get_for_focused_surface(seat);
415 bool shortcuts_inhibited = sway_inhibitor && sway_inhibitor->inhibitor->active; 416 bool shortcuts_inhibited = sway_inhibitor && sway_inhibitor->inhibitor->active;
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 85179dc7..fa83050b 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -212,6 +212,15 @@ static void seat_send_focus(struct sway_node *node, struct sway_seat *seat) {
212 } 212 }
213} 213}
214 214
215void sway_force_focus(struct wlr_surface *surface) {
216 struct sway_seat *seat;
217 wl_list_for_each(seat, &server.input->seats, link) {
218 seat_keyboard_notify_enter(seat, surface);
219 seat_tablet_pads_notify_enter(seat, surface);
220 sway_input_method_relay_set_focus(&seat->im_relay, surface);
221 }
222}
223
215void seat_for_each_node(struct sway_seat *seat, 224void seat_for_each_node(struct sway_seat *seat,
216 void (*f)(struct sway_node *node, void *data), void *data) { 225 void (*f)(struct sway_node *node, void *data), void *data) {
217 struct sway_seat_node *current = NULL; 226 struct sway_seat_node *current = NULL;
@@ -814,11 +823,13 @@ static void seat_configure_keyboard(struct sway_seat *seat,
814 sway_keyboard_configure(seat_device->keyboard); 823 sway_keyboard_configure(seat_device->keyboard);
815 wlr_seat_set_keyboard(seat->wlr_seat, 824 wlr_seat_set_keyboard(seat->wlr_seat,
816 seat_device->input_device->wlr_device->keyboard); 825 seat_device->input_device->wlr_device->keyboard);
817 struct sway_node *focus = seat_get_focus(seat); 826
818 if (focus && node_is_view(focus)) { 827 // force notify reenter to pick up the new configuration. This reuses
819 // force notify reenter to pick up the new configuration 828 // the current focused surface to avoid breaking input grabs.
829 struct wlr_surface *surface = seat->wlr_seat->keyboard_state.focused_surface;
830 if (surface) {
820 wlr_seat_keyboard_notify_clear_focus(seat->wlr_seat); 831 wlr_seat_keyboard_notify_clear_focus(seat->wlr_seat);
821 seat_keyboard_notify_enter(seat, focus->sway_container->view->surface); 832 seat_keyboard_notify_enter(seat, surface);
822 } 833 }
823} 834}
824 835
@@ -1070,7 +1081,8 @@ void seat_configure_xcursor(struct sway_seat *seat) {
1070bool seat_is_input_allowed(struct sway_seat *seat, 1081bool seat_is_input_allowed(struct sway_seat *seat,
1071 struct wlr_surface *surface) { 1082 struct wlr_surface *surface) {
1072 struct wl_client *client = wl_resource_get_client(surface->resource); 1083 struct wl_client *client = wl_resource_get_client(surface->resource);
1073 return !seat->exclusive_client || seat->exclusive_client == client; 1084 return seat->exclusive_client == client ||
1085 (seat->exclusive_client == NULL && !server.session_lock.locked);
1074} 1086}
1075 1087
1076static void send_unfocus(struct sway_container *con, void *data) { 1088static void send_unfocus(struct sway_container *con, void *data) {
@@ -1171,6 +1183,11 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) {
1171 return; 1183 return;
1172 } 1184 }
1173 1185
1186 // Deny setting focus when an input grab or lockscreen is active
1187 if (container && !seat_is_input_allowed(seat, container->view->surface)) {
1188 return;
1189 }
1190
1174 struct sway_output *new_output = 1191 struct sway_output *new_output =
1175 new_workspace ? new_workspace->output : NULL; 1192 new_workspace ? new_workspace->output : NULL;
1176 1193
diff --git a/sway/input/switch.c b/sway/input/switch.c
index af5a2385..ac4baece 100644
--- a/sway/input/switch.c
+++ b/sway/input/switch.c
@@ -34,7 +34,8 @@ static bool sway_switch_trigger_test(enum sway_switch_trigger trigger,
34 34
35static void execute_binding(struct sway_switch *sway_switch) { 35static void execute_binding(struct sway_switch *sway_switch) {
36 struct sway_seat* seat = sway_switch->seat_device->sway_seat; 36 struct sway_seat* seat = sway_switch->seat_device->sway_seat;
37 bool input_inhibited = seat->exclusive_client != NULL; 37 bool input_inhibited = seat->exclusive_client != NULL ||
38 server.session_lock.locked;
38 39
39 list_t *bindings = config->current_mode->switch_bindings; 40 list_t *bindings = config->current_mode->switch_bindings;
40 struct sway_switch_binding *matched_binding = NULL; 41 struct sway_switch_binding *matched_binding = NULL;