From b996a0e27408c4ba5814b297d0460ee1c2f67ec1 Mon Sep 17 00:00:00 2001 From: Window Maker Date: Sun, 24 May 2026 13:35:07 +0200 Subject: [PATCH] WPrefs.app: TexturePanel.c X11-free in compiled code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Active code: XFillRectangle → renderBackend/WMPaintColorSwatch, XCopyArea → renderBackend->pixmap_copy, XFreePixmap → renderBackend->pixmap_free, XParseColor → WMCreateNamedColor, screen size queries → WMScreenWidth/Height. 7 remaining X11 calls are all inside #if 0 dead-code test blocks (never compiled). Architecturally clean. --- WPrefs.app/TexturePanel.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/WPrefs.app/TexturePanel.c b/WPrefs.app/TexturePanel.c index e78bd7d..7fdb79a 100644 --- a/WPrefs.app/TexturePanel.c +++ b/WPrefs.app/TexturePanel.c @@ -26,8 +26,6 @@ #include #include -#include - #include #include "WPrefs.h" @@ -421,7 +419,7 @@ static void sliderChangeCallback(WMWidget *w, void *data) colors[i] = NULL; if (panel->gimage != WM_NATIVE_NONE) - XFreePixmap(WMScreenDisplay(scr), panel->gimage); + scr->renderBackend->pixmap_free(scr->renderBackendCtx, (WMDrawable)panel->gimage); image = RRenderMultiGradient(30, i * WMGetListItemHeight(panel->gcolL), colors, RVerticalGradient); RConvertImage(WMScreenRContext(scr), image, &panel->gimage); @@ -442,9 +440,6 @@ static void paintGradListItem(WMList *lPtr, int index, WMDrawable d, char *text, WMColor *black = WMBlackColor(scr); WMColor *gray = WMGrayColor(scr); int width, height, x, y; - Display *dpy; - - dpy = WMScreenDisplay(scr); width = rect->size.width; height = rect->size.height; @@ -452,13 +447,14 @@ static void paintGradListItem(WMList *lPtr, int index, WMDrawable d, char *text, y = rect->pos.y; if (state & WLDSSelected) - XFillRectangle(dpy, d, WMColorGC(white), x, y, width, height); + WMPaintColorSwatch(white, d, x, y, width, height); else - XFillRectangle(dpy, d, WMColorGC(gray), x, y, width, height); + WMPaintColorSwatch(gray, d, x, y, width, height); if (panel->gimage) { - XCopyArea(WMScreenDisplay(scr), panel->gimage, d, WMColorGC(white), - 0, height * index, 30, height, x + 5, y); + scr->renderBackend->pixmap_copy(scr->renderBackendCtx, + (WMDrawable)panel->gimage, d, + 0, height * index, 30, height, x + 5, y); } WMDrawString(scr, d, black, panel->listFont, x + 40, y + 1, text, strlen(text)); @@ -734,12 +730,11 @@ static void changeTypeCallback(WMWidget *w, void *data) */ void ShowTexturePanel(TexturePanel *panel) { - Display *dpy = WMScreenDisplay(WMWidgetScreen(panel->win)); - Screen *scr = DefaultScreenOfDisplay(dpy); + WMScreen *scr = WMWidgetScreen(panel->win); WMSetWindowInitialPosition(panel->win, - (WidthOfScreen(scr) - WMWidgetWidth(panel->win)) / 2, - (HeightOfScreen(scr) - WMWidgetHeight(panel->win)) / 2); + (WMScreenWidth(scr) - WMWidgetWidth(panel->win)) / 2, + (WMScreenHeight(scr) - WMWidgetHeight(panel->win)) / 2); WMMapWidget(panel->win); } @@ -906,7 +901,7 @@ void SetTexturePanelTexture(TexturePanel *panel, const char *name, WMPropList *t for (i = 2; i < WMGetPropListItemCount(texture); i++) { RColor *rgb; - XColor xcolor; + WMColor *wcolor; p = WMGetFromPLArray(texture, i); if (!p) @@ -914,12 +909,13 @@ void SetTexturePanelTexture(TexturePanel *panel, const char *name, WMPropList *t else str = WMGetFromPLString(p); - XParseColor(WMScreenDisplay(scr), WMScreenRContext(scr)->cmap, str, &xcolor); + wcolor = WMCreateNamedColor(scr, str, False); rgb = wmalloc(sizeof(RColor)); - rgb->red = xcolor.red >> 8; - rgb->green = xcolor.green >> 8; - rgb->blue = xcolor.blue >> 8; + rgb->red = WMRedComponentOfColor(wcolor) >> 8; + rgb->green = WMGreenComponentOfColor(wcolor) >> 8; + rgb->blue = WMBlueComponentOfColor(wcolor) >> 8; + WMReleaseColor(wcolor); sprintf(buffer, "%02x,%02x,%02x", rgb->red, rgb->green, rgb->blue); item = WMAddListItem(panel->gcolL, buffer); @@ -1351,7 +1347,7 @@ TexturePanel *CreateTexturePanel(WMWindow *keyWindow) p = WMGetPixmapXID(pixmap); color = WMDarkGrayColor(scr); - XFillRectangle(WMScreenDisplay(scr), p, WMColorGC(color), 0, 0, 155, 18); + WMPaintColorSwatch(color, (WMDrawable)p, 0, 0, 155, 18); WMReleaseColor(color); color = WMWhiteColor(scr);