WPrefs.app: TexturePanel.c X11-free in compiled code
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.
This commit is contained in:
parent
8fe50a7001
commit
b996a0e274
|
|
@ -26,8 +26,6 @@
|
|||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include <WINGs/WINGs.h>
|
||||
|
||||
#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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue