From d43500831a78580f59525144a0c9b034d4d399d0 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 1 Jul 2018 09:46:02 -0400 Subject: [PATCH 1/2] Updates per wlroots#1076 --- sway/desktop/output.c | 18 +++++++++--------- sway/desktop/transaction.c | 4 ++-- sway/desktop/xdg_shell.c | 4 ++-- sway/desktop/xdg_shell_v6.c | 4 ++-- sway/desktop/xwayland.c | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 1e7494b3e..a86c1646c 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -81,8 +81,8 @@ static bool get_surface_box(struct root_geometry *geo, return false; } - int sw = surface->current->width; - int sh = surface->current->height; + int sw = surface->current.width; + int sh = surface->current.height; double _sx = sx, _sy = sy; rotate_child_position(&_sx, &_sy, sw, sh, geo->width, geo->height, @@ -115,8 +115,8 @@ static void surface_for_each_surface(struct wlr_surface *surface, wlr_surface_iterator_func_t iterator, void *user_data) { geo->x = ox; geo->y = oy; - geo->width = surface->current->width; - geo->height = surface->current->height; + geo->width = surface->current.width; + geo->height = surface->current.height; geo->rotation = 0; wlr_surface_for_each_surface(surface, iterator, user_data); @@ -258,7 +258,7 @@ static void render_surface_iterator(struct wlr_surface *surface, int sx, int sy, float matrix[9]; enum wl_output_transform transform = - wlr_output_transform_invert(surface->current->transform); + wlr_output_transform_invert(surface->current.transform); wlr_matrix_project_box(matrix, &box, transform, rotation, wlr_output->transform_matrix); @@ -1163,16 +1163,16 @@ static void damage_surface_iterator(struct wlr_surface *surface, int sx, int sy, int center_x = box.x + box.width/2; int center_y = box.y + box.height/2; - if (pixman_region32_not_empty(&surface->current->surface_damage)) { + if (pixman_region32_not_empty(&surface->current.surface_damage)) { pixman_region32_t damage; pixman_region32_init(&damage); - pixman_region32_copy(&damage, &surface->current->surface_damage); + pixman_region32_copy(&damage, &surface->current.surface_damage); wlr_region_scale(&damage, &damage, output->wlr_output->scale); - if (ceil(output->wlr_output->scale) > surface->current->scale) { + if (ceil(output->wlr_output->scale) > surface->current.scale) { // When scaling up a surface, it'll become blurry so we need to // expand the damage region wlr_region_expand(&damage, &damage, - ceil(output->wlr_output->scale) - surface->current->scale); + ceil(output->wlr_output->scale) - surface->current.scale); } pixman_region32_translate(&damage, box.x, box.y); wlr_region_rotated_bounds(&damage, &damage, rotation, diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index b4d796cb3..179af6171 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c @@ -73,8 +73,8 @@ static void save_view_buffer(struct sway_view *view, } if (view->surface && wlr_surface_has_buffer(view->surface)) { instruction->saved_buffer = wlr_buffer_ref(view->surface->buffer); - instruction->saved_buffer_width = view->surface->current->width; - instruction->saved_buffer_height = view->surface->current->height; + instruction->saved_buffer_width = view->surface->current.width; + instruction->saved_buffer_height = view->surface->current.height; } } diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 2b634749f..ac35a8d19 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -251,8 +251,8 @@ static void handle_map(struct wl_listener *listener, void *data) { view->natural_width = view->wlr_xdg_surface->geometry.width; view->natural_height = view->wlr_xdg_surface->geometry.height; if (!view->natural_width && !view->natural_height) { - view->natural_width = view->wlr_xdg_surface->surface->current->width; - view->natural_height = view->wlr_xdg_surface->surface->current->height; + view->natural_width = view->wlr_xdg_surface->surface->current.width; + view->natural_height = view->wlr_xdg_surface->surface->current.height; } view_map(view, view->wlr_xdg_surface->surface); diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 2f0730e46..56bbb2449 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -246,8 +246,8 @@ static void handle_map(struct wl_listener *listener, void *data) { view->natural_width = view->wlr_xdg_surface_v6->geometry.width; view->natural_height = view->wlr_xdg_surface_v6->geometry.height; if (!view->natural_width && !view->natural_height) { - view->natural_width = view->wlr_xdg_surface_v6->surface->current->width; - view->natural_height = view->wlr_xdg_surface_v6->surface->current->height; + view->natural_width = view->wlr_xdg_surface_v6->surface->current.width; + view->natural_height = view->wlr_xdg_surface_v6->surface->current.height; } view_map(view, view->wlr_xdg_surface_v6->surface); diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 718032626..0669a4853 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -278,7 +278,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { wl_container_of(listener, xwayland_view, commit); struct sway_view *view = &xwayland_view->view; struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; - struct wlr_surface_state *surface_state = xsurface->surface->current; + struct wlr_surface_state *surface_state = &xsurface->surface->current; if (view->swayc->instructions->length) { transaction_notify_view_ready_by_size(view, From 51b215ad5c0cadc4f1c10f407d1a2c375b46a769 Mon Sep 17 00:00:00 2001 From: emersion Date: Sun, 1 Jul 2018 14:55:14 +0100 Subject: [PATCH 2/2] Use wlr_surface.buffer_damage --- sway/desktop/output.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sway/desktop/output.c b/sway/desktop/output.c index a86c1646c..1211cc07c 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -1163,11 +1163,17 @@ static void damage_surface_iterator(struct wlr_surface *surface, int sx, int sy, int center_x = box.x + box.width/2; int center_y = box.y + box.height/2; - if (pixman_region32_not_empty(&surface->current.surface_damage)) { + if (pixman_region32_not_empty(&surface->buffer_damage)) { + enum wl_output_transform transform = + wlr_output_transform_invert(surface->current.transform); + pixman_region32_t damage; pixman_region32_init(&damage); - pixman_region32_copy(&damage, &surface->current.surface_damage); - wlr_region_scale(&damage, &damage, output->wlr_output->scale); + pixman_region32_copy(&damage, &surface->buffer_damage); + wlr_region_transform(&damage, &damage, transform, + surface->current.buffer_width, surface->current.buffer_height); + wlr_region_scale(&damage, &damage, + output->wlr_output->scale / (float)surface->current.scale); if (ceil(output->wlr_output->scale) > surface->current.scale) { // When scaling up a surface, it'll become blurry so we need to // expand the damage region