WPrefs.app: begin X11/Wayland separation
- WPrefs.h: drop #include <X11/Xlib.h>; ModifierFromKey takes WMScreen* - main.c: X11 locale calls guarded with #ifdef USE_X11_BACKEND - xmodifier.c: X11-specific modifier mapping code guarded with #ifdef USE_X11_BACKEND; Wayland mode uses sensible defaults (Mod1=Alt=Meta, Mod4=Super) - Appearance.c: all 65 Xlib calls replaced with RImage-based rendering (RCreateImage, RDrawLine, RCopyArea, RFillImage, etc.) and WMCreatePixmapFromRImage for display. previewNoText/previewBack fields changed from WMNativePixmap to RImage*. Remaining panels still have X11 calls (editmenu, Menu, TexturePanel, KeyboardShortcuts, HotCornerShortcuts, WPrefs, MouseSettings, double, Paths) — will be addressed in follow-up commits.
This commit is contained in:
parent
23f0bb320e
commit
f0d7879b23
|
|
@ -209,8 +209,8 @@ typedef struct _Panel {
|
|||
WMAlignment titleAlignment;
|
||||
|
||||
WMNativePixmap preview;
|
||||
WMNativePixmap previewNoText;
|
||||
WMNativePixmap previewBack;
|
||||
RImage *previewNoText;
|
||||
RImage *previewBack;
|
||||
|
||||
char *fprefix;
|
||||
} _Panel;
|
||||
|
|
@ -219,7 +219,7 @@ typedef struct {
|
|||
char *title;
|
||||
char *texture;
|
||||
WMPropList *prop;
|
||||
WMNativePixmap preview;
|
||||
RImage *preview;
|
||||
|
||||
char *path;
|
||||
|
||||
|
|
@ -236,6 +236,8 @@ enum {
|
|||
|
||||
static void updateColorPreviewBox(_Panel * panel, int elements);
|
||||
|
||||
static void refreshPreviewDisplay(_Panel *panel);
|
||||
|
||||
static void showData(_Panel * panel);
|
||||
|
||||
static void changePage(WMWidget * w, void *data);
|
||||
|
|
@ -442,15 +444,17 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
static void str2rcolor(RContext * rc, const char *name, RColor * color)
|
||||
static void str2rcolor(WMScreen * scr, const char *name, RColor * color)
|
||||
{
|
||||
XColor xcolor;
|
||||
WMColor *wcolor;
|
||||
|
||||
if (XParseColor(rc->dpy, rc->cmap, name, &xcolor) != 0) {
|
||||
wcolor = WMCreateNamedColor(scr, name, False);
|
||||
if (wcolor) {
|
||||
color->alpha = 255;
|
||||
color->red = xcolor.red >> 8;
|
||||
color->green = xcolor.green >> 8;
|
||||
color->blue = xcolor.blue >> 8;
|
||||
color->red = WMRedComponentOfColor(wcolor) >> 8;
|
||||
color->green = WMGreenComponentOfColor(wcolor) >> 8;
|
||||
color->blue = WMBlueComponentOfColor(wcolor) >> 8;
|
||||
WMReleaseColor(wcolor);
|
||||
} else {
|
||||
/* Color Name was not found - Return white instead */
|
||||
color->alpha = 255;
|
||||
|
|
@ -544,12 +548,11 @@ static void drawMenuBevel(RImage * img)
|
|||
}
|
||||
}
|
||||
|
||||
static WMNativePixmap renderTexture(WMScreen * scr, WMPropList * texture, int width, int height, const char *path, int border)
|
||||
static RImage *renderTexture(WMScreen * scr, WMPropList * texture, int width, int height, const char *path, int border)
|
||||
{
|
||||
char *type;
|
||||
RImage *image = NULL;
|
||||
RImage *timage = NULL;
|
||||
WMNativePixmap pixmap;
|
||||
RContext *rc = WMScreenRContext(scr);
|
||||
char *str;
|
||||
RColor rcolor;
|
||||
|
|
@ -581,7 +584,7 @@ static WMNativePixmap renderTexture(WMScreen * scr, WMPropList * texture, int wi
|
|||
|
||||
str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
|
||||
|
||||
str2rcolor(rc, str, &rcolor);
|
||||
str2rcolor(scr, str, &rcolor);
|
||||
|
||||
image = RCreateImage(width, height, False);
|
||||
RClearImage(image, &rcolor);
|
||||
|
|
@ -590,16 +593,16 @@ static WMNativePixmap renderTexture(WMScreen * scr, WMPropList * texture, int wi
|
|||
RColor c1[2], c2[2];
|
||||
|
||||
str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
|
||||
str2rcolor(rc, str, &c1[0]);
|
||||
str2rcolor(scr, str, &c1[0]);
|
||||
str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
|
||||
str2rcolor(rc, str, &c1[1]);
|
||||
str2rcolor(scr, str, &c1[1]);
|
||||
str = WMGetFromPLString(WMGetFromPLArray(texture, 3));
|
||||
t1 = atoi(str);
|
||||
|
||||
str = WMGetFromPLString(WMGetFromPLArray(texture, 4));
|
||||
str2rcolor(rc, str, &c2[0]);
|
||||
str2rcolor(scr, str, &c2[0]);
|
||||
str = WMGetFromPLString(WMGetFromPLArray(texture, 5));
|
||||
str2rcolor(rc, str, &c2[1]);
|
||||
str2rcolor(scr, str, &c2[1]);
|
||||
str = WMGetFromPLString(WMGetFromPLArray(texture, 6));
|
||||
t2 = atoi(str);
|
||||
|
||||
|
|
@ -624,9 +627,9 @@ static WMNativePixmap renderTexture(WMScreen * scr, WMPropList * texture, int wi
|
|||
}
|
||||
|
||||
str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
|
||||
str2rcolor(rc, str, &rcolor);
|
||||
str2rcolor(scr, str, &rcolor);
|
||||
str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
|
||||
str2rcolor(rc, str, &rcolor2);
|
||||
str2rcolor(scr, str, &rcolor2);
|
||||
|
||||
image = RRenderGradient(width, height, &rcolor, &rcolor2, style);
|
||||
} else if (strcasecmp(&type[2], "gradient") == 0 && toupper(type[0]) == 'T') {
|
||||
|
|
@ -651,9 +654,9 @@ static WMNativePixmap renderTexture(WMScreen * scr, WMPropList * texture, int wi
|
|||
}
|
||||
|
||||
str = WMGetFromPLString(WMGetFromPLArray(texture, 3));
|
||||
str2rcolor(rc, str, &rcolor);
|
||||
str2rcolor(scr, str, &rcolor);
|
||||
str = WMGetFromPLString(WMGetFromPLArray(texture, 4));
|
||||
str2rcolor(rc, str, &rcolor2);
|
||||
str2rcolor(scr, str, &rcolor2);
|
||||
|
||||
grad = RRenderGradient(width, height, &rcolor, &rcolor2, style);
|
||||
|
||||
|
|
@ -693,7 +696,7 @@ static WMNativePixmap renderTexture(WMScreen * scr, WMPropList * texture, int wi
|
|||
for (i = 2; i < j; i++) {
|
||||
str = WMGetFromPLString(WMGetFromPLArray(texture, i));
|
||||
colors[i - 2] = wmalloc(sizeof(RColor));
|
||||
str2rcolor(rc, str, colors[i - 2]);
|
||||
str2rcolor(scr, str, colors[i - 2]);
|
||||
}
|
||||
colors[i - 2] = NULL;
|
||||
|
||||
|
|
@ -707,7 +710,7 @@ static WMNativePixmap renderTexture(WMScreen * scr, WMPropList * texture, int wi
|
|||
RColor color;
|
||||
|
||||
str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
|
||||
str2rcolor(rc, str, &color);
|
||||
str2rcolor(scr, str, &color);
|
||||
|
||||
switch (toupper(type[0])) {
|
||||
case 'T':
|
||||
|
|
@ -728,12 +731,12 @@ static WMNativePixmap renderTexture(WMScreen * scr, WMPropList * texture, int wi
|
|||
default:
|
||||
wwarning(_("type '%s' is not a supported type for a texture"), type);
|
||||
RReleaseImage(timage);
|
||||
return WM_NATIVE_NONE;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!image)
|
||||
return WM_NATIVE_NONE;
|
||||
return NULL;
|
||||
|
||||
if (path) {
|
||||
dumpRImage(path, image);
|
||||
|
|
@ -750,29 +753,26 @@ static WMNativePixmap renderTexture(WMScreen * scr, WMPropList * texture, int wi
|
|||
RBevelImage(image, border);
|
||||
}
|
||||
|
||||
RConvertImage(rc, image, &pixmap);
|
||||
RReleaseImage(image);
|
||||
|
||||
return pixmap;
|
||||
return image;
|
||||
}
|
||||
|
||||
static WMNativePixmap renderMenu(_Panel * panel, WMPropList * texture, int width, int iheight)
|
||||
static RImage *renderMenu(_Panel * panel, WMPropList * texture, int width, int iheight)
|
||||
{
|
||||
WMScreen *scr = WMWidgetScreen(panel->parent);
|
||||
Display *dpy = WMScreenDisplay(scr);
|
||||
WMNativePixmap pix, tmp;
|
||||
GC gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
|
||||
RImage *pix, *tmp;
|
||||
int i;
|
||||
|
||||
switch (panel->menuStyle) {
|
||||
case MSTYLE_NORMAL:
|
||||
tmp = renderTexture(scr, texture, width, iheight, NULL, RBEV_RAISED2);
|
||||
if (!tmp)
|
||||
return NULL;
|
||||
|
||||
pix = XCreatePixmap(dpy, tmp, width, iheight * 4, WMScreenDepth(scr));
|
||||
pix = RCreateImage(width, iheight * 4, False);
|
||||
for (i = 0; i < 4; i++) {
|
||||
XCopyArea(dpy, tmp, pix, gc, 0, 0, width, iheight, 0, iheight * i);
|
||||
RCopyArea(pix, tmp, 0, 0, width, iheight, 0, iheight * i);
|
||||
}
|
||||
XFreePixmap(dpy, tmp);
|
||||
RReleaseImage(tmp);
|
||||
break;
|
||||
case MSTYLE_SINGLE:
|
||||
pix = renderTexture(scr, texture, width, iheight * 4, NULL, MENU_BEVEL);
|
||||
|
|
@ -781,18 +781,17 @@ static WMNativePixmap renderMenu(_Panel * panel, WMPropList * texture, int width
|
|||
pix = renderTexture(scr, texture, width, iheight * 4, NULL, RBEV_RAISED2);
|
||||
break;
|
||||
default:
|
||||
pix = WM_NATIVE_NONE;
|
||||
pix = NULL;
|
||||
}
|
||||
XFreeGC(dpy, gc);
|
||||
|
||||
return pix;
|
||||
}
|
||||
|
||||
static void renderPreview(_Panel * panel, GC gc, int part, int relief)
|
||||
static void renderPreview(_Panel * panel, int part, int relief)
|
||||
{
|
||||
WMListItem *item;
|
||||
TextureListItem *titem;
|
||||
WMNativePixmap pix;
|
||||
RImage *pix;
|
||||
WMScreen *scr = WMWidgetScreen(panel->box);
|
||||
|
||||
item = WMGetListItem(panel->texLs, panel->textureIndex[part]);
|
||||
|
|
@ -801,43 +800,29 @@ static void renderPreview(_Panel * panel, GC gc, int part, int relief)
|
|||
pix = renderTexture(scr, titem->prop,
|
||||
textureOptions[part].preview.size.width, textureOptions[part].preview.size.height,
|
||||
NULL, relief);
|
||||
if (!pix)
|
||||
return;
|
||||
|
||||
XCopyArea(WMScreenDisplay(scr), pix, panel->preview, gc, 0, 0,
|
||||
RCopyArea(panel->previewNoText, pix, 0, 0,
|
||||
textureOptions[part].preview.size.width, textureOptions[part].preview.size.height,
|
||||
textureOptions[part].preview.pos.x, textureOptions[part].preview.pos.y);
|
||||
|
||||
XCopyArea(WMScreenDisplay(scr), pix, panel->previewNoText, gc, 0, 0,
|
||||
textureOptions[part].preview.size.width, textureOptions[part].preview.size.height,
|
||||
textureOptions[part].preview.pos.x, textureOptions[part].preview.pos.y);
|
||||
|
||||
XFreePixmap(WMScreenDisplay(scr), pix);
|
||||
RReleaseImage(pix);
|
||||
}
|
||||
|
||||
static void updatePreviewBox(_Panel * panel, int elements)
|
||||
{
|
||||
WMScreen *scr = WMWidgetScreen(panel->parent);
|
||||
Display *dpy = WMScreenDisplay(scr);
|
||||
WMNativePixmap pix;
|
||||
GC gc;
|
||||
RImage *pix;
|
||||
int colorUpdate = 0;
|
||||
|
||||
gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
|
||||
|
||||
if (panel->preview == WM_NATIVE_NONE) {
|
||||
WMPixmap *p;
|
||||
|
||||
panel->previewNoText = XCreatePixmap(dpy, WMWidgetXID(panel->parent),
|
||||
240 - 4, 215 - 4, WMScreenDepth(scr));
|
||||
panel->previewBack = XCreatePixmap(dpy, WMWidgetXID(panel->parent),
|
||||
240 - 4, 215 - 4, WMScreenDepth(scr));
|
||||
|
||||
p = WMCreatePixmap(scr, 240 - 4, 215 - 4, WMScreenDepth(scr), False);
|
||||
panel->preview = WMGetPixmapXID(p);
|
||||
WMSetLabelImage(panel->prevL, p);
|
||||
WMReleasePixmap(p);
|
||||
if (panel->previewNoText == NULL) {
|
||||
panel->previewNoText = RCreateImage(240 - 4, 215 - 4, False);
|
||||
panel->previewBack = RCreateImage(240 - 4, 215 - 4, False);
|
||||
panel->preview = WM_NATIVE_NONE; /* will be created in updateColorPreviewBox */
|
||||
}
|
||||
if (elements & (1 << PBACKGROUND)) {
|
||||
WMNativePixmap tmp;
|
||||
RImage *tmp;
|
||||
TextureListItem *titem;
|
||||
WMListItem *item;
|
||||
|
||||
|
|
@ -845,31 +830,31 @@ static void updatePreviewBox(_Panel * panel, int elements)
|
|||
panel->textureIndex[PBACKGROUND]);
|
||||
titem = (TextureListItem *) item->clientData;
|
||||
tmp = renderTexture(scr, titem->prop, 240 - 4, 215 - 4, NULL, 0);
|
||||
|
||||
XCopyArea(dpy, tmp, panel->preview, gc, 0, 0, 240 - 4, 215 -4 , 0, 0);
|
||||
XCopyArea(dpy, tmp, panel->previewNoText, gc, 0, 0, 240 - 4, 215 -4 , 0, 0);
|
||||
XCopyArea(dpy, tmp, panel->previewBack, gc, 0, 0, 240 - 4, 215 -4 , 0, 0);
|
||||
XFreePixmap(dpy, tmp);
|
||||
if (tmp) {
|
||||
RCopyArea(panel->previewNoText, tmp, 0, 0, 240 - 4, 215 - 4, 0, 0);
|
||||
RCopyArea(panel->previewBack, tmp, 0, 0, 240 - 4, 215 - 4, 0, 0);
|
||||
RReleaseImage(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if (elements & (1 << PFOCUSED)) {
|
||||
renderPreview(panel, gc, PFOCUSED, RBEV_RAISED2);
|
||||
renderPreview(panel, PFOCUSED, RBEV_RAISED2);
|
||||
colorUpdate |= 1 << FTITLE_COL | 1 << FFBORDER_COL;
|
||||
}
|
||||
if (elements & (1 << PUNFOCUSED)) {
|
||||
renderPreview(panel, gc, PUNFOCUSED, RBEV_RAISED2);
|
||||
renderPreview(panel, PUNFOCUSED, RBEV_RAISED2);
|
||||
colorUpdate |= 1 << UTITLE_COL | 1 << FBORDER_COL;
|
||||
}
|
||||
if (elements & (1 << POWNER)) {
|
||||
renderPreview(panel, gc, POWNER, RBEV_RAISED2);
|
||||
renderPreview(panel, POWNER, RBEV_RAISED2);
|
||||
colorUpdate |= 1 << OTITLE_COL | 1 << FBORDER_COL;
|
||||
}
|
||||
if (elements & (1 << PRESIZEBAR)) {
|
||||
renderPreview(panel, gc, PRESIZEBAR, RESIZEBAR_BEVEL);
|
||||
renderPreview(panel, PRESIZEBAR, RESIZEBAR_BEVEL);
|
||||
colorUpdate |= 1 << FBORDER_COL;
|
||||
}
|
||||
if (elements & (1 << PMTITLE)) {
|
||||
renderPreview(panel, gc, PMTITLE, RBEV_RAISED2);
|
||||
renderPreview(panel, PMTITLE, RBEV_RAISED2);
|
||||
colorUpdate |= 1 << MTITLE_COL | 1 << FBORDER_COL;
|
||||
}
|
||||
if (elements & (1 << PMITEM)) {
|
||||
|
|
@ -882,16 +867,12 @@ static void updatePreviewBox(_Panel * panel, int elements)
|
|||
pix = renderMenu(panel, titem->prop,
|
||||
textureOptions[PMITEM].preview.size.width,
|
||||
textureOptions[PMITEM].preview.size.height / 4);
|
||||
|
||||
XCopyArea(dpy, pix, panel->preview, gc, 0, 0,
|
||||
textureOptions[PMITEM].preview.size.width, textureOptions[PMITEM].preview.size.height,
|
||||
textureOptions[PMITEM].preview.pos.x, textureOptions[PMITEM].preview.pos.y);
|
||||
|
||||
XCopyArea(dpy, pix, panel->previewNoText, gc, 0, 0,
|
||||
textureOptions[PMITEM].preview.size.width, textureOptions[PMITEM].preview.size.height,
|
||||
textureOptions[PMITEM].preview.pos.x, textureOptions[PMITEM].preview.pos.y);
|
||||
|
||||
XFreePixmap(dpy, pix);
|
||||
if (pix) {
|
||||
RCopyArea(panel->previewNoText, pix, 0, 0,
|
||||
textureOptions[PMITEM].preview.size.width, textureOptions[PMITEM].preview.size.height,
|
||||
textureOptions[PMITEM].preview.pos.x, textureOptions[PMITEM].preview.pos.y);
|
||||
RReleaseImage(pix);
|
||||
}
|
||||
|
||||
colorUpdate |= 1 << MITEM_COL | 1 << MDISAB_COL |
|
||||
1 << MHIGH_COL | 1 << MHIGHT_COL |
|
||||
|
|
@ -904,15 +885,15 @@ static void updatePreviewBox(_Panel * panel, int elements)
|
|||
item = WMGetListItem(panel->texLs, panel->textureIndex[6]);
|
||||
titem = (TextureListItem *) item->clientData;
|
||||
|
||||
renderPreview(panel, gc, PICON, titem->ispixmap ? 0 : RBEV_RAISED3);
|
||||
renderPreview(panel, PICON, titem->ispixmap ? 0 : RBEV_RAISED3);
|
||||
}
|
||||
|
||||
if (colorUpdate)
|
||||
updateColorPreviewBox(panel, colorUpdate);
|
||||
else
|
||||
else {
|
||||
refreshPreviewDisplay(panel);
|
||||
WMRedisplayWidget(panel->prevL);
|
||||
|
||||
XFreeGC(dpy, gc);
|
||||
}
|
||||
}
|
||||
|
||||
static void cancelNewTexture(void *data)
|
||||
|
|
@ -1008,7 +989,7 @@ static void okEditTexture(void *data)
|
|||
wfree(titem->texture);
|
||||
titem->texture = str;
|
||||
|
||||
XFreePixmap(WMScreenDisplay(WMWidgetScreen(panel->texLs)), titem->preview);
|
||||
RReleaseImage(titem->preview);
|
||||
titem->preview = renderTexture(WMWidgetScreen(panel->texLs), titem->prop,
|
||||
TEXPREV_WIDTH, TEXPREV_HEIGHT, titem->path, 0);
|
||||
|
||||
|
|
@ -1127,12 +1108,26 @@ static void extractTexture(WMWidget * w, void *data)
|
|||
}
|
||||
}
|
||||
|
||||
static void refreshPreviewDisplay(_Panel *panel)
|
||||
{
|
||||
WMScreen *scr = WMWidgetScreen(panel->box);
|
||||
WMPixmap *p;
|
||||
|
||||
if (!panel->previewNoText)
|
||||
return;
|
||||
|
||||
p = WMCreatePixmapFromRImage(scr, panel->previewNoText, 128);
|
||||
if (p) {
|
||||
panel->preview = WMGetPixmapXID(p);
|
||||
WMSetLabelImage(panel->prevL, p);
|
||||
WMReleasePixmap(p);
|
||||
}
|
||||
}
|
||||
|
||||
static void changePage(WMWidget * w, void *data)
|
||||
{
|
||||
_Panel *panel = (_Panel *) data;
|
||||
int section;
|
||||
WMScreen *scr = WMWidgetScreen(panel->box);
|
||||
RContext *rc = WMScreenRContext(scr);
|
||||
|
||||
if (w) {
|
||||
section = WMGetPopUpButtonSelectedItem(panel->secP);
|
||||
|
|
@ -1143,14 +1138,10 @@ static void changePage(WMWidget * w, void *data)
|
|||
|
||||
WMSetListPosition(panel->texLs, panel->textureIndex[section] - 2);
|
||||
}
|
||||
{
|
||||
GC gc;
|
||||
|
||||
gc = XCreateGC(rc->dpy, WMWidgetXID(panel->parent), 0, NULL);
|
||||
XCopyArea(rc->dpy, panel->previewBack, panel->preview, gc,
|
||||
textureOptions[panel->oldsection].hand.x, textureOptions[panel->oldsection].hand.y, 22, 22,
|
||||
textureOptions[panel->oldsection].hand.x, textureOptions[panel->oldsection].hand.y);
|
||||
}
|
||||
/* Refresh display from previewNoText (erases old hand) */
|
||||
refreshPreviewDisplay(panel);
|
||||
|
||||
if (w) {
|
||||
panel->oldsection = section;
|
||||
WMDrawPixmap(panel->hand, panel->preview, textureOptions[section].hand.x, textureOptions[section].hand.y);
|
||||
|
|
@ -1267,8 +1258,9 @@ static void paintListItem(WMList * lPtr, int index, WMDrawable d, char *text, in
|
|||
{
|
||||
_Panel *panel = (_Panel *) WMGetHangedData(lPtr);
|
||||
WMScreen *scr = WMWidgetScreen(lPtr);
|
||||
const W_RenderBackend *R = scr->renderBackend;
|
||||
void *rctx = scr->renderBackendCtx;
|
||||
int width, height, x, y, tmp;
|
||||
Display *dpy = WMScreenDisplay(scr);
|
||||
WMColor *back = (state & WLDSSelected) ? WMWhiteColor(scr) : WMGrayColor(scr);
|
||||
WMListItem *item;
|
||||
WMColor *black = WMBlackColor(scr);
|
||||
|
|
@ -1290,11 +1282,16 @@ static void paintListItem(WMList * lPtr, int index, WMDrawable d, char *text, in
|
|||
x = rect->pos.x;
|
||||
y = rect->pos.y;
|
||||
|
||||
XFillRectangle(dpy, d, WMColorGC(back), x, y, width, height);
|
||||
R->fill_rect(rctx, d, back, x, y, width, height);
|
||||
|
||||
if (titem->preview)
|
||||
XCopyArea(dpy, titem->preview, d, WMColorGC(black), 0, 0,
|
||||
TEXPREV_WIDTH, TEXPREV_HEIGHT, x + 5, y + 5);
|
||||
if (titem->preview) {
|
||||
WMPixmap *pm = WMCreatePixmapFromRImage(scr, titem->preview, 128);
|
||||
if (pm) {
|
||||
R->composite_pixmap(rctx, d, pm, 0, 0,
|
||||
TEXPREV_WIDTH, TEXPREV_HEIGHT, x + 5, y + 5);
|
||||
WMReleasePixmap(pm);
|
||||
}
|
||||
}
|
||||
|
||||
tmp = WMGetPopUpButtonSelectedItem(panel->secP);
|
||||
if ((tmp >= 0) && ((1 << tmp) & titem->selectedFor))
|
||||
|
|
@ -1312,47 +1309,46 @@ static void paintListItem(WMList * lPtr, int index, WMDrawable d, char *text, in
|
|||
WMReleaseColor(black);
|
||||
}
|
||||
|
||||
static WMNativePixmap loadRImage(WMScreen * scr, const char *path)
|
||||
static RImage *loadRImage(WMScreen * scr, const char *path)
|
||||
{
|
||||
FILE *f;
|
||||
RImage *image;
|
||||
int w, h, d, cnt;
|
||||
size_t read_size;
|
||||
WMNativePixmap pixmap;
|
||||
|
||||
(void) scr;
|
||||
|
||||
f = fopen(path, "rb");
|
||||
if (!f)
|
||||
return WM_NATIVE_NONE;
|
||||
return NULL;
|
||||
|
||||
cnt = fscanf(f, "%02x%02x%1x", &w, &h, &d);
|
||||
if (cnt != 3) {
|
||||
wwarning(_("could not read size of image from '%s', ignoring"), path);
|
||||
fclose(f);
|
||||
return WM_NATIVE_NONE;
|
||||
return NULL;
|
||||
}
|
||||
if (d < 3 || d > 4) {
|
||||
wwarning(_("image \"%s\" has an invalid depth of %d, ignoring"), path, d);
|
||||
fclose(f);
|
||||
return WM_NATIVE_NONE;
|
||||
return NULL;
|
||||
}
|
||||
image = RCreateImage(w, h, d == 4);
|
||||
if (image == NULL) {
|
||||
wwarning(_("could not create RImage for \"%s\": %s"),
|
||||
path, RMessageForError(RErrorCode));
|
||||
fclose(f);
|
||||
return WM_NATIVE_NONE;
|
||||
return NULL;
|
||||
}
|
||||
read_size = w * h * d;
|
||||
if (fread(image->data, 1, read_size, f) == read_size)
|
||||
RConvertImage(WMScreenRContext(scr), image, &pixmap);
|
||||
else
|
||||
pixmap = WM_NATIVE_NONE;
|
||||
if (fread(image->data, 1, read_size, f) != read_size) {
|
||||
RReleaseImage(image);
|
||||
image = NULL;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
RReleaseImage(image);
|
||||
|
||||
return pixmap;
|
||||
return image;
|
||||
}
|
||||
|
||||
static void fillTextureList(WMList * lPtr)
|
||||
|
|
@ -1429,25 +1425,16 @@ static void changeColorPage(WMWidget * w, void *data)
|
|||
{
|
||||
_Panel *panel = (_Panel *) data;
|
||||
int section;
|
||||
WMScreen *scr = WMWidgetScreen(panel->box);
|
||||
RContext *rc = WMScreenRContext(scr);
|
||||
|
||||
section = WMGetPopUpButtonSelectedItem(panel->colP);
|
||||
if (section < 0)
|
||||
return;
|
||||
|
||||
if (panel->preview) {
|
||||
GC gc;
|
||||
/* Refresh display from previewNoText (erases old hand) */
|
||||
if (panel->previewNoText)
|
||||
refreshPreviewDisplay(panel);
|
||||
|
||||
gc = XCreateGC(rc->dpy, WMWidgetXID(panel->parent), 0, NULL);
|
||||
XCopyArea(rc->dpy, panel->previewBack, panel->preview, gc,
|
||||
colorOptions[panel->oldcsection].hand.x,
|
||||
colorOptions[panel->oldcsection].hand.y, 22, 22 ,
|
||||
colorOptions[panel->oldcsection].hand.x,
|
||||
colorOptions[panel->oldcsection].hand.y);
|
||||
}
|
||||
if (w) {
|
||||
|
||||
panel->oldcsection = section;
|
||||
if (panel->preview)
|
||||
WMDrawPixmap(panel->hand, panel->preview,
|
||||
|
|
@ -1482,139 +1469,103 @@ paintText(WMScreen * scr, WMDrawable d, WMColor * color, WMFont * font,
|
|||
WMDrawString(scr, d, color, font, x, y + (h - WMFontHeight(font)) / 2, text, l);
|
||||
}
|
||||
|
||||
static void wmcolor2rcolor(WMColor *wc, RColor *rc)
|
||||
{
|
||||
rc->red = WMRedComponentOfColor(wc) >> 8;
|
||||
rc->green = WMGreenComponentOfColor(wc) >> 8;
|
||||
rc->blue = WMBlueComponentOfColor(wc) >> 8;
|
||||
rc->alpha = 255;
|
||||
}
|
||||
|
||||
static void RFillRect(RImage *img, int x, int y, int w, int h, const RColor *color)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < h; i++)
|
||||
RDrawLine(img, x, y + i, x + w - 1, y + i, color);
|
||||
}
|
||||
|
||||
static void RDrawRect(RImage *img, int x, int y, int w, int h, const RColor *color)
|
||||
{
|
||||
RDrawLine(img, x, y, x + w, y, color);
|
||||
RDrawLine(img, x, y + h, x + w, y + h, color);
|
||||
RDrawLine(img, x, y, x, y + h, color);
|
||||
RDrawLine(img, x + w, y, x + w, y + h, color);
|
||||
}
|
||||
|
||||
static void RFillTriangle(RImage *img, int x0, int y0, int x1, int y1, int x2, int y2, const RColor *color)
|
||||
{
|
||||
/* Simple scanline fill for a convex triangle */
|
||||
int ymin = y0, ymax = y0;
|
||||
int y;
|
||||
if (y1 < ymin) ymin = y1;
|
||||
if (y2 < ymin) ymin = y2;
|
||||
if (y1 > ymax) ymax = y1;
|
||||
if (y2 > ymax) ymax = y2;
|
||||
|
||||
for (y = ymin; y <= ymax; y++) {
|
||||
int xmin = img->width, xmax = -1;
|
||||
int edges[3][4] = {{x0,y0,x1,y1},{x1,y1,x2,y2},{x2,y2,x0,y0}};
|
||||
int e;
|
||||
for (e = 0; e < 3; e++) {
|
||||
int ex0 = edges[e][0], ey0 = edges[e][1];
|
||||
int ex1 = edges[e][2], ey1 = edges[e][3];
|
||||
if ((ey0 <= y && ey1 >= y) || (ey1 <= y && ey0 >= y)) {
|
||||
int dy = ey1 - ey0;
|
||||
int x;
|
||||
if (dy == 0) {
|
||||
x = ex0 < ex1 ? ex0 : ex1;
|
||||
if (x < xmin) xmin = x;
|
||||
x = ex0 > ex1 ? ex0 : ex1;
|
||||
if (x > xmax) xmax = x;
|
||||
} else {
|
||||
x = ex0 + (y - ey0) * (ex1 - ex0) / dy;
|
||||
if (x < xmin) xmin = x;
|
||||
if (x > xmax) xmax = x;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (xmin <= xmax)
|
||||
RDrawLine(img, xmin, y, xmax, y, color);
|
||||
}
|
||||
}
|
||||
|
||||
static void updateColorPreviewBox(_Panel * panel, int elements)
|
||||
{
|
||||
WMScreen *scr = WMWidgetScreen(panel->box);
|
||||
Display *dpy = WMScreenDisplay(scr);
|
||||
WMNativePixmap d, pnot;
|
||||
GC gc;
|
||||
RImage *pnot;
|
||||
WMDrawable d;
|
||||
RColor rc;
|
||||
|
||||
d = panel->preview;
|
||||
pnot = panel->previewNoText;
|
||||
gc = WMColorGC(panel->colors[FTITLE_COL]);
|
||||
if (!pnot)
|
||||
return;
|
||||
|
||||
if (elements & (1 << FTITLE_COL)) {
|
||||
XCopyArea(dpy, pnot, d, gc, 30, 10, 190, 20, 30, 10);
|
||||
paintText(scr, d, panel->colors[FTITLE_COL],
|
||||
panel->boldFont, 30, 10, 190, 20,
|
||||
panel->titleAlignment, _("Focused WNativeWindow"));
|
||||
}
|
||||
if (elements & (1 << UTITLE_COL)) {
|
||||
XCopyArea(dpy, pnot, d, gc, 30, 40, 190, 20, 30, 40);
|
||||
paintText(scr, d, panel->colors[UTITLE_COL],
|
||||
panel->boldFont, 30, 40, 190, 20,
|
||||
panel->titleAlignment,
|
||||
_("Unfocused WNativeWindow"));
|
||||
}
|
||||
if (elements & (1 << OTITLE_COL)) {
|
||||
XCopyArea(dpy, pnot, d, gc, 30, 70, 190, 20, 30, 70);
|
||||
paintText(scr, d, panel->colors[OTITLE_COL],
|
||||
panel->boldFont, 30, 70, 190, 20,
|
||||
panel->titleAlignment,
|
||||
_("Owner of Focused WNativeWindow"));
|
||||
}
|
||||
if (elements & (1 << MTITLE_COL)) {
|
||||
XCopyArea(dpy, pnot, d, gc, 30, 120, 90, 20, 30, 120);
|
||||
paintText(scr, d, panel->colors[MTITLE_COL],
|
||||
panel->boldFont, 30, 120, 90, 20, WALeft,
|
||||
_("Menu Title"));
|
||||
}
|
||||
if (elements & (1 << MITEM_COL)) {
|
||||
XCopyArea(dpy, pnot, d, gc, 30, 140, 90, 20, 30, 140);
|
||||
paintText(scr, d, panel->colors[MITEM_COL],
|
||||
panel->normalFont, 30, 140, 90, 20, WALeft,
|
||||
_("Normal Item"));
|
||||
XCopyArea(dpy, pnot, d, gc, 30, 200, 90, 20, 30, 200);
|
||||
paintText(scr, d, panel->colors[MITEM_COL],
|
||||
panel->normalFont, 30, 200, 90, 20, WALeft,
|
||||
_("Normal Item"));
|
||||
}
|
||||
if (elements & (1 << MDISAB_COL)) {
|
||||
XCopyArea(dpy, pnot, d, gc, 30, 160, 90, 20, 30, 160);
|
||||
paintText(scr, d, panel->colors[MDISAB_COL],
|
||||
panel->normalFont, 30, 160, 90, 20, WALeft,
|
||||
_("Disabled Item"));
|
||||
}
|
||||
if (elements & (1 << MHIGH_COL)) {
|
||||
XFillRectangle(WMScreenDisplay(scr), d,
|
||||
WMColorGC(panel->colors[MHIGH_COL]),
|
||||
31, 181, 87, 17);
|
||||
XFillRectangle(WMScreenDisplay(scr), pnot,
|
||||
WMColorGC(panel->colors[MHIGH_COL]),
|
||||
31, 181, 87, 17);
|
||||
wmcolor2rcolor(panel->colors[MHIGH_COL], &rc);
|
||||
RFillRect(pnot, 31, 181, 87, 17, &rc);
|
||||
elements |= 1 << MHIGHT_COL;
|
||||
}
|
||||
if (elements & (1 << MHIGHT_COL)) {
|
||||
XCopyArea(dpy, pnot, d, gc, 30, 180, 90, 20, 30, 180);
|
||||
paintText(scr, d, panel->colors[MHIGHT_COL],
|
||||
panel->normalFont, 30, 180, 90, 20, WALeft,
|
||||
_("Highlighted"));
|
||||
}
|
||||
if (elements & (1 << FBORDER_COL)) {
|
||||
XDrawRectangle(dpy, pnot,
|
||||
WMColorGC(panel->colors[FBORDER_COL]),
|
||||
29, 39, 190, 20);
|
||||
XDrawRectangle(dpy, d,
|
||||
WMColorGC(panel->colors[FBORDER_COL]),
|
||||
29, 39, 190, 20);
|
||||
XDrawRectangle(dpy, pnot,
|
||||
WMColorGC(panel->colors[FBORDER_COL]),
|
||||
29, 69, 190, 20);
|
||||
XDrawRectangle(dpy, d,
|
||||
WMColorGC(panel->colors[FBORDER_COL]),
|
||||
29, 69, 190, 20);
|
||||
XDrawLine(dpy, pnot,
|
||||
WMColorGC(panel->colors[FBORDER_COL]),
|
||||
30, 100, 30, 109);
|
||||
XDrawLine(dpy, d,
|
||||
WMColorGC(panel->colors[FBORDER_COL]),
|
||||
30, 100, 30, 109);
|
||||
XDrawLine(dpy, pnot,
|
||||
WMColorGC(panel->colors[FBORDER_COL]),
|
||||
31, 109, 219, 109);
|
||||
XDrawLine(dpy, d,
|
||||
WMColorGC(panel->colors[FBORDER_COL]),
|
||||
31, 109, 219, 109);
|
||||
XDrawLine(dpy, pnot,
|
||||
WMColorGC(panel->colors[FBORDER_COL]),
|
||||
220, 100, 220, 109);
|
||||
XDrawLine(dpy, d,
|
||||
WMColorGC(panel->colors[FBORDER_COL]),
|
||||
220, 100, 220, 109);
|
||||
XDrawLine(dpy, pnot,
|
||||
WMColorGC(panel->colors[FBORDER_COL]),
|
||||
29, 120, 29, 220);
|
||||
XDrawLine(dpy, d,
|
||||
WMColorGC(panel->colors[FBORDER_COL]),
|
||||
29, 120, 29, 220);
|
||||
XDrawLine(dpy, pnot,
|
||||
WMColorGC(panel->colors[FBORDER_COL]),
|
||||
29, 119, 119, 119);
|
||||
XDrawLine(dpy, d,
|
||||
WMColorGC(panel->colors[FBORDER_COL]),
|
||||
29, 119, 119, 119);
|
||||
XDrawLine(dpy, pnot,
|
||||
WMColorGC(panel->colors[FBORDER_COL]),
|
||||
119, 120, 119, 220);
|
||||
XDrawLine(dpy, d,
|
||||
WMColorGC(panel->colors[FBORDER_COL]),
|
||||
119, 120, 119, 220);
|
||||
wmcolor2rcolor(panel->colors[FBORDER_COL], &rc);
|
||||
RDrawRect(pnot, 29, 39, 190, 20, &rc);
|
||||
RDrawRect(pnot, 29, 69, 190, 20, &rc);
|
||||
RDrawLine(pnot, 30, 100, 30, 109, &rc);
|
||||
RDrawLine(pnot, 31, 109, 219, 109, &rc);
|
||||
RDrawLine(pnot, 220, 100, 220, 109, &rc);
|
||||
RDrawLine(pnot, 29, 120, 29, 220, &rc);
|
||||
RDrawLine(pnot, 29, 119, 119, 119, &rc);
|
||||
RDrawLine(pnot, 119, 120, 119, 220, &rc);
|
||||
}
|
||||
|
||||
if (elements & (1 << FFBORDER_COL)) {
|
||||
XDrawRectangle(dpy, pnot,
|
||||
WMColorGC(panel->colors[FFBORDER_COL]),
|
||||
29, 9, 190, 20);
|
||||
XDrawRectangle(dpy, d,
|
||||
WMColorGC(panel->colors[FFBORDER_COL]),
|
||||
29, 9, 190, 20);
|
||||
wmcolor2rcolor(panel->colors[FFBORDER_COL], &rc);
|
||||
RDrawRect(pnot, 29, 9, 190, 20, &rc);
|
||||
}
|
||||
|
||||
if (elements & (1 << ICONT_COL) || elements & (1 << ICONB_COL)) {
|
||||
RColor rgb;
|
||||
RHSVColor hsv, hsv2;
|
||||
int v;
|
||||
WMColor *light, *dim;
|
||||
RColor lightc, dimc;
|
||||
|
||||
updatePreviewBox(panel, 1 << PICON);
|
||||
|
||||
|
|
@ -1627,41 +1578,35 @@ static void updateColorPreviewBox(_Panel * panel, int elements)
|
|||
|
||||
v = hsv.value * 16 / 10;
|
||||
hsv.value = (v > 255 ? 255 : v);
|
||||
RHSVtoRGB(&hsv, &rgb);
|
||||
light = WMCreateRGBColor(scr, rgb.red << 8, rgb.green << 8, rgb.blue << 8, False);
|
||||
RHSVtoRGB(&hsv, &lightc);
|
||||
lightc.alpha = 255;
|
||||
|
||||
hsv2.value = hsv2.value / 2;
|
||||
RHSVtoRGB(&hsv2, &rgb);
|
||||
dim = WMCreateRGBColor(scr, rgb.red << 8, rgb.green << 8, rgb.blue << 8, False);
|
||||
RHSVtoRGB(&hsv2, &dimc);
|
||||
dimc.alpha = 255;
|
||||
|
||||
XFillRectangle(dpy, d, WMColorGC(panel->colors[ICONB_COL]), 156, 131, 62, 11);
|
||||
XDrawLine(dpy, d, WMColorGC(light), 155, 130, 155, 142);
|
||||
XDrawLine(dpy, d, WMColorGC(light), 156, 130, 217, 130);
|
||||
XDrawLine(dpy, d, WMColorGC(dim), 218, 130, 218, 142);
|
||||
|
||||
paintText(scr, d, panel->colors[ICONT_COL],
|
||||
panel->smallFont, 155, 130, 64, 13, WALeft,
|
||||
_("Icon Text"));
|
||||
|
||||
WMReleaseColor(light);
|
||||
WMReleaseColor(dim);
|
||||
wmcolor2rcolor(panel->colors[ICONB_COL], &rc);
|
||||
RFillRect(pnot, 156, 131, 62, 11, &rc);
|
||||
RDrawLine(pnot, 155, 130, 155, 142, &lightc);
|
||||
RDrawLine(pnot, 156, 130, 217, 130, &lightc);
|
||||
RDrawLine(pnot, 218, 130, 218, 142, &dimc);
|
||||
}
|
||||
|
||||
if (elements & (1 << CLIP_COL) || elements & (1 << CCLIP_COL)) {
|
||||
WMNativePixmap pix;
|
||||
RColor black;
|
||||
RColor dark;
|
||||
RColor light;
|
||||
RImage *tile;
|
||||
TextureListItem *titem;
|
||||
WMListItem *item;
|
||||
XPoint p[4];
|
||||
RColor clipc;
|
||||
|
||||
item = WMGetListItem(panel->texLs, panel->textureIndex[PICON]);
|
||||
titem = (TextureListItem *) item->clientData;
|
||||
|
||||
pix = renderTexture(scr, titem->prop, 64, 64, NULL, titem->ispixmap ? 0 : RBEV_RAISED3);
|
||||
tile = RCreateImageFromDrawable(WMScreenRContext(scr), pix, WM_NATIVE_NONE);
|
||||
tile = renderTexture(scr, titem->prop, 64, 64, NULL, titem->ispixmap ? 0 : RBEV_RAISED3);
|
||||
if (!tile)
|
||||
goto skip_clip;
|
||||
|
||||
black.alpha = 255;
|
||||
black.red = black.green = black.blue = 0;
|
||||
|
|
@ -1692,34 +1637,73 @@ static void updateColorPreviewBox(_Panel * panel, int elements)
|
|||
ROperateLine(tile, RSubtractOperation, 5, 64 - 6 - (23 - 15), 6 + 23 - 15, 64 - 5, &dark);
|
||||
ROperateLine(tile, RAddOperation, 4, 64 - 5, 6 + 23 - 15, 64 - 5, &light);
|
||||
|
||||
RConvertImage(WMScreenRContext(scr), tile, &pix);
|
||||
/* Copy tile to previewNoText */
|
||||
RCopyArea(pnot, tile, 0, 0, 64, 64, 155, 130);
|
||||
RReleaseImage(tile);
|
||||
|
||||
XCopyArea(dpy, pix, d, gc, 0, 0, 64, 64, 155, 130);
|
||||
XFreePixmap(dpy, pix);
|
||||
|
||||
/* top right arrow */
|
||||
p[0].x = p[3].x = 155 + 64 - 5 - (23 - 15);
|
||||
p[0].y = p[3].y = 130 + 5;
|
||||
p[1].x = 155 + 64 - 6;
|
||||
p[1].y = 130 + 5;
|
||||
p[2].x = 155 + 64 - 6;
|
||||
p[2].y = 130 + 4 + 23 - 15;
|
||||
|
||||
XFillPolygon(dpy, d, WMColorGC(panel->colors[CLIP_COL]), p, 3, Convex, CoordModeOrigin);
|
||||
XDrawLines(dpy, d, WMColorGC(panel->colors[CLIP_COL]), p, 4, CoordModeOrigin);
|
||||
wmcolor2rcolor(panel->colors[CLIP_COL], &clipc);
|
||||
RFillTriangle(pnot,
|
||||
155 + 64 - 5 - (23 - 15), 130 + 5,
|
||||
155 + 64 - 6, 130 + 5,
|
||||
155 + 64 - 6, 130 + 4 + 23 - 15, &clipc);
|
||||
|
||||
/* bottom left arrow */
|
||||
p[0].x = p[3].x = 155 + 5;
|
||||
p[0].y = p[3].y = 130 + 64 - 5 - (23 - 15);
|
||||
p[1].x = 155 + 5;
|
||||
p[1].y = 130 + 64 - 6;
|
||||
p[2].x = 155 + 4 + 23 - 15;
|
||||
p[2].y = 130 + 64 - 6;
|
||||
RFillTriangle(pnot,
|
||||
155 + 5, 130 + 64 - 5 - (23 - 15),
|
||||
155 + 5, 130 + 64 - 6,
|
||||
155 + 4 + 23 - 15, 130 + 64 - 6, &clipc);
|
||||
skip_clip: ;
|
||||
}
|
||||
|
||||
XFillPolygon(dpy, d, WMColorGC(panel->colors[CLIP_COL]), p, 3, Convex, CoordModeOrigin);
|
||||
XDrawLines(dpy, d, WMColorGC(panel->colors[CLIP_COL]), p, 4, CoordModeOrigin);
|
||||
/* Convert previewNoText to display pixmap, then draw text on it */
|
||||
refreshPreviewDisplay(panel);
|
||||
d = panel->preview;
|
||||
|
||||
if (elements & (1 << FTITLE_COL)) {
|
||||
paintText(scr, d, panel->colors[FTITLE_COL],
|
||||
panel->boldFont, 30, 10, 190, 20,
|
||||
panel->titleAlignment, _("Focused WNativeWindow"));
|
||||
}
|
||||
if (elements & (1 << UTITLE_COL)) {
|
||||
paintText(scr, d, panel->colors[UTITLE_COL],
|
||||
panel->boldFont, 30, 40, 190, 20,
|
||||
panel->titleAlignment,
|
||||
_("Unfocused WNativeWindow"));
|
||||
}
|
||||
if (elements & (1 << OTITLE_COL)) {
|
||||
paintText(scr, d, panel->colors[OTITLE_COL],
|
||||
panel->boldFont, 30, 70, 190, 20,
|
||||
panel->titleAlignment,
|
||||
_("Owner of Focused WNativeWindow"));
|
||||
}
|
||||
if (elements & (1 << MTITLE_COL)) {
|
||||
paintText(scr, d, panel->colors[MTITLE_COL],
|
||||
panel->boldFont, 30, 120, 90, 20, WALeft,
|
||||
_("Menu Title"));
|
||||
}
|
||||
if (elements & (1 << MITEM_COL)) {
|
||||
paintText(scr, d, panel->colors[MITEM_COL],
|
||||
panel->normalFont, 30, 140, 90, 20, WALeft,
|
||||
_("Normal Item"));
|
||||
paintText(scr, d, panel->colors[MITEM_COL],
|
||||
panel->normalFont, 30, 200, 90, 20, WALeft,
|
||||
_("Normal Item"));
|
||||
}
|
||||
if (elements & (1 << MDISAB_COL)) {
|
||||
paintText(scr, d, panel->colors[MDISAB_COL],
|
||||
panel->normalFont, 30, 160, 90, 20, WALeft,
|
||||
_("Disabled Item"));
|
||||
}
|
||||
if (elements & (1 << MHIGHT_COL)) {
|
||||
paintText(scr, d, panel->colors[MHIGHT_COL],
|
||||
panel->normalFont, 30, 180, 90, 20, WALeft,
|
||||
_("Highlighted"));
|
||||
}
|
||||
if (elements & (1 << ICONT_COL) || elements & (1 << ICONB_COL)) {
|
||||
paintText(scr, d, panel->colors[ICONT_COL],
|
||||
panel->smallFont, 155, 130, 64, 13, WALeft,
|
||||
_("Icon Text"));
|
||||
}
|
||||
|
||||
if (elements & (1 << CLIP_COL))
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ static void showData(_Panel * panel)
|
|||
/**/ str = GetStringForKey("ModifierKey");
|
||||
if (!str)
|
||||
str = "mod1";
|
||||
a = ModifierFromKey(dpy, str);
|
||||
a = ModifierFromKey(WMWidgetScreen(panel->parent), str);
|
||||
|
||||
if (a != -1) {
|
||||
str = modifierNames[a];
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@
|
|||
#include <strings.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include <wraster.h>
|
||||
|
||||
#include <WINGs/WINGs.h>
|
||||
|
|
@ -141,7 +139,7 @@ void AddDeadChildHandler(pid_t pid, void (*handler)(void*), void *data);
|
|||
|
||||
|
||||
/* ---[ xmodifier.c ] ---------------------------------------------------- */
|
||||
int ModifierFromKey(Display * dpy, const char *key);
|
||||
int ModifierFromKey(WMScreen *scr, const char *key);
|
||||
|
||||
|
||||
/* ---[ Panel Initializers ]---------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -24,8 +24,11 @@
|
|||
|
||||
#include <assert.h>
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
#ifdef USE_X11_BACKEND
|
||||
#include <X11/Xlocale.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#endif
|
||||
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
|
@ -137,6 +140,7 @@ int main(int argc, char **argv)
|
|||
|
||||
/* X11 locale checks only meaningful in X11 mode. In Wayland mode
|
||||
* locale handling is delegated to xkbcommon / glib. */
|
||||
#ifdef USE_X11_BACKEND
|
||||
if (!getenv("WAYLAND_DISPLAY") || getenv("DISPLAY")) {
|
||||
if (!XSupportsLocale()) {
|
||||
wwarning(_("X server does not support locale"));
|
||||
|
|
@ -145,6 +149,7 @@ int main(int argc, char **argv)
|
|||
wwarning(_("cannot set locale modifiers"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* WMOpenScreen autodetects Wayland-client mode (WAYLAND_DISPLAY set
|
||||
|
|
|
|||
|
|
@ -33,12 +33,17 @@ Perpetrator: Sudish Joseph <sj@eng.mindspring.net>, Sept. 1997. */
|
|||
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include "../src/wconfig.h"
|
||||
|
||||
#ifdef USE_X11_BACKEND
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include <WINGs/WINGsX11.h>
|
||||
#endif
|
||||
|
||||
#include <WINGs/WUtil.h>
|
||||
#include <WINGs/WINGsX11.h>
|
||||
|
||||
#include "WPrefs.h"
|
||||
|
||||
|
|
@ -46,6 +51,29 @@ Perpetrator: Sudish Joseph <sj@eng.mindspring.net>, Sept. 1997. */
|
|||
/* keymap handling */
|
||||
/************************************************************************/
|
||||
|
||||
/* Modifier index results — populated by x_reset_modifier_mapping on X11,
|
||||
* or left at defaults (Mod1=Alt=Meta, Mod4=Super) on Wayland. */
|
||||
|
||||
/* X11 modifier map indices — values match <X11/X.h>. */
|
||||
#ifndef ShiftMapIndex
|
||||
#define ShiftMapIndex 0
|
||||
#define LockMapIndex 1
|
||||
#define ControlMapIndex 2
|
||||
#define Mod1MapIndex 3
|
||||
#define Mod2MapIndex 4
|
||||
#define Mod3MapIndex 5
|
||||
#define Mod4MapIndex 6
|
||||
#define Mod5MapIndex 7
|
||||
#endif
|
||||
|
||||
static int MetaIndex = Mod1MapIndex;
|
||||
static int HyperIndex = 0;
|
||||
static int SuperIndex = Mod4MapIndex;
|
||||
static int AltIndex = Mod1MapIndex;
|
||||
static int ModeIndex = 0;
|
||||
|
||||
#ifdef USE_X11_BACKEND
|
||||
|
||||
/* X bogusly doesn't define the interpretations of any bits besides
|
||||
ModControl, ModShift, and ModLock; so the Interclient Communication
|
||||
Conventions Manual says that we have to bend over backwards to figure
|
||||
|
|
@ -86,7 +114,6 @@ Perpetrator: Sudish Joseph <sj@eng.mindspring.net>, Sept. 1997. */
|
|||
use a pop-up-window instead.)
|
||||
*/
|
||||
|
||||
static int MetaIndex, HyperIndex, SuperIndex, AltIndex, ModeIndex;
|
||||
|
||||
static const char *index_to_name(int indice)
|
||||
{
|
||||
|
|
@ -277,13 +304,20 @@ static void x_reset_modifier_mapping(Display * display)
|
|||
XFreeModifiermap(x_modifier_keymap);
|
||||
}
|
||||
|
||||
int ModifierFromKey(Display * dpy, const char *key)
|
||||
#endif /* USE_X11_BACKEND */
|
||||
|
||||
int ModifierFromKey(WMScreen *scr, const char *key)
|
||||
{
|
||||
#ifdef USE_X11_BACKEND
|
||||
Display *dpy = WMScreenDisplay(scr);
|
||||
static int eqw = 0;
|
||||
|
||||
if (!eqw)
|
||||
x_reset_modifier_mapping(dpy);
|
||||
eqw = 1;
|
||||
#else
|
||||
(void)scr;
|
||||
#endif
|
||||
|
||||
if (strcasecmp(key, "SHIFT") == 0)
|
||||
return ShiftMapIndex;
|
||||
|
|
|
|||
Loading…
Reference in New Issue