diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index e5aa84783..837b79620 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h @@ -368,4 +368,12 @@ keyboard_shortcuts_inhibitor_get_for_surface(const struct sway_seat *seat, struct sway_keyboard_shortcuts_inhibitor * keyboard_shortcuts_inhibitor_get_for_focused_surface(const struct sway_seat *seat); +/** + * Returns the keyboard shortcuts inhibitor that applies to the given surface + * or NULL if none exists. It looks at inhibitors attached to all seats. + */ +struct sway_keyboard_shortcuts_inhibitor * +keyboard_shortcuts_inhibitor_get_for_surface_on_any_seat( + const struct wlr_surface *surface); + #endif diff --git a/sway/input/seat.c b/sway/input/seat.c index 75fea484c..aa4b0490f 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -1715,3 +1715,18 @@ keyboard_shortcuts_inhibitor_get_for_focused_surface( return keyboard_shortcuts_inhibitor_get_for_surface(seat, seat->wlr_seat->keyboard_state.focused_surface); } + +struct sway_keyboard_shortcuts_inhibitor * +keyboard_shortcuts_inhibitor_get_for_surface_on_any_seat( + const struct wlr_surface *surface) { + struct sway_seat *seat = NULL; + wl_list_for_each(seat, &server.input->seats, link) { + struct sway_keyboard_shortcuts_inhibitor *sway_inhibitor = + keyboard_shortcuts_inhibitor_get_for_surface(seat, surface); + if (sway_inhibitor) { + return sway_inhibitor; + } + } + + return NULL; +} diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 58356d4ea..666468e7e 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -220,6 +220,19 @@ static const char *ipc_json_content_type_description(enum wp_content_type_v1_typ return NULL; } +static const char *ipc_json_keyboard_shortcuts_inhibitor_description( + struct sway_keyboard_shortcuts_inhibitor *sway_inhibitor) { + if (!sway_inhibitor) { + return "none"; + } + + if (!sway_inhibitor->inhibitor->active) { + return "inactive"; + } + + return "active"; +} + json_object *ipc_json_get_version(void) { int major = 0, minor = 0, patch = 0; json_object *version = json_object_new_object(); @@ -631,6 +644,12 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object json_object_new_string(ipc_json_content_type_description(content_type))); } + json_object_object_add(object, "keyboard_shortcuts_inhibitor", + json_object_new_string( + ipc_json_keyboard_shortcuts_inhibitor_description( + keyboard_shortcuts_inhibitor_get_for_surface_on_any_seat( + c->view->surface)))); + #if HAVE_XWAYLAND if (c->view->type == SWAY_VIEW_XWAYLAND) { json_object_object_add(object, "window",