diff options
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r-- | sway/ipc-json.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index cf1b42a6..05e453ec 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -12,6 +12,7 @@ #include "sway/input/seat.h" #include <wlr/types/wlr_box.h> #include <wlr/types/wlr_output.h> +#include <xkbcommon/xkbcommon.h> #include "wlr-layer-shell-unstable-v1-protocol.h" static const char *ipc_json_layout_description(enum sway_container_layout l) { @@ -245,10 +246,10 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object json_object_object_add(object, "marks", marks); struct wlr_box window_box = { - c->view->x - c->x, + c->content_x - c->x, (c->current.border == B_PIXEL) ? c->current.border_thickness : 0, - c->view->width, - c->view->height + c->content_width, + c->content_height }; json_object_object_add(object, "window_rect", ipc_json_create_rect(&window_box)); @@ -257,7 +258,7 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object if (c->current.border == B_NORMAL) { deco_box.width = c->width; - deco_box.height = c->view->y - c->y; + deco_box.height = c->content_y - c->y; } json_object_object_add(object, "deco_rect", ipc_json_create_rect(&deco_box)); @@ -265,7 +266,7 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object struct wlr_box geometry = {0, 0, c->view->natural_width, c->view->natural_height}; json_object_object_add(object, "geometry", ipc_json_create_rect(&geometry)); -#ifdef HAVE_XWAYLAND +#if HAVE_XWAYLAND if (c->view->type == SWAY_VIEW_XWAYLAND) { json_object_object_add(object, "window", json_object_new_int(view_get_x11_window_id(c->view))); @@ -503,6 +504,27 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) { json_object_object_add(object, "type", json_object_new_string(describe_device_type(device))); + if (device->wlr_device->type == WLR_INPUT_DEVICE_KEYBOARD) { + struct wlr_keyboard *keyboard = device->wlr_device->keyboard; + struct xkb_keymap *keymap = keyboard->keymap; + struct xkb_state *state = keyboard->xkb_state; + xkb_layout_index_t num_layouts = xkb_keymap_num_layouts(keymap); + xkb_layout_index_t layout_idx; + for (layout_idx = 0; layout_idx < num_layouts; layout_idx++) { + bool is_active = + xkb_state_layout_index_is_active(state, + layout_idx, + XKB_STATE_LAYOUT_EFFECTIVE); + if (is_active) { + const char *layout = + xkb_keymap_layout_get_name(keymap, layout_idx); + json_object_object_add(object, "xkb_active_layout_name", + json_object_new_string(layout)); + break; + } + } + } + return object; } |