wayland: Phase 48 — guard NETWM init/update/cleanup functions against NULL dpy

Add if (!dpy) return guards to wNETWMInitStuff, wNETWMCleanup,
wNETWMUpdateDesktop, wNETWMGetCurrentDesktopFromHint,
wNETWMUpdateActions, and updateWindowOpacity so the Wayland backend
path does not crash calling XChangeProperty/XDeleteProperty/
XGetWindowProperty on a NULL display.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Levi Neely 2026-03-28 06:54:35 +01:00
parent 2d3d6d4716
commit b0728c7048
1 changed files with 12 additions and 0 deletions

View File

@ -362,6 +362,8 @@ void wNETWMUpdateDesktop(WScreen *scr)
long *views, sizes[2];
int count, i;
if (!dpy) return; /* Wayland: no X11 root-window properties */
if (scr->workspace_count == 0)
return;
@ -389,6 +391,8 @@ int wNETWMGetCurrentDesktopFromHint(WScreen *scr)
int count;
unsigned char *prop;
if (!dpy) return -1; /* Wayland: no X11 _NET_CURRENT_DESKTOP hint */
prop = PropGetCheckProperty(scr->root_win, net_current_desktop, WA_CARDINAL, 0, 1, &count);
if (prop) {
int desktop = *(long *)prop;
@ -576,6 +580,8 @@ static void updateWindowOpacity(WWindow *wwin)
unsigned long items, rest;
unsigned long *property;
if (!dpy) return; /* Wayland: no X11 _NET_WM_WINDOW_OPACITY */
if (!wwin->frame)
return;
@ -651,6 +657,8 @@ void wNETWMInitStuff(WScreen *scr)
NetData *data;
int i;
if (!dpy) return; /* Wayland: no X11 NETWM atoms or root-window hints */
#ifdef DEBUG_WMSPEC
wmessage("wNETWMInitStuff");
#endif
@ -708,6 +716,8 @@ void wNETWMCleanup(WScreen *scr)
{
int i;
if (!dpy) return; /* Wayland: no X11 root-window atoms to clean up */
for (i = 0; i < wlengthof(atomNames); i++)
XDeleteProperty(dpy, scr->root_win, *atomNames[i].atom);
}
@ -717,6 +727,8 @@ void wNETWMUpdateActions(WWindow *wwin, Bool del)
Atom action[10]; /* nr of actions atoms defined */
int i = 0;
if (!dpy) return; /* Wayland: no X11 _NET_WM_ALLOWED_ACTIONS property */
if (del) {
XDeleteProperty(dpy, wwin->client_win, net_wm_allowed_actions);
return;