def _reset_surface(self):
        """This creates a fresh surface and cairo context."""
        if hasattr(self, "surface"):
            self.surface.finish()

        self.surface = cairocffi.RecordingSurface(
            cairocffi.CONTENT_COLOR_ALPHA,
            None,
        )
        self.ctx = self.new_ctx()
This creates a fresh surface and cairo context.
libqtile/backend/base/drawer.py