Skip to content

Commit

Permalink
x11: free old root pixmap if we re-create it
Browse files Browse the repository at this point in the history
we re-create this pixmap in _get_root_pixmap_and_surface() if its width and
height do not match (here we cannot resize unfortunately; if it's smaller
we could allow clipping, but we don't want to do that because of our
various fill modes, and if it's larger, well, the old pixmap is not big
enough and there are no x11 resize calls).

however, we did not free the old pixmap, resulting in a leak every time we
painted the screen.

Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
  • Loading branch information
tych0 committed May 30, 2024
1 parent 128fc83 commit 6a09c02
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libqtile/backend/x11/xcbq.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ def __init__(self, display):
self.atoms = AtomCache(self)
self.width = -1
self.height = -1
self.root_pixmap_id = None

def _get_root_pixmap_and_surface(self, screen):
# Querying the screen dimensions via the xcffib connection does not
Expand Down Expand Up @@ -702,6 +703,11 @@ def _update_root_pixmap(self, root_pixmap):
self.conn.core.ClearArea(0, self.default_screen.root.wid, 0, 0, self.width, self.height)
self.conn.flush()

# now that we have drawn the new pixmap, free the old one
if self.root_pixmap_id is not None and self.root_pixmap_id != root_pixmap:
self.conn.core.FreePixmap(self.root_pixmap_id)
self.root_pixmap_id = root_pixmap

def fill(self, screen, background):
root_pixmap, surface = self._get_root_pixmap_and_surface(screen)

Expand Down

0 comments on commit 6a09c02

Please sign in to comment.