aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sway/ipc-json.c51
-rw-r--r--sway/sway-ipc.7.scd5
2 files changed, 45 insertions, 11 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 125df387..c008f241 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -350,6 +350,38 @@ static void ipc_json_describe_workspace(struct sway_workspace *workspace,
350 json_object_object_add(object, "floating_nodes", floating_array); 350 json_object_object_add(object, "floating_nodes", floating_array);
351} 351}
352 352
353static void get_deco_rect(struct sway_container *c, struct wlr_box *deco_rect) {
354 enum sway_container_layout parent_layout = container_parent_layout(c);
355 if (parent_layout != L_TABBED && parent_layout != L_STACKED &&
356 c->current.border != B_NORMAL) {
357 deco_rect->x = deco_rect->y = deco_rect->width = deco_rect->height = 0;
358 return;
359 }
360
361 if (c->parent) {
362 deco_rect->x = c->x - c->parent->x;
363 deco_rect->y = c->y - c->parent->y;
364 } else {
365 deco_rect->x = c->x - c->workspace->x;
366 deco_rect->y = c->y - c->workspace->y;
367 }
368 deco_rect->width = c->width;
369 deco_rect->height = container_titlebar_height();
370
371 if (parent_layout == L_TABBED) {
372 deco_rect->width = c->parent
373 ? c->parent->width / c->parent->children->length
374 : c->workspace->width / c->workspace->tiling->length;
375 deco_rect->x += deco_rect->width * container_sibling_index(c);
376 } else if (container_parent_layout(c) == L_STACKED) {
377 if (!c->view) {
378 size_t siblings = container_get_siblings(c)->length;
379 deco_rect->y -= deco_rect->height * siblings;
380 }
381 deco_rect->y += deco_rect->height * container_sibling_index(c);
382 }
383}
384
353static void ipc_json_describe_view(struct sway_container *c, json_object *object) { 385static void ipc_json_describe_view(struct sway_container *c, json_object *object) {
354 json_object_object_add(object, "pid", json_object_new_int(c->view->pid)); 386 json_object_object_add(object, "pid", json_object_new_int(c->view->pid));
355 387
@@ -377,15 +409,6 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
377 409
378 json_object_object_add(object, "window_rect", ipc_json_create_rect(&window_box)); 410 json_object_object_add(object, "window_rect", ipc_json_create_rect(&window_box));
379 411
380 struct wlr_box deco_box = {0, 0, 0, 0};
381
382 if (c->current.border == B_NORMAL) {
383 deco_box.width = c->width;
384 deco_box.height = c->content_y - c->y;
385 }
386
387 json_object_object_add(object, "deco_rect", ipc_json_create_rect(&deco_box));
388
389 struct wlr_box geometry = {0, 0, c->view->natural_width, c->view->natural_height}; 412 struct wlr_box geometry = {0, 0, c->view->natural_width, c->view->natural_height};
390 json_object_object_add(object, "geometry", ipc_json_create_rect(&geometry)); 413 json_object_object_add(object, "geometry", ipc_json_create_rect(&geometry));
391 414
@@ -465,6 +488,10 @@ static void ipc_json_describe_container(struct sway_container *c, json_object *o
465 json_object_new_int(c->current.border_thickness)); 488 json_object_new_int(c->current.border_thickness));
466 json_object_object_add(object, "floating_nodes", json_object_new_array()); 489 json_object_object_add(object, "floating_nodes", json_object_new_array());
467 490
491 struct wlr_box deco_box = {0, 0, 0, 0};
492 get_deco_rect(c, &deco_box);
493 json_object_object_add(object, "deco_rect", ipc_json_create_rect(&deco_box));
494
468 if (c->view) { 495 if (c->view) {
469 ipc_json_describe_view(c, object); 496 ipc_json_describe_view(c, object);
470 } 497 }
@@ -505,6 +532,12 @@ json_object *ipc_json_describe_node(struct sway_node *node) {
505 532
506 struct wlr_box box; 533 struct wlr_box box;
507 node_get_box(node, &box); 534 node_get_box(node, &box);
535 if (node->type == N_CONTAINER) {
536 struct wlr_box deco_rect = {0, 0, 0, 0};
537 get_deco_rect(node->sway_container, &deco_rect);
538 box.y += deco_rect.height;
539 box.height -= deco_rect.height;
540 }
508 541
509 json_object *focus = json_object_new_array(); 542 json_object *focus = json_object_new_array();
510 struct focus_inactive_data data = { 543 struct focus_inactive_data data = {
diff --git a/sway/sway-ipc.7.scd b/sway/sway-ipc.7.scd
index d598a54f..6b400453 100644
--- a/sway/sway-ipc.7.scd
+++ b/sway/sway-ipc.7.scd
@@ -314,14 +314,15 @@ node and will have the following properties:
314 and other special nodes such as the scratchpad 314 and other special nodes such as the scratchpad
315|- rect 315|- rect
316: object 316: object
317: The absolute geometry of the node 317: The absolute geometry of the node. The window decorations are excluded from
318 this, but borders are included.
318|- window_rect 319|- window_rect
319: object 320: object
320: The geometry of the contents inside the node. The window decorations are 321: The geometry of the contents inside the node. The window decorations are
321 excluded from this calculation, but borders are included. 322 excluded from this calculation, but borders are included.
322|- deco_rect 323|- deco_rect
323: object 324: object
324: The geometry of the decorations inside the node 325: The geometry of the decorations for the node relative to the parent node
325|- geometry 326|- geometry
326: object 327: object
327: The natural geometry of the contents if it were to size itself 328: The natural geometry of the contents if it were to size itself