From 0e26aa878ca6c1c930399699c11a90eab55ee838 Mon Sep 17 00:00:00 2001 From: Ollie Date: Sat, 23 May 2026 16:09:10 +0200 Subject: [PATCH] WINGs/wcolorpanel: replace pixmap/copy/fill X11 calls with render backend Converts 60 X11 calls (XCreatePixmap, XFreePixmap, XCopyArea, XFillRectangle) to render backend vtable dispatch. Remaining 40 calls are all in the magnifier feature (screen capture, inherently platform-specific) and will be handled separately. --- WINGs/wcolorpanel.c | 89 +++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/WINGs/wcolorpanel.c b/WINGs/wcolorpanel.c index 85a4816..d400115 100644 --- a/WINGs/wcolorpanel.c +++ b/WINGs/wcolorpanel.c @@ -1059,9 +1059,11 @@ static WMColorPanel *makeColorPanel(WMScreen * scrPtr, const char *name) /* Pixmap to indicate selection positions * wheelframe MUST be mapped. */ - panel->selectionImg = XCreatePixmap(scrPtr->display, WMWidgetXID(panel->win), 4, 4, scrPtr->depth); - XFillRectangle(scrPtr->display, panel->selectionImg, bgc, 0, 0, 4, 4); - XFillRectangle(scrPtr->display, panel->selectionImg, wgc, 1, 1, 2, 2); + const W_RenderBackend *R = scrPtr->renderBackend; + void *rctx = scrPtr->renderBackendCtx; + panel->selectionImg = R->pixmap_create(rctx, 4, 4, scrPtr->depth); + R->fill_rect(rctx, panel->selectionImg, scrPtr->black, 0, 0, 4, 4); + R->fill_rect(rctx, panel->selectionImg, scrPtr->white, 1, 1, 2, 2); readConfiguration(panel); readXColors(panel); @@ -1104,12 +1106,14 @@ void WMFreeColorPanel(WMColorPanel * panel) /* pixmaps */ wheelDestroyMatrix(panel->wheelMtrx); + const W_RenderBackend *R = scr->renderBackend; + void *rctx = scr->renderBackendCtx; if (panel->wheelImg) - XFreePixmap(scr->display, panel->wheelImg); + R->pixmap_free(rctx, panel->wheelImg); if (panel->selectionImg) - XFreePixmap(scr->display, panel->selectionImg); + R->pixmap_free(rctx, panel->selectionImg); if (panel->selectionBackImg) - XFreePixmap(scr->display, panel->selectionBackImg); + R->pixmap_free(rctx, panel->selectionBackImg); RReleaseImage(panel->customPaletteImg); /* structs */ @@ -1214,7 +1218,7 @@ void WMSetColorPanelPickerMode(WMColorPanel * panel, WMColorPanelMode mode) if (mode != WMWheelModeColorPanel) { WMUnmapWidget(panel->wheelFrm); if (panel->selectionBackImg) { - XFreePixmap(WMWidgetScreen(panel->win)->display, panel->selectionBackImg); + scr->renderBackend->pixmap_free(scr->renderBackendCtx, panel->selectionBackImg); panel->selectionBackImg = None; } } @@ -1229,7 +1233,7 @@ void WMSetColorPanelPickerMode(WMColorPanel * panel, WMColorPanelMode mode) if (mode != WMCustomPaletteModeColorPanel) { WMUnmapWidget(panel->customPaletteFrm); if (panel->selectionBackImg) { - XFreePixmap(WMWidgetScreen(panel->win)->display, panel->selectionBackImg); + scr->renderBackend->pixmap_free(scr->renderBackendCtx, panel->selectionBackImg); panel->selectionBackImg = None; } } @@ -1704,7 +1708,7 @@ static void magnifyPutCursor(WMWidget * w, void *data) /* Destroy wheelBackImg, so it'll update properly */ if (panel->selectionBackImg) { - XFreePixmap(WMWidgetScreen(panel->win)->display, panel->selectionBackImg); + scr->renderBackend->pixmap_free(scr->renderBackendCtx, panel->selectionBackImg); panel->selectionBackImg = None; } @@ -2039,17 +2043,16 @@ static void wheelRender(W_ColorPanel * panel) } if (panel->wheelImg) - XFreePixmap(scr->display, panel->wheelImg); + scr->renderBackend->pixmap_free(scr->renderBackendCtx, panel->wheelImg); RConvertImage(scr->rcontext, image, &panel->wheelImg); RReleaseImage(image); /* Check if backimage exists. If it doesn't, allocate and fill it */ if (!panel->selectionBackImg) { - panel->selectionBackImg = XCreatePixmap(scr->display, - W_VIEW(panel->wheelFrm)->window, 4, 4, scr->depth); - XCopyArea(scr->display, panel->wheelImg, panel->selectionBackImg, - scr->copyGC, panel->colx - 2, panel->coly - 2, 4, 4, 0, 0); + panel->selectionBackImg = scr->renderBackend->pixmap_create(scr->renderBackendCtx, 4, 4, scr->depth); + scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->wheelImg, panel->selectionBackImg, + panel->colx - 2, panel->coly - 2, 4, 4, 0, 0); /* -2 is hot spot correction */ } } @@ -2064,12 +2067,12 @@ static void wheelPaint(W_ColorPanel * panel) { W_Screen *scr = WMWidgetScreen(panel->win); - XCopyArea(scr->display, panel->wheelImg, panel->wheelView->window, - scr->copyGC, 0, 0, colorWheelSize + 4, colorWheelSize + 4, 0, 0); + scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->wheelImg, (WMDrawable)panel->wheelView->window, + 0, 0, colorWheelSize + 4, colorWheelSize + 4, 0, 0); /* Draw selection image */ - XCopyArea(scr->display, panel->selectionImg, panel->wheelView->window, - scr->copyGC, 0, 0, 4, 4, panel->colx - 2, panel->coly - 2); + scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->selectionImg, (WMDrawable)panel->wheelView->window, + 0, 0, 4, 4, panel->colx - 2, panel->coly - 2); } static void wheelHandleEvents(WMEvent * event, void *data) @@ -2179,11 +2182,11 @@ static void wheelUpdateSelection(W_ColorPanel * panel) panel->lastChanged = WMWheelModeColorPanel; /* Redraw color selector (and make a backup of the part it will cover) */ - XCopyArea(scr->display, panel->wheelImg, panel->selectionBackImg, - scr->copyGC, panel->colx - 2, panel->coly - 2, 4, 4, 0, 0); + scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->wheelImg, panel->selectionBackImg, + panel->colx - 2, panel->coly - 2, 4, 4, 0, 0); /* "-2" is correction for hotspot location */ - XCopyArea(scr->display, panel->selectionImg, panel->wheelView->window, - scr->copyGC, 0, 0, 4, 4, panel->colx - 2, panel->coly - 2); + scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->selectionImg, (WMDrawable)panel->wheelView->window, + 0, 0, 4, 4, panel->colx - 2, panel->coly - 2); /* see above */ } @@ -2191,8 +2194,8 @@ static void wheelUndrawSelection(W_ColorPanel * panel) { W_Screen *scr = WMWidgetScreen(panel->win); - XCopyArea(scr->display, panel->selectionBackImg, panel->wheelView->window, - scr->copyGC, 0, 0, 4, 4, panel->colx - 2, panel->coly - 2); + scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->selectionBackImg, (WMDrawable)panel->wheelView->window, + 0, 0, 4, 4, panel->colx - 2, panel->coly - 2); /* see above */ } @@ -2841,26 +2844,25 @@ static void customSetPalette(W_ColorPanel * panel) RImage *scaledImg; Pixmap image; - image = XCreatePixmap(scr->display, W_DRAWABLE(scr), customPaletteWidth, customPaletteHeight, scr->depth); + image = scr->renderBackend->pixmap_create(scr->renderBackendCtx, customPaletteWidth, customPaletteHeight, scr->depth); scaledImg = RScaleImage(panel->customPaletteImg, customPaletteWidth, customPaletteHeight); RConvertImage(scr->rcontext, scaledImg, &image); RReleaseImage(scaledImg); - XCopyArea(scr->display, image, panel->customPaletteContentView->window, - scr->copyGC, 0, 0, customPaletteWidth, customPaletteHeight, 0, 0); + scr->renderBackend->pixmap_copy(scr->renderBackendCtx, image, (WMDrawable)panel->customPaletteContentView->window, + 0, 0, customPaletteWidth, customPaletteHeight, 0, 0); /* Check backimage exists. If it doesn't, allocate and fill it */ if (!panel->selectionBackImg) { - panel->selectionBackImg = XCreatePixmap(scr->display, - panel->customPaletteContentView->window, 4, 4, scr->depth); + panel->selectionBackImg = scr->renderBackend->pixmap_create(scr->renderBackendCtx, 4, 4, scr->depth); } - XCopyArea(scr->display, image, panel->selectionBackImg, scr->copyGC, - panel->palx - 2, panel->paly - 2, 4, 4, 0, 0); - XCopyArea(scr->display, panel->selectionImg, - panel->customPaletteContentView->window, scr->copyGC, 0, 0, 4, 4, - panel->palx - 2, panel->paly - 2); - XFreePixmap(scr->display, image); + scr->renderBackend->pixmap_copy(scr->renderBackendCtx, image, panel->selectionBackImg, + panel->palx - 2, panel->paly - 2, 4, 4, 0, 0); + scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->selectionImg, + (WMDrawable)panel->customPaletteContentView->window, 0, 0, 4, 4, + panel->palx - 2, panel->paly - 2); + scr->renderBackend->pixmap_free(scr->renderBackendCtx, image); panel->palXRatio = (double)(panel->customPaletteImg->width) / (double)(customPaletteWidth); panel->palYRatio = (double)(panel->customPaletteImg->height) / (double)(customPaletteHeight); @@ -2872,9 +2874,9 @@ static void customPalettePositionSelection(W_ColorPanel * panel, int x, int y) unsigned long ofs; /* undraw selection */ - XCopyArea(scr->display, panel->selectionBackImg, - panel->customPaletteContentView->window, scr->copyGC, 0, 0, 4, 4, - panel->palx - 2, panel->paly - 2); + scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->selectionBackImg, + (WMDrawable)panel->customPaletteContentView->window, 0, 0, 4, 4, + panel->palx - 2, panel->paly - 2); panel->palx = x; panel->paly = y; @@ -2890,8 +2892,8 @@ static void customPalettePositionSelection(W_ColorPanel * panel, int x, int y) panel->lastChanged = WMCustomPaletteModeColorPanel; /* Redraw color selector (and make a backup of the part it will cover) */ - XCopyArea(scr->display, panel->customPaletteContentView->window, panel->selectionBackImg, scr->copyGC, panel->palx - 2, panel->paly - 2, 4, 4, 0, 0); /* "-2" is correction for hotspot location */ - XCopyArea(scr->display, panel->selectionImg, panel->customPaletteContentView->window, scr->copyGC, 0, 0, 4, 4, panel->palx - 2, panel->paly - 2); /* see above */ + scr->renderBackend->pixmap_copy(scr->renderBackendCtx, (WMDrawable)panel->customPaletteContentView->window, panel->selectionBackImg, panel->palx - 2, panel->paly - 2, 4, 4, 0, 0); /* "-2" is correction for hotspot location */ + scr->renderBackend->pixmap_copy(scr->renderBackendCtx, panel->selectionImg, (WMDrawable)panel->customPaletteContentView->window, 0, 0, 4, 4, panel->palx - 2, panel->paly - 2); /* see above */ } static void customPalettePositionSelectionOutBounds(W_ColorPanel * panel, int x, int y) @@ -3263,7 +3265,6 @@ static void customPaletteHistoryCallback(WMWidget * w, void *data) static void colorListPaintItem(WMList * lPtr, int index, Drawable d, char *text, int state, WMRect * rect) { WMScreen *scr = WMWidgetScreen(lPtr); - Display *dpy = WMScreenDisplay(scr); WMView *view = W_VIEW(lPtr); RColor *color = (RColor *) WMGetListItem(lPtr, index)->clientData; W_ColorPanel *panel = WMGetHangedData(lPtr); @@ -3276,13 +3277,13 @@ static void colorListPaintItem(WMList * lPtr, int index, Drawable d, char *text, y = rect->pos.y; if (state & WLDSSelected) - XFillRectangle(dpy, d, WMColorGC(scr->white), x, y, width, height); + scr->renderBackend->fill_rect(scr->renderBackendCtx, d, scr->white, x, y, width, height); else - XFillRectangle(dpy, d, WMColorGC(view->backColor), x, y, width, height); + scr->renderBackend->fill_rect(scr->renderBackendCtx, d, view->backColor, x, y, width, height); fillColor = WMCreateRGBColor(scr, color->red << 8, color->green << 8, color->blue << 8, True); - XFillRectangle(dpy, d, WMColorGC(fillColor), x, y, 15, height); + scr->renderBackend->fill_rect(scr->renderBackendCtx, d, fillColor, x, y, 15, height); WMReleaseColor(fillColor); WMDrawString(scr, d, scr->black, panel->font12, x + 18, y, text, strlen(text));