WPrefs.app: HotCornerShortcuts.c X11-free (RImage quadrant extraction)
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.
This commit is contained in:
parent
f8a2ff12d0
commit
fabf6c01b2
|
|
@ -32,7 +32,7 @@ typedef struct _Panel {
|
||||||
|
|
||||||
WMWidget *parent;
|
WMWidget *parent;
|
||||||
WMPixmap *icon;
|
WMPixmap *icon;
|
||||||
WMNativePixmap quarter[4];
|
WMPixmap *quarter[4];
|
||||||
|
|
||||||
WMFrame *hcF;
|
WMFrame *hcF;
|
||||||
WMButton *hcB;
|
WMButton *hcB;
|
||||||
|
|
@ -207,7 +207,7 @@ static void createPanel(Panel * p)
|
||||||
RImage *xis = NULL;
|
RImage *xis = NULL;
|
||||||
WMScreen *scr = WMWidgetScreen(panel->parent);
|
WMScreen *scr = WMWidgetScreen(panel->parent);
|
||||||
RContext *rc = WMScreenRContext(scr);
|
RContext *rc = WMScreenRContext(scr);
|
||||||
GC gc = XCreateGC(scr->display, WMWidgetXID(panel->parent), 0, NULL);
|
|
||||||
|
|
||||||
path = LocateImage(ICON_FILE);
|
path = LocateImage(ICON_FILE);
|
||||||
if (path) {
|
if (path) {
|
||||||
|
|
@ -350,15 +350,19 @@ static void createPanel(Panel * p)
|
||||||
CreateImages(scr, rc, xis, ICON_FILE, &panel->icon, NULL);
|
CreateImages(scr, rc, xis, ICON_FILE, &panel->icon, NULL);
|
||||||
if (panel->icon)
|
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));
|
if (iconimg) {
|
||||||
XCopyArea(scr->display, WMGetPixmapXID(panel->icon), panel->quarter[0], gc, 0, 0, panel->icon->width/2, panel->icon->height/2, 0, 0);
|
int hw = iconimg->width / 2;
|
||||||
nicon = WMCreatePixmapFromXPixmaps(scr, panel->quarter[0], WMGetPixmapMaskXID(panel->icon),
|
int hh = iconimg->height / 2;
|
||||||
panel->icon->width/2, panel->icon->height/2, WMScreenDepth(scr));
|
RImage *q;
|
||||||
WMSetLabelImage(panel->icornerL, nicon);
|
|
||||||
WMReleasePixmap(nicon);
|
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);
|
panel->hcactionsT[0] = WMCreateTextField(panel->hcactionsF);
|
||||||
WMResizeWidget(panel->hcactionsT[0], 180, 20);
|
WMResizeWidget(panel->hcactionsT[0], 180, 20);
|
||||||
|
|
@ -368,17 +372,11 @@ static void createPanel(Panel * p)
|
||||||
WMResizeWidget(panel->icornerL, 24, 24);
|
WMResizeWidget(panel->icornerL, 24, 24);
|
||||||
WMMoveWidget(panel->icornerL, 10, 48);
|
WMMoveWidget(panel->icornerL, 10, 48);
|
||||||
WMSetLabelImagePosition(panel->icornerL, WIPImageOnly);
|
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));
|
q = RGetSubImage(iconimg, hw, 0, hw, hh);
|
||||||
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);
|
panel->quarter[1] = q ? WMCreatePixmapFromRImage(scr, q, 128) : NULL;
|
||||||
nicon = WMCreatePixmapFromXPixmaps(scr, panel->quarter[1], WMGetPixmapMaskXID(panel->icon),
|
if (q) RReleaseImage(q);
|
||||||
panel->icon->width/2, panel->icon->height/2, WMScreenDepth(scr));
|
WMSetLabelImage(panel->icornerL, panel->quarter[1]);
|
||||||
WMSetLabelImage(panel->icornerL, nicon);
|
|
||||||
WMReleasePixmap(nicon);
|
|
||||||
}
|
|
||||||
|
|
||||||
panel->hcactionsT[1] = WMCreateTextField(panel->hcactionsF);
|
panel->hcactionsT[1] = WMCreateTextField(panel->hcactionsF);
|
||||||
WMResizeWidget(panel->hcactionsT[1], 180, 20);
|
WMResizeWidget(panel->hcactionsT[1], 180, 20);
|
||||||
|
|
@ -388,17 +386,12 @@ static void createPanel(Panel * p)
|
||||||
WMResizeWidget(panel->icornerL, 24, 24);
|
WMResizeWidget(panel->icornerL, 24, 24);
|
||||||
WMMoveWidget(panel->icornerL, 10, 78);
|
WMMoveWidget(panel->icornerL, 10, 78);
|
||||||
WMSetLabelImagePosition(panel->icornerL, WIPImageOnly);
|
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));
|
q = RGetSubImage(iconimg, 0, hh, hw, hh);
|
||||||
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);
|
panel->quarter[2] = q ? WMCreatePixmapFromRImage(scr, q, 128) : NULL;
|
||||||
nicon = WMCreatePixmapFromXPixmaps(scr, panel->quarter[2], WMGetPixmapMaskXID(panel->icon),
|
if (q) RReleaseImage(q);
|
||||||
panel->icon->width/2, panel->icon->height/2, WMScreenDepth(scr));
|
WMSetLabelImage(panel->icornerL, panel->quarter[2]);
|
||||||
WMSetLabelImage(panel->icornerL, nicon);
|
|
||||||
WMReleasePixmap(nicon);
|
|
||||||
}
|
|
||||||
panel->hcactionsT[2] = WMCreateTextField(panel->hcactionsF);
|
panel->hcactionsT[2] = WMCreateTextField(panel->hcactionsF);
|
||||||
WMResizeWidget(panel->hcactionsT[2], 180, 20);
|
WMResizeWidget(panel->hcactionsT[2], 180, 20);
|
||||||
WMMoveWidget(panel->hcactionsT[2], 50, 80);
|
WMMoveWidget(panel->hcactionsT[2], 50, 80);
|
||||||
|
|
@ -407,27 +400,24 @@ static void createPanel(Panel * p)
|
||||||
WMResizeWidget(panel->icornerL, 24, 24);
|
WMResizeWidget(panel->icornerL, 24, 24);
|
||||||
WMMoveWidget(panel->icornerL, 10, 108);
|
WMMoveWidget(panel->icornerL, 10, 108);
|
||||||
WMSetLabelImagePosition(panel->icornerL, WIPImageOnly);
|
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));
|
q = RGetSubImage(iconimg, hw, hh, hw, hh);
|
||||||
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);
|
panel->quarter[3] = q ? WMCreatePixmapFromRImage(scr, q, 128) : NULL;
|
||||||
nicon = WMCreatePixmapFromXPixmaps(scr, panel->quarter[3], WMGetPixmapMaskXID(panel->icon),
|
if (q) RReleaseImage(q);
|
||||||
panel->icon->width/2, panel->icon->height/2, WMScreenDepth(scr));
|
WMSetLabelImage(panel->icornerL, panel->quarter[3]);
|
||||||
WMSetLabelImage(panel->icornerL, nicon);
|
|
||||||
WMReleasePixmap(nicon);
|
|
||||||
}
|
|
||||||
|
|
||||||
panel->hcactionsT[3] = WMCreateTextField(panel->hcactionsF);
|
panel->hcactionsT[3] = WMCreateTextField(panel->hcactionsF);
|
||||||
WMResizeWidget(panel->hcactionsT[3], 180, 20);
|
WMResizeWidget(panel->hcactionsT[3], 180, 20);
|
||||||
WMMoveWidget(panel->hcactionsT[3], 50, 107);
|
WMMoveWidget(panel->hcactionsT[3], 50, 107);
|
||||||
|
|
||||||
|
RReleaseImage(iconimg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WMMapSubwidgets(panel->hcactionsF);
|
WMMapSubwidgets(panel->hcactionsF);
|
||||||
|
|
||||||
if (xis)
|
if (xis)
|
||||||
RReleaseImage(xis);
|
RReleaseImage(xis);
|
||||||
XFreeGC(scr->display, gc);
|
|
||||||
|
|
||||||
WMRealizeWidget(panel->box);
|
WMRealizeWidget(panel->box);
|
||||||
WMMapSubwidgets(panel->box);
|
WMMapSubwidgets(panel->box);
|
||||||
|
|
@ -437,11 +427,10 @@ static void createPanel(Panel * p)
|
||||||
static void prepareForClose(_Panel *panel)
|
static void prepareForClose(_Panel *panel)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
WMScreen *scr = WMWidgetScreen(panel->parent);
|
|
||||||
|
|
||||||
WMReleasePixmap(panel->icon);
|
WMReleasePixmap(panel->icon);
|
||||||
for (i = 0; i < sizeof(panel->quarter) / sizeof(WMNativePixmap); i++)
|
for (i = 0; i < 4; i++)
|
||||||
XFreePixmap(scr->display, panel->quarter[i]);
|
if (panel->quarter[i]) WMReleasePixmap(panel->quarter[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Panel *InitHotCornerShortcuts(WMWidget *parent)
|
Panel *InitHotCornerShortcuts(WMWidget *parent)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue