[PATCH] wmsetbg: free the previous root pixmap via the ESETROOT pairing
7 views
Skip to first unread message
david.m...@gmail.com
unread,
Jun 17, 2026, 4:43:43 PMJun 17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Window Maker Development
Commit 6c107e0c switched duplicatePixmap() to RetainTemporary and removed XKillClient() from setPixmapProperty(). RetainTemporary resources are released only on server reset, so each background change now leaves a full-screen pixmap retained in the X server until logout. In helper mode that is one leak per workspace switch.
diff --git a/util/wmsetbg.c b/util/wmsetbg.c index 4f697d49..a7e59872 100644 --- a/util/wmsetbg.c +++ b/util/wmsetbg.c @@ -781,12 +781,8 @@ static Pixmap duplicatePixmap(Pixmap pixmap, int width, int height) Display *tmpDpy; Pixmap copyP;
-/* Open a separate connection so the pixmap survives our exit. - * RetainTemporary (not RetainPermanent) is used intentionally: - * the pixmap lives until the X session ends, avoiding the need - * for XKillClient() on old pixmaps (which can crash when the - * X server reuses a client ID that now belongs to our own - * connection, causing "X connection broken"). */ +/* must open a new display or the RetainPermanent will + * leave stuff allocated in RContext unallocated after exit */ tmpDpy = XOpenDisplay(display); if (!tmpDpy) { wwarning("could not open display to update background image information"); @@ -799,45 +795,83 @@ static Pixmap duplicatePixmap(Pixmap pixmap, int width, int height) XCopyArea(tmpDpy, pixmap, copyP, DefaultGC(tmpDpy, scr), 0, 0, width, height, 0, 0); XSync(tmpDpy, False);
+static int dummyErrorHandler(Display * dpy, XErrorEvent * err) +{ +/* Parameter not used, but tell the compiler that it is ok */ +(void) dpy; +(void) err;
-/* Read and discard the old property data. We no longer call - * XKillClient() on the old pixmap: since duplicatePixmap() uses - * RetainTemporary, old pixmaps are freed automatically when the - * X session ends. Calling XKillClient() here was unsafe because - * the X server reuses client IDs; if the stored resource ID was - * reassigned to our own connection the server would kill us, - * producing "X connection to :0 broken". */ -XGetWindowProperty(dpy, root, prop, 0L, 1L, False, AnyPropertyType, - &type, &format, &length, &after, &data); -if (data) -XFree(data); +/* Free the previous background pixmap only when both _XROOTPMAP_ID + * and ESETROOT_PMAP_ID hold the same XID, that pairing marks a + * RetainPermanent zombie left by a compliant root setter so + * XKillClient on it cannot hit a live connection. A bare + * _XROOTPMAP_ID may come from a tool that closed in Destroy mode, + * in which case the client bits of the stored XID can already be + * recycled to a live client, including our own dpy, and killing + * it produces "X connection broken". */ +have_root = getRootPixmapAtom(prop, &old_root); +have_eset = getRootPixmapAtom(eprop, &old_eset); +if (have_root && have_eset && old_root == old_eset && old_eset != None) { +XSetErrorHandler(dummyErrorHandler); +XKillClient(dpy, old_eset); +XSync(dpy, False); +XSetErrorHandler(NULL); +}