From b3ee9af0c837bcb48eb30021eaa42c882426e66a Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 2 Jul 2018 23:06:44 +0100 Subject: Add view_get_geometry --- sway/tree/view.c | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-) (limited to 'sway/tree') diff --git a/sway/tree/view.c b/sway/tree/view.c index 950494d8..fba0b52d 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -162,6 +162,20 @@ void view_get_constraints(struct sway_view *view, double *min_width, } } +void view_get_geometry(struct sway_view *view, struct wlr_box *box) { + if (view->surface == NULL) { + box->x = box->y = box->width = box->height = 0; + return; + } + if (view->impl->get_geometry) { + view->impl->get_geometry(view, box); + return; + } + box->x = box->y = 0; + box->width = view->surface->current.width; + box->height = view->surface->current.height; +} + uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, int height) { if (view->impl->configure) { @@ -615,36 +629,6 @@ void view_unmap(struct sway_view *view) { view->surface = NULL; } -void view_update_position(struct sway_view *view, double lx, double ly) { - if (view->x == lx && view->y == ly) { - return; - } - container_damage_whole(view->swayc); - view->x = lx; - view->y = ly; - view->swayc->current.view_x = lx; - view->swayc->current.view_y = ly; - if (container_is_floating(view->swayc)) { - container_set_geometry_from_floating_view(view->swayc); - } - container_damage_whole(view->swayc); -} - -void view_update_size(struct sway_view *view, int width, int height) { - if (view->width == width && view->height == height) { - return; - } - container_damage_whole(view->swayc); - view->width = width; - view->height = height; - view->swayc->current.view_width = width; - view->swayc->current.view_height = height; - if (container_is_floating(view->swayc)) { - container_set_geometry_from_floating_view(view->swayc); - } - container_damage_whole(view->swayc); -} - static void view_subsurface_create(struct sway_view *view, struct wlr_subsurface *subsurface) { struct sway_view_child *child = calloc(1, sizeof(struct sway_view_child)); -- cgit v1.2.3 From 982a2d0c99f4128a7cf2236ca190dd9b4e6d7828 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 16 Aug 2018 22:41:10 +1000 Subject: Fix geometry --- sway/tree/container.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sway/tree') diff --git a/sway/tree/container.c b/sway/tree/container.c index db780270..1dc4be4b 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -525,6 +525,11 @@ static void surface_at_view(struct sway_container *swayc, double lx, double ly, double view_sx = lx - sview->x; double view_sy = ly - sview->y; + struct wlr_box geometry; + view_get_geometry(sview, &geometry); + view_sx += geometry.x; + view_sy += geometry.y; + double _sx, _sy; struct wlr_surface *_surface = NULL; switch (sview->type) { -- cgit v1.2.3 From 8af4e2e3e67e4e28e9ffad162984c0cc1414d771 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 17 Aug 2018 10:23:29 +1000 Subject: Handle xwayland views sending new sizes in their commits --- sway/tree/container.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sway/tree') diff --git a/sway/tree/container.c b/sway/tree/container.c index 1dc4be4b..b3368a2e 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -1089,6 +1089,7 @@ void container_set_geometry_from_floating_view(struct sway_container *con) { con->y = view->y - top; con->width = view->width + border_width * 2; con->height = top + view->height + border_width; + container_set_dirty(con); } bool container_is_floating(struct sway_container *container) { -- cgit v1.2.3 From b0a5f3a25f52bc1d48d771cb02820042006d8d9e Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 18 Aug 2018 15:10:06 +1000 Subject: Store geometry in the view and handle any floating view resizing --- sway/tree/container.c | 9 ++------- sway/tree/view.c | 26 ++++++++++++-------------- 2 files changed, 14 insertions(+), 21 deletions(-) (limited to 'sway/tree') diff --git a/sway/tree/container.c b/sway/tree/container.c index b3368a2e..b3f3a344 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -522,13 +522,8 @@ static void surface_at_view(struct sway_container *swayc, double lx, double ly, return; } struct sway_view *sview = swayc->sway_view; - double view_sx = lx - sview->x; - double view_sy = ly - sview->y; - - struct wlr_box geometry; - view_get_geometry(sview, &geometry); - view_sx += geometry.x; - view_sy += geometry.y; + double view_sx = lx - sview->x + sview->geometry.x; + double view_sy = ly - sview->y + sview->geometry.y; double _sx, _sy; struct wlr_surface *_surface = NULL; diff --git a/sway/tree/view.c b/sway/tree/view.c index fba0b52d..fbe4bc58 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -162,20 +162,6 @@ void view_get_constraints(struct sway_view *view, double *min_width, } } -void view_get_geometry(struct sway_view *view, struct wlr_box *box) { - if (view->surface == NULL) { - box->x = box->y = box->width = box->height = 0; - return; - } - if (view->impl->get_geometry) { - view->impl->get_geometry(view, box); - return; - } - box->x = box->y = 0; - box->width = view->surface->current.width; - box->height = view->surface->current.height; -} - uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, int height) { if (view->impl->configure) { @@ -629,6 +615,18 @@ void view_unmap(struct sway_view *view) { view->surface = NULL; } +void view_update_size(struct sway_view *view, int width, int height) { + if (!sway_assert(container_is_floating(view->swayc), + "Expected a floating container")) { + return; + } + view->width = width; + view->height = height; + view->swayc->current.view_width = width; + view->swayc->current.view_height = height; + container_set_geometry_from_floating_view(view->swayc); +} + static void view_subsurface_create(struct sway_view *view, struct wlr_subsurface *subsurface) { struct sway_view_child *child = calloc(1, sizeof(struct sway_view_child)); -- cgit v1.2.3