aboutsummaryrefslogtreecommitdiffstats
path: root/sway/ipc-json.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r--sway/ipc-json.c32
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 @@
12#include "sway/input/seat.h" 12#include "sway/input/seat.h"
13#include <wlr/types/wlr_box.h> 13#include <wlr/types/wlr_box.h>
14#include <wlr/types/wlr_output.h> 14#include <wlr/types/wlr_output.h>
15#include <xkbcommon/xkbcommon.h>
15#include "wlr-layer-shell-unstable-v1-protocol.h" 16#include "wlr-layer-shell-unstable-v1-protocol.h"
16 17
17static const char *ipc_json_layout_description(enum sway_container_layout l) { 18static 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
245 json_object_object_add(object, "marks", marks); 246 json_object_object_add(object, "marks", marks);
246 247
247 struct wlr_box window_box = { 248 struct wlr_box window_box = {
248 c->view->x - c->x, 249 c->content_x - c->x,
249 (c->current.border == B_PIXEL) ? c->current.border_thickness : 0, 250 (c->current.border == B_PIXEL) ? c->current.border_thickness : 0,
250 c->view->width, 251 c->content_width,
251 c->view->height 252 c->content_height
252 }; 253 };
253 254
254 json_object_object_add(object, "window_rect", ipc_json_create_rect(&window_box)); 255 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
257 258
258 if (c->current.border == B_NORMAL) { 259 if (c->current.border == B_NORMAL) {
259 deco_box.width = c->width; 260 deco_box.width = c->width;
260 deco_box.height = c->view->y - c->y; 261 deco_box.height = c->content_y - c->y;
261 } 262 }
262 263
263 json_object_object_add(object, "deco_rect", ipc_json_create_rect(&deco_box)); 264 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
265 struct wlr_box geometry = {0, 0, c->view->natural_width, c->view->natural_height}; 266 struct wlr_box geometry = {0, 0, c->view->natural_width, c->view->natural_height};
266 json_object_object_add(object, "geometry", ipc_json_create_rect(&geometry)); 267 json_object_object_add(object, "geometry", ipc_json_create_rect(&geometry));
267 268
268#ifdef HAVE_XWAYLAND 269#if HAVE_XWAYLAND
269 if (c->view->type == SWAY_VIEW_XWAYLAND) { 270 if (c->view->type == SWAY_VIEW_XWAYLAND) {
270 json_object_object_add(object, "window", 271 json_object_object_add(object, "window",
271 json_object_new_int(view_get_x11_window_id(c->view))); 272 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) {
503 json_object_object_add(object, "type", 504 json_object_object_add(object, "type",
504 json_object_new_string(describe_device_type(device))); 505 json_object_new_string(describe_device_type(device)));
505 506
507 if (device->wlr_device->type == WLR_INPUT_DEVICE_KEYBOARD) {
508 struct wlr_keyboard *keyboard = device->wlr_device->keyboard;
509 struct xkb_keymap *keymap = keyboard->keymap;
510 struct xkb_state *state = keyboard->xkb_state;
511 xkb_layout_index_t num_layouts = xkb_keymap_num_layouts(keymap);
512 xkb_layout_index_t layout_idx;
513 for (layout_idx = 0; layout_idx < num_layouts; layout_idx++) {
514 bool is_active =
515 xkb_state_layout_index_is_active(state,
516 layout_idx,
517 XKB_STATE_LAYOUT_EFFECTIVE);
518 if (is_active) {
519 const char *layout =
520 xkb_keymap_layout_get_name(keymap, layout_idx);
521 json_object_object_add(object, "xkb_active_layout_name",
522 json_object_new_string(layout));
523 break;
524 }
525 }
526 }
527
506 return object; 528 return object;
507} 529}
508 530