From df7d28034325ae80fd4b1660e2c6d5f67dc30d67 Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Fri, 3 Dec 2021 23:15:55 +0300 Subject: [PATCH] subsurface: apply position change at the right moment Subsurface position is considered to be a part of the parent surface's state, therefore it should be modified when the parent is committed. --- types/wlr_surface.c | 48 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/types/wlr_surface.c b/types/wlr_surface.c index bef4300f..360e4dff 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -508,6 +508,30 @@ static void subsurface_parent_commit(struct wlr_subsurface *subsurface) { wlr_surface_unlock_cached(surface, subsurface->cached_seq); subsurface->has_cache = false; } + + if (subsurface->current.x != subsurface->pending.x || + subsurface->current.y != subsurface->pending.y) { + // Subsurface has moved + int dx = subsurface->current.x - subsurface->pending.x; + int dy = subsurface->current.y - subsurface->pending.y; + + subsurface->current.x = subsurface->pending.x; + subsurface->current.y = subsurface->pending.y; + + if ((surface->current.transform & WL_OUTPUT_TRANSFORM_90) != 0) { + int tmp = dx; + dx = dy; + dy = tmp; + } + + pixman_region32_union_rect(&surface->buffer_damage, + &surface->buffer_damage, + dx * surface->previous.scale, dy * surface->previous.scale, + surface->previous.buffer_width, surface->previous.buffer_height); + pixman_region32_union_rect(&surface->buffer_damage, + &surface->buffer_damage, 0, 0, + surface->current.buffer_width, surface->current.buffer_height); + } } static void subsurface_commit(struct wlr_subsurface *subsurface) { @@ -1055,30 +1079,6 @@ static void subsurface_role_commit(struct wlr_surface *surface) { return; } - if (subsurface->current.x != subsurface->pending.x || - subsurface->current.y != subsurface->pending.y) { - // Subsurface has moved - int dx = subsurface->current.x - subsurface->pending.x; - int dy = subsurface->current.y - subsurface->pending.y; - - subsurface->current.x = subsurface->pending.x; - subsurface->current.y = subsurface->pending.y; - - if ((surface->current.transform & WL_OUTPUT_TRANSFORM_90) != 0) { - int tmp = dx; - dx = dy; - dy = tmp; - } - - pixman_region32_union_rect(&surface->buffer_damage, - &surface->buffer_damage, - dx * surface->previous.scale, dy * surface->previous.scale, - surface->previous.buffer_width, surface->previous.buffer_height); - pixman_region32_union_rect(&surface->buffer_damage, - &surface->buffer_damage, 0, 0, - surface->current.buffer_width, surface->current.buffer_height); - } - subsurface_consider_map(subsurface, true); }