Phase 80f: clean X11 from client.c, pixmap.c

- client.c: XFree -> wfree (vtable owns allocation), XGetTransientForHint
  -> prop_get_transient_for, XConfigureWindow -> frame_configure/stacking_restack,
  wFetchName -> window_fetch_name
- pixmap.c: wPixmapCreateFromXBMData and wPixmapCreate dispatch through
  new vtable slots pixmap_create_from_xbm and pixmap_create

New vtable slots: pixmap_create_from_xbm, pixmap_create.
Both files verified X11-free with nm.
This commit is contained in:
Levi Neely 2026-05-13 10:48:54 +02:00
parent 008da962fe
commit e504141132
5 changed files with 71 additions and 45 deletions

View File

@ -1692,6 +1692,15 @@ typedef struct WMBackend {
void (*switchpanel_send_enter)(WNativeWindow info_win, WNativeWindow window);
void (*format_x_error)(void *error, char *buf, int size);
/* ------------------------------------------------------------------ */
/* Pixmap creation (Phase 80d) */
/* ------------------------------------------------------------------ */
WPixmap *(*pixmap_create_from_xbm)(WScreen *scr, char *data, char *mask,
int width, int height,
unsigned long fg, unsigned long bg);
WPixmap *(*pixmap_create)(unsigned long image, unsigned long mask);
} WMBackend;
/*

View File

@ -6196,6 +6196,13 @@ static void wl_noop_switchpanel_send_enter(WNativeWindow info_win, WNativeWindow
static void wl_noop_format_x_error(void *error, char *buf, int size)
{ (void)error; if (size > 0) buf[0] = '\0'; }
static WPixmap *wl_noop_pixmap_create_from_xbm(WScreen *scr, char *data, char *mask,
int width, int height, unsigned long fg, unsigned long bg)
{ (void)scr; (void)data; (void)mask; (void)width; (void)height; (void)fg; (void)bg; return NULL; }
static WPixmap *wl_noop_pixmap_create(unsigned long image, unsigned long mask)
{ (void)image; (void)mask; return NULL; }
/* ------------------------------------------------------------------ */
/* vtable */
/* ------------------------------------------------------------------ */
@ -6410,4 +6417,6 @@ const WMBackend wl_backend = {
.display_get_name = wl_display_get_name,
.switchpanel_send_enter = wl_noop_switchpanel_send_enter,
.format_x_error = wl_noop_format_x_error,
.pixmap_create_from_xbm = wl_noop_pixmap_create_from_xbm,
.pixmap_create = wl_noop_pixmap_create,
};

View File

