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 committed Nov 6, 2024
1 parent 106123e commit 4529db7
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 @@ -1526,9 +1526,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 @@ -215,10 +215,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 @@ -1828,9 +1832,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) {
// NVIDIA doesn't like us grabbing the new pixmap before releasing
Expand Down
1 change: 1 addition & 0 deletions src/wm/win.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ void unmap_win_finish(session_t *ps, struct win *w);
/// because of fading and such.
void win_destroy_start(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 4529db7

Please sign in to comment.