diff options
author | Kenny Levinsen <kl@kl.wtf> | 2021-02-12 23:22:51 +0100 |
---|---|---|
committer | Tudor Brindus <me@tbrindus.ca> | 2021-02-16 22:05:00 -0500 |
commit | a047b5ee4a2a67d30d93641ff86531d54b8e0879 (patch) | |
tree | 271666c6254e4fabf943c1153224059411a5ce56 /sway/ipc-json.c | |
parent | Add missing transaction commits to seatop_default (diff) | |
download | sway-a047b5ee4a2a67d30d93641ff86531d54b8e0879.tar.gz sway-a047b5ee4a2a67d30d93641ff86531d54b8e0879.tar.zst sway-a047b5ee4a2a67d30d93641ff86531d54b8e0879.zip |
container: Move pending state to state struct
Pending state is currently inlined directly in the container struct,
while the current state is in a state struct. A side-effect of this is
that it is not immediately obvious that pending double-buffered state is
accessed, nor is it obvious what state is double-buffered.
Instead, use the state struct for both current and pending.
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r-- | sway/ipc-json.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index cfc6dfcf..2c4c52a3 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -456,27 +456,27 @@ static void get_deco_rect(struct sway_container *c, struct wlr_box *deco_rect) { | |||
456 | bool tab_or_stack = parent_layout == L_TABBED || parent_layout == L_STACKED; | 456 | bool tab_or_stack = parent_layout == L_TABBED || parent_layout == L_STACKED; |
457 | if (((!tab_or_stack || container_is_floating(c)) && | 457 | if (((!tab_or_stack || container_is_floating(c)) && |
458 | c->current.border != B_NORMAL) || | 458 | c->current.border != B_NORMAL) || |
459 | c->fullscreen_mode != FULLSCREEN_NONE || | 459 | c->pending.fullscreen_mode != FULLSCREEN_NONE || |
460 | c->workspace == NULL) { | 460 | c->pending.workspace == NULL) { |
461 | deco_rect->x = deco_rect->y = deco_rect->width = deco_rect->height = 0; | 461 | deco_rect->x = deco_rect->y = deco_rect->width = deco_rect->height = 0; |
462 | return; | 462 | return; |
463 | } | 463 | } |
464 | 464 | ||
465 | if (c->parent) { | 465 | if (c->pending.parent) { |
466 | deco_rect->x = c->x - c->parent->x; | 466 | deco_rect->x = c->pending.x - c->pending.parent->pending.x; |
467 | deco_rect->y = c->y - c->parent->y; | 467 | deco_rect->y = c->pending.y - c->pending.parent->pending.y; |
468 | } else { | 468 | } else { |
469 | deco_rect->x = c->x - c->workspace->x; | 469 | deco_rect->x = c->pending.x - c->pending.workspace->x; |
470 | deco_rect->y = c->y - c->workspace->y; | 470 | deco_rect->y = c->pending.y - c->pending.workspace->y; |
471 | } | 471 | } |
472 | deco_rect->width = c->width; | 472 | deco_rect->width = c->pending.width; |
473 | deco_rect->height = container_titlebar_height(); | 473 | deco_rect->height = container_titlebar_height(); |
474 | 474 | ||
475 | if (!container_is_floating(c)) { | 475 | if (!container_is_floating(c)) { |
476 | if (parent_layout == L_TABBED) { | 476 | if (parent_layout == L_TABBED) { |
477 | deco_rect->width = c->parent | 477 | deco_rect->width = c->pending.parent |
478 | ? c->parent->width / c->parent->children->length | 478 | ? c->pending.parent->pending.width / c->pending.parent->pending.children->length |
479 | : c->workspace->width / c->workspace->tiling->length; | 479 | : c->pending.workspace->width / c->pending.workspace->tiling->length; |
480 | deco_rect->x += deco_rect->width * container_sibling_index(c); | 480 | deco_rect->x += deco_rect->width * container_sibling_index(c); |
481 | } else if (parent_layout == L_STACKED) { | 481 | } else if (parent_layout == L_STACKED) { |
482 | if (!c->view) { | 482 | if (!c->view) { |
@@ -499,10 +499,10 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object | |||
499 | json_object_object_add(object, "visible", json_object_new_boolean(visible)); | 499 | json_object_object_add(object, "visible", json_object_new_boolean(visible)); |
500 | 500 | ||
501 | struct wlr_box window_box = { | 501 | struct wlr_box window_box = { |
502 | c->content_x - c->x, | 502 | c->pending.content_x - c->pending.x, |
503 | (c->current.border == B_PIXEL) ? c->current.border_thickness : 0, | 503 | (c->current.border == B_PIXEL) ? c->current.border_thickness : 0, |
504 | c->content_width, | 504 | c->pending.content_width, |
505 | c->content_height | 505 | c->pending.content_height |
506 | }; | 506 | }; |
507 | 507 | ||
508 | json_object_object_add(object, "window_rect", ipc_json_create_rect(&window_box)); | 508 | json_object_object_add(object, "window_rect", ipc_json_create_rect(&window_box)); |
@@ -595,11 +595,11 @@ static void ipc_json_describe_container(struct sway_container *c, json_object *o | |||
595 | 595 | ||
596 | json_object_object_add(object, "layout", | 596 | json_object_object_add(object, "layout", |
597 | json_object_new_string( | 597 | json_object_new_string( |
598 | ipc_json_layout_description(c->layout))); | 598 | ipc_json_layout_description(c->pending.layout))); |
599 | 599 | ||
600 | json_object_object_add(object, "orientation", | 600 | json_object_object_add(object, "orientation", |
601 | json_object_new_string( | 601 | json_object_new_string( |
602 | ipc_json_orientation_description(c->layout))); | 602 | ipc_json_orientation_description(c->pending.layout))); |
603 | 603 | ||
604 | bool urgent = c->view ? | 604 | bool urgent = c->view ? |
605 | view_is_urgent(c->view) : container_has_urgent_child(c); | 605 | view_is_urgent(c->view) : container_has_urgent_child(c); |
@@ -607,7 +607,7 @@ static void ipc_json_describe_container(struct sway_container *c, json_object *o | |||
607 | json_object_object_add(object, "sticky", json_object_new_boolean(c->is_sticky)); | 607 | json_object_object_add(object, "sticky", json_object_new_boolean(c->is_sticky)); |
608 | 608 | ||
609 | json_object_object_add(object, "fullscreen_mode", | 609 | json_object_object_add(object, "fullscreen_mode", |
610 | json_object_new_int(c->fullscreen_mode)); | 610 | json_object_new_int(c->pending.fullscreen_mode)); |
611 | 611 | ||
612 | struct sway_node *parent = node_get_parent(&c->node); | 612 | struct sway_node *parent = node_get_parent(&c->node); |
613 | struct wlr_box parent_box = {0, 0, 0, 0}; | 613 | struct wlr_box parent_box = {0, 0, 0, 0}; |
@@ -617,8 +617,8 @@ static void ipc_json_describe_container(struct sway_container *c, json_object *o | |||
617 | } | 617 | } |
618 | 618 | ||
619 | if (parent_box.width != 0 && parent_box.height != 0) { | 619 | if (parent_box.width != 0 && parent_box.height != 0) { |
620 | double percent = ((double)c->width / parent_box.width) | 620 | double percent = ((double)c->pending.width / parent_box.width) |
621 | * ((double)c->height / parent_box.height); | 621 | * ((double)c->pending.height / parent_box.height); |
622 | json_object_object_add(object, "percent", json_object_new_double(percent)); | 622 | json_object_object_add(object, "percent", json_object_new_double(percent)); |
623 | } | 623 | } |
624 | 624 | ||
@@ -749,10 +749,10 @@ json_object *ipc_json_describe_node_recursive(struct sway_node *node) { | |||
749 | } | 749 | } |
750 | break; | 750 | break; |
751 | case N_CONTAINER: | 751 | case N_CONTAINER: |
752 | if (node->sway_container->children) { | 752 | if (node->sway_container->pending.children) { |
753 | for (i = 0; i < node->sway_container->children->length; ++i) { | 753 | for (i = 0; i < node->sway_container->pending.children->length; ++i) { |
754 | struct sway_container *child = | 754 | struct sway_container *child = |
755 | node->sway_container->children->items[i]; | 755 | node->sway_container->pending.children->items[i]; |
756 | json_object_array_add(children, | 756 | json_object_array_add(children, |
757 | ipc_json_describe_node_recursive(&child->node)); | 757 | ipc_json_describe_node_recursive(&child->node)); |
758 | } | 758 | } |