From 04b80760d839e925e8c4bcb5d94a82408d2c93b3 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Mon, 10 Oct 2022 13:55:05 +0100 Subject: [PATCH] win: fix leak in win_bind_mask Related: #905 Signed-off-by: Yuxuan Shui --- src/config.h | 1 - src/win.c | 33 ++++++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/config.h b/src/config.h index a58321f..b91a5ef 100644 --- a/src/config.h +++ b/src/config.h @@ -53,7 +53,6 @@ enum open_window_animation { OPEN_WINDOW_ANIMATION_SLIDE_OUT_CENTER, OPEN_WINDOW_ANIMATION_ZOOM, OPEN_WINDOW_ANIMATION_MINIMIZE, - OPEN_WINDOW_ANIMATION_MAXIMIZE, OPEN_WINDOW_ANIMATION_SQUEEZE, OPEN_WINDOW_ANIMATION_SQUEEZE_BOTTOM, OPEN_WINDOW_ANIMATION_INVALID, diff --git a/src/win.c b/src/win.c index 7cabdea..7553c6b 100644 --- a/src/win.c +++ b/src/win.c @@ -357,6 +357,8 @@ bool win_bind_mask(struct backend_base *b, struct managed_win *w) { pixman_region32_translate(®_bound_local, -w->g.x, -w->g.y); w->mask_image = b->ops->make_mask( b, (geometry_t){.width = w->g.width, .height = w->g.height}, ®_bound_local); + pixman_region32_fini(®_bound_local); + if (!w->mask_image) { return false; } @@ -671,14 +673,23 @@ void win_process_update_flags(session_t *ps, struct managed_win *w) { add_damage_from_win(ps, w); } + + // Determine if a window should animate if (win_should_animate(ps, w)) { + if (win_check_flags_all(w, WIN_FLAGS_SIZE_STALE)) { + win_on_win_size_change(ps, w); + win_update_bounding_shape(ps, w); + damaged = true; + win_clear_flags(w, WIN_FLAGS_SIZE_STALE); + } + if (w->pending_g.y < 0 && w->g.y > 0 && abs(w->pending_g.y - w->g.y) >= w->pending_g.height) w->dwm_mask = ANIM_PREV_TAG; else if (w->pending_g.y > 0 && w->g.y < 0 && abs(w->pending_g.y - w->g.y) >= w->pending_g.height) w->dwm_mask = ANIM_NEXT_TAG; - if (!was_visible || w->dwm_mask || (w->window_type == WINTYPE_NOTIFICATION && w->state == WSTATE_MAPPING)) { + if (!was_visible || w->dwm_mask) { // Set window-open animation init_animation(ps, w); @@ -744,12 +755,12 @@ void win_process_update_flags(session_t *ps, struct managed_win *w) { w->g = w->pending_g; } - if (win_check_flags_all(w, WIN_FLAGS_SIZE_STALE)) { - win_on_win_size_change(ps, w); - win_update_bounding_shape(ps, w); - damaged = true; - win_clear_flags(w, WIN_FLAGS_SIZE_STALE); - } + if (!win_should_animate(ps, w) && win_check_flags_all(w, WIN_FLAGS_SIZE_STALE)) { + win_on_win_size_change(ps, w); + win_update_bounding_shape(ps, w); + damaged = true; + win_clear_flags(w, WIN_FLAGS_SIZE_STALE); + } if (win_check_flags_all(w, WIN_FLAGS_POSITION_STALE)) { damaged = true; @@ -3025,6 +3036,10 @@ win_is_fullscreen_xcb(xcb_connection_t *c, const struct atom *a, const xcb_windo void win_set_flags(struct managed_win *w, uint64_t flags) { log_debug("Set flags %" PRIu64 " to window %#010x (%s)", flags, w->base.id, w->name); if (unlikely(w->state == WSTATE_DESTROYING)) { + if (w->animation_progress != 1.0) { + // Return because animation will trigger some of the flags + return; + } log_error("Flags set on a destroyed window %#010x (%s)", w->base.id, w->name); return; } @@ -3037,6 +3052,10 @@ void win_clear_flags(struct managed_win *w, uint64_t flags) { log_debug("Clear flags %" PRIu64 " from window %#010x (%s)", flags, w->base.id, w->name); if (unlikely(w->state == WSTATE_DESTROYING)) { + if (w->animation_progress != 1.0) { + // Return because animation will trigger some of the flags + return; + } log_warn("Flags cleared on a destroyed window %#010x (%s)", w->base.id, w->name); return;