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 | |
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')
-rw-r--r-- | sway/tree/container.c | 44 | ||||
-rw-r--r-- | sway/tree/view.c | 37 |
2 files changed, 42 insertions, 39 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 | ||
diff --git a/sway/tree/view.c b/sway/tree/view.c index 21b32649..18195467 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -196,22 +196,22 @@ static bool gaps_to_edge(struct sway_view *view) { | |||
196 | } | 196 | } |
197 | 197 | ||
198 | void view_autoconfigure(struct sway_view *view) { | 198 | void view_autoconfigure(struct sway_view *view) { |
199 | if (!view->container->workspace) { | 199 | struct sway_container *con = view->container; |
200 | if (!con->workspace) { | ||
200 | // Hidden in the scratchpad | 201 | // Hidden in the scratchpad |
201 | return; | 202 | return; |
202 | } | 203 | } |
203 | struct sway_output *output = view->container->workspace->output; | 204 | struct sway_output *output = con->workspace->output; |
204 | 205 | ||
205 | if (view->container->is_fullscreen) { | 206 | if (con->is_fullscreen) { |
206 | view->x = output->lx; | 207 | con->content_x = output->lx; |
207 | view->y = output->ly; | 208 | con->content_y = output->ly; |
208 | view->width = output->width; | 209 | con->content_width = output->width; |
209 | view->height = output->height; | 210 | con->content_height = output->height; |
210 | return; | 211 | return; |
211 | } | 212 | } |
212 | 213 | ||
213 | struct sway_workspace *ws = view->container->workspace; | 214 | struct sway_workspace *ws = view->container->workspace; |
214 | struct sway_container *con = view->container; | ||
215 | 215 | ||
216 | bool smart = config->hide_edge_borders == E_SMART || | 216 | bool smart = config->hide_edge_borders == E_SMART || |
217 | config->hide_edge_borders == E_SMART_NO_GAPS; | 217 | config->hide_edge_borders == E_SMART_NO_GAPS; |
@@ -289,10 +289,10 @@ void view_autoconfigure(struct sway_view *view) { | |||
289 | break; | 289 | break; |
290 | } | 290 | } |
291 | 291 | ||
292 | view->x = x; | 292 | con->content_x = x; |
293 | view->y = y; | 293 | con->content_y = y; |
294 | view->width = width; | 294 | con->content_width = width; |
295 | view->height = height; | 295 | con->content_height = height; |
296 | } | 296 | } |
297 | 297 | ||
298 | void view_set_activated(struct sway_view *view, bool activated) { | 298 | void view_set_activated(struct sway_view *view, bool activated) { |
@@ -667,11 +667,11 @@ void view_update_size(struct sway_view *view, int width, int height) { | |||
667 | "Expected a floating container")) { | 667 | "Expected a floating container")) { |
668 | return; | 668 | return; |
669 | } | 669 | } |
670 | view->width = width; | 670 | view->container->content_width = width; |
671 | view->height = height; | 671 | view->container->content_height = height; |
672 | view->container->current.view_width = width; | 672 | view->container->current.content_width = width; |
673 | view->container->current.view_height = height; | 673 | view->container->current.content_height = height; |
674 | container_set_geometry_from_floating_view(view->container); | 674 | container_set_geometry_from_content(view->container); |
675 | } | 675 | } |
676 | 676 | ||
677 | static void subsurface_get_root_coords(struct sway_view_child *child, | 677 | static void subsurface_get_root_coords(struct sway_view_child *child, |
@@ -707,7 +707,8 @@ static void view_child_damage(struct sway_view_child *child, bool whole) { | |||
707 | int sx, sy; | 707 | int sx, sy; |
708 | child->impl->get_root_coords(child, &sx, &sy); | 708 | child->impl->get_root_coords(child, &sx, &sy); |
709 | desktop_damage_surface(child->surface, | 709 | desktop_damage_surface(child->surface, |
710 | child->view->x + sx, child->view->y + sy, whole); | 710 | child->view->container->content_x + sx, |
711 | child->view->container->content_y + sy, whole); | ||
711 | } | 712 | } |
712 | 713 | ||
713 | static void view_child_handle_surface_commit(struct wl_listener *listener, | 714 | static void view_child_handle_surface_commit(struct wl_listener *listener, |