diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-11-17 18:32:03 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-11-17 21:29:42 +1000 |
commit | be9348d25c9556bdabb83d964a8761f920fc4a11 (patch) | |
tree | c06bde3d10e9bfea04acdd9b055cd596f13d4522 /sway/tree/container.c | |
parent | Merge pull request #3132 from emersion/dispatch-cursor-btn-segfault (diff) | |
download | sway-be9348d25c9556bdabb83d964a8761f920fc4a11.tar.gz sway-be9348d25c9556bdabb83d964a8761f920fc4a11.tar.zst sway-be9348d25c9556bdabb83d964a8761f920fc4a11.zip |
Move view {x,y,width,height} into container struct
This renames/moves the following properties:
* sway_view.{x,y,width,height} ->
sway_container.content_{x,y,width,height}
* This is required to support placeholder containers as they don't
have a view.
* sway_container_state.view_{x,y,width,height} ->
sway_container_state.content_{x,y,width,height}
* To remain consistent with the above.
* sway_container_state.con_{x,y,width,height} ->
sway_container_state.{x,y,width,height}
* The con prefix was there to give it contrast from the view
properties, and is no longer useful.
The function container_set_geometry_from_floating_view has also been
renamed to container_set_geometry_from_content.
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 3740cb53..89d80e51 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -165,8 +165,8 @@ static struct sway_container *surface_at_view(struct sway_container *con, double | |||
165 | return NULL; | 165 | return NULL; |
166 | } | 166 | } |
167 | struct sway_view *view = con->view; | 167 | struct sway_view *view = con->view; |
168 | double view_sx = lx - view->x + view->geometry.x; | 168 | double view_sx = lx - con->content_x + view->geometry.x; |
169 | double view_sy = ly - view->y + view->geometry.y; | 169 | double view_sy = ly - con->content_y + view->geometry.y; |
170 | 170 | ||
171 | double _sx, _sy; | 171 | double _sx, _sy; |
172 | struct wlr_surface *_surface = NULL; | 172 | struct wlr_surface *_surface = NULL; |
@@ -641,16 +641,18 @@ void container_init_floating(struct sway_container *con) { | |||
641 | con->y = ws->y + (ws->height - con->height) / 2; | 641 | con->y = ws->y + (ws->height - con->height) / 2; |
642 | } else { | 642 | } else { |
643 | struct sway_view *view = con->view; | 643 | struct sway_view *view = con->view; |
644 | view->width = fmax(min_width, fmin(view->natural_width, max_width)); | 644 | con->content_width = |
645 | view->height = fmax(min_height, fmin(view->natural_height, max_height)); | 645 | fmax(min_width, fmin(view->natural_width, max_width)); |
646 | view->x = ws->x + (ws->width - view->width) / 2; | 646 | con->content_height = |
647 | view->y = ws->y + (ws->height - view->height) / 2; | 647 | fmax(min_height, fmin(view->natural_height, max_height)); |
648 | con->content_x = ws->x + (ws->width - con->content_width) / 2; | ||
649 | con->content_y = ws->y + (ws->height - con->content_height) / 2; | ||
648 | 650 | ||
649 | // If the view's border is B_NONE then these properties are ignored. | 651 | // If the view's border is B_NONE then these properties are ignored. |
650 | con->border_top = con->border_bottom = true; | 652 | con->border_top = con->border_bottom = true; |
651 | con->border_left = con->border_right = true; | 653 | con->border_left = con->border_right = true; |
652 | 654 | ||
653 | container_set_geometry_from_floating_view(con); | 655 | container_set_geometry_from_content(con); |
654 | } | 656 | } |
655 | } | 657 | } |
656 | 658 | ||
@@ -707,14 +709,13 @@ void container_set_floating(struct sway_container *container, bool enable) { | |||
707 | ipc_event_window(container, "floating"); | 709 | ipc_event_window(container, "floating"); |
708 | } | 710 | } |
709 | 711 | ||
710 | void container_set_geometry_from_floating_view(struct sway_container *con) { | 712 | void container_set_geometry_from_content(struct sway_container *con) { |
711 | if (!sway_assert(con->view, "Expected a view")) { | 713 | if (!sway_assert(con->view, "Expected a view")) { |
712 | return; | 714 | return; |
713 | } | 715 | } |
714 | if (!sway_assert(container_is_floating(con), "Expected a floating view")) { | 716 | if (!sway_assert(container_is_floating(con), "Expected a floating view")) { |
715 | return; | 717 | return; |
716 | } | 718 | } |
717 | struct sway_view *view = con->view; | ||
718 | size_t border_width = 0; | 719 | size_t border_width = 0; |
719 | size_t top = 0; | 720 | size_t top = 0; |
720 | 721 | ||
@@ -724,10 +725,10 @@ void container_set_geometry_from_floating_view(struct sway_container *con) { | |||
724 | container_titlebar_height() : border_width; | 725 | container_titlebar_height() : border_width; |
725 | } | 726 | } |
726 | 727 | ||
727 | con->x = view->x - border_width; | 728 | con->x = con->content_x - border_width; |
728 | con->y = view->y - top; | 729 | con->y = con->content_y - top; |
729 | con->width = view->width + border_width * 2; | 730 | con->width = con->content_width + border_width * 2; |
730 | con->height = top + view->height + border_width; | 731 | con->height = top + con->content_height + border_width; |
731 | node_set_dirty(&con->node); | 732 | node_set_dirty(&con->node); |
732 | } | 733 | } |
733 | 734 | ||
@@ -756,15 +757,16 @@ void container_floating_translate(struct sway_container *con, | |||
756 | double x_amount, double y_amount) { | 757 | double x_amount, double y_amount) { |
757 | con->x += x_amount; | 758 | con->x += x_amount; |
758 | con->y += y_amount; | 759 | con->y += y_amount; |
759 | if (con->view) { | 760 | con->content_x += x_amount; |
760 | con->view->x += x_amount; | 761 | con->content_y += y_amount; |
761 | con->view->y += y_amount; | 762 | |
762 | } else { | 763 | if (con->children) { |
763 | for (int i = 0; i < con->children->length; ++i) { | 764 | for (int i = 0; i < con->children->length; ++i) { |
764 | struct sway_container *child = con->children->items[i]; | 765 | struct sway_container *child = con->children->items[i]; |
765 | container_floating_translate(child, x_amount, y_amount); | 766 | container_floating_translate(child, x_amount, y_amount); |
766 | } | 767 | } |
767 | } | 768 | } |
769 | |||
768 | node_set_dirty(&con->node); | 770 | node_set_dirty(&con->node); |
769 | } | 771 | } |
770 | 772 | ||
@@ -964,10 +966,10 @@ static void surface_send_leave_iterator(struct wlr_surface *surface, | |||
964 | 966 | ||
965 | void container_discover_outputs(struct sway_container *con) { | 967 | void container_discover_outputs(struct sway_container *con) { |
966 | struct wlr_box con_box = { | 968 | struct wlr_box con_box = { |
967 | .x = con->current.con_x, | 969 | .x = con->current.x, |
968 | .y = con->current.con_y, | 970 | .y = con->current.y, |
969 | .width = con->current.con_width, | 971 | .width = con->current.width, |
970 | .height = con->current.con_height, | 972 | .height = con->current.height, |
971 | }; | 973 | }; |
972 | struct sway_output *old_output = container_get_effective_output(con); | 974 | struct sway_output *old_output = container_get_effective_output(con); |
973 | 975 | ||