From fabf6c01b22ce7fc01a91074ef09b3f2f37fc0bf Mon Sep 17 00:00:00 2001 From: Window Maker Date: Sun, 24 May 2026 13:28:11 +0200 Subject: [PATCH] WPrefs.app: HotCornerShortcuts.c X11-free (RImage quadrant extraction) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced XCreatePixmap/XCopyArea/XCreateGC/XFreeGC/XFreePixmap with RImage-based quadrant extraction: RLoadImage → RGetSubImage for each corner → WMCreatePixmapFromRImage → WMSetLabelImage. panel->quarter[] changed from WMNativePixmap to WMPixmap*. Cleanup uses WMReleasePixmap instead of XFreePixmap. --- WPrefs.app/HotCornerShortcuts.c | 77 ++++++++++++++------------------- 1 file changed, 33 insertions(+), 44 deletions(-) diff --git a/WPrefs.app/HotCornerShortcuts.c b/WPrefs.app/HotCornerShortcuts.c index b8c944a..569b8b1 100644 --- a/WPrefs.app/HotCornerShortcuts.c +++ b/WPrefs.app/HotCornerShortcuts.c @@ -32,7 +32,7 @@ typedef struct _Panel { WMWidget *parent; WMPixmap *icon; - WMNativePixmap quarter[4]; + WMPixmap *quarter[4]; WMFrame *hcF; WMButton *hcB; @@ -207,7 +207,7 @@ static void createPanel(Panel * p) RImage *xis = NULL; WMScreen *scr = WMWidgetScreen(panel->parent); RContext *rc = WMScreenRContext(scr); - GC gc = XCreateGC(scr->display, WMWidgetXID(panel->parent), 0, NULL); + path = LocateImage(ICON_FILE); if (path) { @@ -350,15 +350,19 @@ static void createPanel(Panel * p) CreateImages(scr, rc, xis, ICON_FILE, &panel->icon, NULL); if (panel->icon) { - WMPixmap *nicon; + char *iconpath = LocateImage(ICON_FILE); + RImage *iconimg = iconpath ? RLoadImage(rc, iconpath, 0) : NULL; + if (iconpath) wfree(iconpath); - panel->quarter[0] = XCreatePixmap(scr->display, WMWidgetXID(panel->parent), panel->icon->width/2, panel->icon->height/2, WMScreenDepth(scr)); - XCopyArea(scr->display, WMGetPixmapXID(panel->icon), panel->quarter[0], gc, 0, 0, panel->icon->width/2, panel->icon->height/2, 0, 0); - nicon = WMCreatePixmapFromXPixmaps(scr, panel->quarter[0], WMGetPixmapMaskXID(panel->icon), - panel->icon->width/2, panel->icon->height/2, WMScreenDepth(scr)); - WMSetLabelImage(panel->icornerL, nicon); - WMReleasePixmap(nicon); - } + if (iconimg) { + int hw = iconimg->width / 2; + int hh = iconimg->height / 2; + RImage *q; + + q = RGetSubImage(iconimg, 0, 0, hw, hh); + panel->quarter[0] = q ? WMCreatePixmapFromRImage(scr, q, 128) : NULL; + if (q) RReleaseImage(q); + WMSetLabelImage(panel->icornerL, panel->quarter[0]); panel->hcactionsT[0] = WMCreateTextField(panel->hcactionsF); WMResizeWidget(panel->hcactionsT[0], 180, 20); @@ -368,17 +372,11 @@ static void createPanel(Panel * p) WMResizeWidget(panel->icornerL, 24, 24); WMMoveWidget(panel->icornerL, 10, 48); WMSetLabelImagePosition(panel->icornerL, WIPImageOnly); - if (panel->icon) - { - WMPixmap *nicon; - panel->quarter[1] = XCreatePixmap(scr->display, WMWidgetXID(panel->parent), panel->icon->width/2, panel->icon->height/2, WMScreenDepth(scr)); - XCopyArea(scr->display, WMGetPixmapXID(panel->icon), panel->quarter[1], gc, panel->icon->width/2, 0, panel->icon->width/2, panel->icon->height/2, 0, 0); - nicon = WMCreatePixmapFromXPixmaps(scr, panel->quarter[1], WMGetPixmapMaskXID(panel->icon), - panel->icon->width/2, panel->icon->height/2, WMScreenDepth(scr)); - WMSetLabelImage(panel->icornerL, nicon); - WMReleasePixmap(nicon); - } + q = RGetSubImage(iconimg, hw, 0, hw, hh); + panel->quarter[1] = q ? WMCreatePixmapFromRImage(scr, q, 128) : NULL; + if (q) RReleaseImage(q); + WMSetLabelImage(panel->icornerL, panel->quarter[1]); panel->hcactionsT[1] = WMCreateTextField(panel->hcactionsF); WMResizeWidget(panel->hcactionsT[1], 180, 20); @@ -388,17 +386,12 @@ static void createPanel(Panel * p) WMResizeWidget(panel->icornerL, 24, 24); WMMoveWidget(panel->icornerL, 10, 78); WMSetLabelImagePosition(panel->icornerL, WIPImageOnly); - if (panel->icon) - { - WMPixmap *nicon; - panel->quarter[2] = XCreatePixmap(scr->display, WMWidgetXID(panel->parent), panel->icon->width/2, panel->icon->height/2, WMScreenDepth(scr)); - XCopyArea(scr->display, WMGetPixmapXID(panel->icon), panel->quarter[2], gc, 0, panel->icon->height/2, panel->icon->width/2, panel->icon->height/2, 0, 0); - nicon = WMCreatePixmapFromXPixmaps(scr, panel->quarter[2], WMGetPixmapMaskXID(panel->icon), - panel->icon->width/2, panel->icon->height/2, WMScreenDepth(scr)); - WMSetLabelImage(panel->icornerL, nicon); - WMReleasePixmap(nicon); - } + q = RGetSubImage(iconimg, 0, hh, hw, hh); + panel->quarter[2] = q ? WMCreatePixmapFromRImage(scr, q, 128) : NULL; + if (q) RReleaseImage(q); + WMSetLabelImage(panel->icornerL, panel->quarter[2]); + panel->hcactionsT[2] = WMCreateTextField(panel->hcactionsF); WMResizeWidget(panel->hcactionsT[2], 180, 20); WMMoveWidget(panel->hcactionsT[2], 50, 80); @@ -407,27 +400,24 @@ static void createPanel(Panel * p) WMResizeWidget(panel->icornerL, 24, 24); WMMoveWidget(panel->icornerL, 10, 108); WMSetLabelImagePosition(panel->icornerL, WIPImageOnly); - if (panel->icon) - { - WMPixmap *nicon; - panel->quarter[3] = XCreatePixmap(scr->display, WMWidgetXID(panel->parent), panel->icon->width/2, panel->icon->height/2, WMScreenDepth(scr)); - XCopyArea(scr->display, WMGetPixmapXID(panel->icon), panel->quarter[3], gc, panel->icon->width/2, panel->icon->height/2, panel->icon->width/2, panel->icon->height/2, 0, 0); - nicon = WMCreatePixmapFromXPixmaps(scr, panel->quarter[3], WMGetPixmapMaskXID(panel->icon), - panel->icon->width/2, panel->icon->height/2, WMScreenDepth(scr)); - WMSetLabelImage(panel->icornerL, nicon); - WMReleasePixmap(nicon); - } + q = RGetSubImage(iconimg, hw, hh, hw, hh); + panel->quarter[3] = q ? WMCreatePixmapFromRImage(scr, q, 128) : NULL; + if (q) RReleaseImage(q); + WMSetLabelImage(panel->icornerL, panel->quarter[3]); panel->hcactionsT[3] = WMCreateTextField(panel->hcactionsF); WMResizeWidget(panel->hcactionsT[3], 180, 20); WMMoveWidget(panel->hcactionsT[3], 50, 107); + RReleaseImage(iconimg); + } + } + WMMapSubwidgets(panel->hcactionsF); if (xis) RReleaseImage(xis); - XFreeGC(scr->display, gc); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); @@ -437,11 +427,10 @@ static void createPanel(Panel * p) static void prepareForClose(_Panel *panel) { int i; - WMScreen *scr = WMWidgetScreen(panel->parent); WMReleasePixmap(panel->icon); - for (i = 0; i < sizeof(panel->quarter) / sizeof(WMNativePixmap); i++) - XFreePixmap(scr->display, panel->quarter[i]); + for (i = 0; i < 4; i++) + if (panel->quarter[i]) WMReleasePixmap(panel->quarter[i]); } Panel *InitHotCornerShortcuts(WMWidget *parent)