mirror of
https://github.com/swaywm/sway.git
synced 2025-02-26 03:01:20 +00:00
Add keyboard shortcuts inhibitors to ipc json output
Extend the container description in IPC JSON to include keyboard shortcut inhibitor state so it can be evaluated by clients. This requires adding a new function that can retrieve a keyboard shortcuts inhibitor applying to a specific surface no matter what seat it is attached to. Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
This commit is contained in:
parent
f7a0f06dff
commit
0b7ee0b4a6
3 changed files with 42 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Add table
Reference in a new issue