aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seat.c
diff options
context:
space:
mode:
authorLibravatar Michael Weiser <michael.weiser@gmx.de>2020-02-15 20:55:33 +0100
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2020-03-11 23:51:37 -0400
commiteeac0aa170d4ee19111df072ea361b56c802cf34 (patch)
tree58327ead389b1c396117e55af9f766e8c38e0995 /sway/input/seat.c
parentconfig: Fix typo in reload bindsym flag bitmask (diff)
downloadsway-eeac0aa170d4ee19111df072ea361b56c802cf34.tar.gz
sway-eeac0aa170d4ee19111df072ea361b56c802cf34.tar.zst
sway-eeac0aa170d4ee19111df072ea361b56c802cf34.zip
input: Add support for keyboard shortcuts inhibit
Adding support for the keyboard shortcuts inhibit protocol allows remote desktop and virtualisation software to receive all keyboard input in order to pass it through to their clients so users can fully interact the their remote/virtual session. The software usually provides its own key combination to release its "grab" to all keyboard input. The inhibitor can be deactivated by the user by removing focus from the surface using another input device such as the pointer. Use support for the procotol in wlroots to add support to sway. Extend the input manager with handlers for inhibitor creation and destruction and appropriate bookkeeping. Attach the inhibitors to the seats they apply to to avoid having to search the list of all currently existing inhibitors on every keystroke and passing the inhibitor manager around. Add a helper function to retrieve the inhibitor applying to the currently focused surface of a seat, if one exists. Extend bindsym with a flag for bindings that should be processed even if an inhibitor is active. Conversely this disables all normal shortcuts if an inhibitor is found for the currently focused surface in keyboard::handle_key_event() since they don't have that flag set. Use above helper function to determine if an inhibitor exists for the surface that would eventually receive input. Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 371de56e..6739c163 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -557,6 +557,7 @@ struct sway_seat *seat_create(const char *seat_name) {
557 handle_request_set_primary_selection; 557 handle_request_set_primary_selection;
558 558
559 wl_list_init(&seat->keyboard_groups); 559 wl_list_init(&seat->keyboard_groups);
560 wl_list_init(&seat->keyboard_shortcuts_inhibitors);
560 561
561 wl_list_insert(&server.input->seats, &seat->link); 562 wl_list_insert(&server.input->seats, &seat->link);
562 563
@@ -1473,3 +1474,18 @@ void seatop_render(struct sway_seat *seat, struct sway_output *output,
1473bool seatop_allows_set_cursor(struct sway_seat *seat) { 1474bool seatop_allows_set_cursor(struct sway_seat *seat) {
1474 return seat->seatop_impl->allow_set_cursor; 1475 return seat->seatop_impl->allow_set_cursor;
1475} 1476}
1477
1478struct sway_keyboard_shortcuts_inhibitor *
1479keyboard_shortcuts_inhibitor_get_for_focused_surface(
1480 const struct sway_seat *seat) {
1481 struct wlr_surface *focused_surface =
1482 seat->wlr_seat->keyboard_state.focused_surface;
1483 struct sway_keyboard_shortcuts_inhibitor *sway_inhibitor = NULL;
1484 wl_list_for_each(sway_inhibitor, &seat->keyboard_shortcuts_inhibitors, link) {
1485 if (sway_inhibitor->inhibitor->surface == focused_surface) {
1486 return sway_inhibitor;
1487 }
1488 }
1489
1490 return NULL;
1491}