Skip to content

Commit

Permalink
core: don't leak pixmaps of saved window images
Browse files Browse the repository at this point in the history
  • Loading branch information
absolutelynothelix authored and yshui committed Nov 9, 2024
1 parent dc9009d commit 006a5e9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/picom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 7 additions & 5 deletions src/wm/win.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/wm/win.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 006a5e9

Please sign in to comment.