From 006a5e9ecd310c7dd7ac34f0fd9cf1d387c623fa Mon Sep 17 00:00:00 2001 From: Maxim Solovyov Date: Thu, 7 Nov 2024 00:41:09 +0300 Subject: [PATCH] core: don't leak pixmaps of saved window images --- src/picom.c | 4 +--- src/wm/win.c | 12 +++++++----- src/wm/win.h | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/picom.c b/src/picom.c index 63eaa8787f..d45b8ff642 100644 --- a/src/picom.c +++ b/src/picom.c @@ -1686,9 +1686,7 @@ static void handle_pending_updates(struct session *ps, double delta_t) { w->running_animation_instance = NULL; w->in_openclose = false; if (w->saved_win_image != NULL) { - ps->backend_data->ops.release_image(ps->backend_data, - w->saved_win_image); - w->saved_win_image = NULL; + win_release_saved_win_image(ps->backend_data, w); } if (w->state == WSTATE_UNMAPPED) { unmap_win_finish(ps, w); diff --git a/src/wm/win.c b/src/wm/win.c index 16e10396fb..fb3558c2db 100644 --- a/src/wm/win.c +++ b/src/wm/win.c @@ -235,10 +235,14 @@ static inline void win_release_mask(backend_t *base, struct win *w) { } } -static inline void win_release_saved_win_image(backend_t *base, struct win *w) { +void win_release_saved_win_image(backend_t *base, struct win *w) { if (w->saved_win_image) { - base->ops.release_image(base, w->saved_win_image); + xcb_pixmap_t pixmap = XCB_NONE; + pixmap = base->ops.release_image(base, w->saved_win_image); w->saved_win_image = NULL; + if (pixmap != XCB_NONE) { + xcb_free_pixmap(base->c->c, pixmap); + } } } @@ -1937,9 +1941,7 @@ bool win_process_animation_and_state_change(struct session *ps, struct win *w, d if (win_check_flags_any(w, WIN_FLAGS_PIXMAP_STALE)) { // Grab the old pixmap, animations might need it if (w->saved_win_image) { - ps->backend_data->ops.release_image(ps->backend_data, - w->saved_win_image); - w->saved_win_image = NULL; + win_release_saved_win_image(ps->backend_data, w); } if (ps->drivers & DRIVER_NVIDIA) { if (w->win_image != NULL) { diff --git a/src/wm/win.h b/src/wm/win.h index d79fdf6e4e..ecf0c4e6c7 100644 --- a/src/wm/win.h +++ b/src/wm/win.h @@ -419,6 +419,7 @@ void unmap_win_finish(session_t *ps, struct win *w); /// because of fading and such. void win_destroy_start(session_t *ps, struct win *w); void win_map_start(struct session *ps, struct win *w); +void win_release_saved_win_image(backend_t *base, struct win *w); /// Release images bound with a window, set the *_NONE flags on the window. Only to be /// used when de-initializing the backend outside of win.c void win_release_images(struct backend_base *backend, struct win *w);