@ -3046,6 +3046,44 @@ static void x11_format_x_error(void *error, char *buf, int size)
(unsigned int)err->resourceid, err->serial);
}
static WPixmap *x11_pixmap_create_from_xbm(WScreen *scr, char *data, char *mask,
int width, int height,
unsigned long fg, unsigned long bg)
{
WPixmap *pix = wmalloc(sizeof(WPixmap));
pix->image = XCreatePixmapFromBitmapData(dpy, scr->w_win, data, width, height,
fg, bg, scr->w_depth);
if (pix->image == None) { wfree(pix); return NULL; }
if (mask)
pix->mask = XCreateBitmapFromData(dpy, scr->w_win, mask, width, height);
else
pix->mask = None;
pix->width = width;
pix->height = height;
pix->depth = scr->w_depth;
return pix;
}
static WPixmap *x11_pixmap_create(unsigned long image, unsigned long mask)
{
WPixmap *pix;
Window foo;
int bar;
unsigned int width, height, depth, baz;
pix = wmalloc(sizeof(WPixmap));
pix->image = (Pixmap)image;
pix->mask = (Pixmap)mask;
if (!XGetGeometry(dpy, (Pixmap)image, &foo, &bar, &bar, &width, &height, &baz, &depth)) {
wfree(pix);
return NULL;
}
pix->width = width;
pix->height = height;
pix->depth = depth;
return pix;
}
/* -------------------------------------------------------------------- */
/* Backend vtable instance and active-backend pointer */
/* -------------------------------------------------------------------- */
@ -3239,6 +3277,8 @@ const WMBackend x11_backend = {
.display_get_name = x11_display_get_name,
.switchpanel_send_enter = x11_switchpanel_send_enter,
.format_x_error = x11_format_x_error,
.pixmap_create_from_xbm = x11_pixmap_create_from_xbm,
.pixmap_create = x11_pixmap_create,
};
/*

View File

@ -135,7 +135,7 @@ void wClientConfigure(WWindow * wwin, XConfigureRequestEvent * xcre)
xwc.border_width = xcre->border_width;
xwc.stack_mode = xcre->detail;
xwc.sibling = xcre->above;
XConfigureWindow(dpy, xcre->window, xcre->value_mask, &xwc);
wm_backend->frame_configure((WNativeWindow)xcre->window, xwc.x, xwc.y, xwc.width, xwc.height);
return;
}
{
@ -156,8 +156,11 @@ void wClientConfigure(WWindow * wwin, XConfigureRequestEvent * xcre)
xwc.sibling = xcre->above;
}
xwc.stack_mode = xcre->detail;
XConfigureWindow(dpy, wwin->frame->core->window,
xcre->value_mask & (CWSibling | CWStackMode), &xwc);
{
WNativeWindow wins[2] = { (WNativeWindow)wwin->frame->core->window,
(WNativeWindow)xwc.sibling };
wm_backend->stacking_restack(wins, 2);
}
/* fix stacking order */
RemakeStackList(wwin->screen_ptr);
}
@ -252,13 +255,13 @@ void wClientCheckProperty(WWindow * wwin, XPropertyEvent * event)
case WA_WM_NAME:
if (!wwin->flags.net_has_title) {
/* window title was changed */
if (!wFetchName(dpy, wwin->client_win, &tmp)) {
if (!wm_backend->window_fetch_name(wwin->client_win, &tmp)) {
wWindowUpdateName(wwin, NULL);
} else {
wWindowUpdateName(wwin, tmp);
}
if (tmp)
XFree(tmp);
wfree(tmp);
}
break;
@ -447,12 +450,9 @@ void wClientCheckProperty(WWindow * wwin, XPropertyEvent * event)
Window new_owner;
WWindow *owner;
if (!XGetTransientForHint(dpy, wwin->client_win, &new_owner)) {
new_owner = None;
} else {
if (new_owner == 0 || new_owner == wwin->client_win) {
new_owner = wwin->screen_ptr->root_win;
}
new_owner = (Window)wm_backend->prop_get_transient_for(wwin->client_win);
if (new_owner == 0 || new_owner == wwin->client_win) {
new_owner = wwin->screen_ptr->root_win;
}
if (new_owner != wwin->transient_for) {
owner = wWindowFor(wwin->transient_for);

View File

@ -77,44 +77,12 @@ WPixmap *wPixmapCreateFromXPMData(WScreen * scr, char **data)
WPixmap *wPixmapCreateFromXBMData(WScreen * scr, char *data, char *mask,
int width, int height, unsigned long fg, unsigned long bg)
{
WPixmap *pix;
pix = wmalloc(sizeof(WPixmap));
pix->image = XCreatePixmapFromBitmapData(dpy, scr->w_win, data, width, height, fg, bg, scr->w_depth);
if (pix->image == None) {
wfree(pix);
return NULL;
}
if (mask) {
pix->mask = XCreateBitmapFromData(dpy, scr->w_win, mask, width, height);
} else {
pix->mask = None;
}
pix->width = width;
pix->height = height;
pix->depth = scr->w_depth;
return pix;
return wm_backend->pixmap_create_from_xbm(scr, data, mask, width, height, fg, bg);
}
WPixmap *wPixmapCreate(Pixmap image, Pixmap mask)
{
WPixmap *pix;
Window foo;
int bar;
unsigned int width, height, depth, baz;
pix = wmalloc(sizeof(WPixmap));
pix->image = image;
pix->mask = mask;
if (!XGetGeometry(dpy, image, &foo, &bar, &bar, &width, &height, &baz, &depth)) {
wwarning("XGetGeometry() failed during wPixmapCreate()");
wfree(pix);
return NULL;
}
pix->width = width;
pix->height = height;
pix->depth = depth;
return pix;
return wm_backend->pixmap_create((unsigned long)image, (unsigned long)mask);
}
/*