mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-29 03:16:01 +01:00
WPrefs: Set workspace background
This patch enables users to set the workspace background (WorkspaceBack) in the Appearance Preferences section of WPrefs. It appears as a new item in the popup menu in the Texture tab, in the list of textures below, and a preview appears in the background of the preview panel on the left.
This commit is contained in:
committed by
Carlos R. Mafra
parent
a325624b4a
commit
66556c421d
@@ -108,6 +108,7 @@ typedef struct _Panel {
|
|||||||
|
|
||||||
Pixmap preview;
|
Pixmap preview;
|
||||||
Pixmap previewNoText;
|
Pixmap previewNoText;
|
||||||
|
Pixmap previewBack;
|
||||||
|
|
||||||
char *fprefix;
|
char *fprefix;
|
||||||
} _Panel;
|
} _Panel;
|
||||||
@@ -303,7 +304,8 @@ static const struct {
|
|||||||
{ "ResizebarBack", "(solid, gray)", N_("[Resizebar]") },
|
{ "ResizebarBack", "(solid, gray)", N_("[Resizebar]") },
|
||||||
{ "MenuTitleBack", "(solid, black)", N_("[Menu Title]") },
|
{ "MenuTitleBack", "(solid, black)", N_("[Menu Title]") },
|
||||||
{ "MenuTextBack", "(solid, gray)", N_("[Menu Item]") },
|
{ "MenuTextBack", "(solid, gray)", N_("[Menu Item]") },
|
||||||
{ "IconBack", "(solid, gray)", N_("[Icon]") }
|
{ "IconBack", "(solid, gray)", N_("[Icon]") },
|
||||||
|
{ "WorkspaceBack", "(solid, black)", N_("[Background]") }
|
||||||
};
|
};
|
||||||
|
|
||||||
#define RESIZEBAR_BEVEL -1
|
#define RESIZEBAR_BEVEL -1
|
||||||
@@ -364,6 +366,7 @@ static WMRect previewPositions[] = {
|
|||||||
{{155, 130}, {64, 64}}
|
{{155, 130}, {64, 64}}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define PBACKGROUND 7
|
||||||
#define EVERYTHING 0xff
|
#define EVERYTHING 0xff
|
||||||
|
|
||||||
static WMRect previewColorPositions[] = {
|
static WMRect previewColorPositions[] = {
|
||||||
@@ -755,21 +758,32 @@ static void updatePreviewBox(_Panel * panel, int elements)
|
|||||||
gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
|
gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
|
||||||
|
|
||||||
if (panel->preview == None) {
|
if (panel->preview == None) {
|
||||||
WMColor *color;
|
|
||||||
WMPixmap *p;
|
WMPixmap *p;
|
||||||
|
|
||||||
panel->previewNoText = XCreatePixmap(dpy, WMWidgetXID(panel->parent),
|
panel->previewNoText = XCreatePixmap(dpy, WMWidgetXID(panel->parent),
|
||||||
240 - 4, 215 - 4, WMScreenDepth(scr));
|
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);
|
p = WMCreatePixmap(scr, 240 - 4, 215 - 4, WMScreenDepth(scr), False);
|
||||||
panel->preview = WMGetPixmapXID(p);
|
panel->preview = WMGetPixmapXID(p);
|
||||||
WMSetLabelImage(panel->prevL, p);
|
WMSetLabelImage(panel->prevL, p);
|
||||||
WMReleasePixmap(p);
|
WMReleasePixmap(p);
|
||||||
|
}
|
||||||
|
if (elements & (1 << PBACKGROUND)) {
|
||||||
|
Pixmap tmp;
|
||||||
|
TextureListItem *titem;
|
||||||
|
WMListItem *item;
|
||||||
|
|
||||||
color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
|
item = WMGetListItem(panel->texLs,
|
||||||
XFillRectangle(dpy, panel->preview, WMColorGC(color), 0, 0, 240 - 4, 215 - 4);
|
panel->textureIndex[PBACKGROUND]);
|
||||||
XFillRectangle(dpy, panel->previewNoText, WMColorGC(color), 0, 0, 240 - 4, 215 - 4);
|
titem = (TextureListItem *) item->clientData;
|
||||||
WMReleaseColor(color);
|
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 (elements & (1 << PFOCUSED)) {
|
if (elements & (1 << PFOCUSED)) {
|
||||||
@@ -966,8 +980,12 @@ static void okEditTexture(void *data)
|
|||||||
|
|
||||||
WMRedisplayWidget(panel->texLs);
|
WMRedisplayWidget(panel->texLs);
|
||||||
|
|
||||||
if (titem->selectedFor)
|
if (titem->selectedFor) {
|
||||||
updatePreviewBox(panel, titem->selectedFor);
|
if (titem->selectedFor & (1 << PBACKGROUND))
|
||||||
|
updatePreviewBox(panel, EVERYTHING);
|
||||||
|
else
|
||||||
|
updatePreviewBox(panel, titem->selectedFor);
|
||||||
|
}
|
||||||
|
|
||||||
changePage(panel->secP, panel);
|
changePage(panel->secP, panel);
|
||||||
}
|
}
|
||||||
@@ -1097,12 +1115,14 @@ static void changePage(WMWidget * w, void *data)
|
|||||||
WMSetListPosition(panel->texLs, panel->textureIndex[section] - 2);
|
WMSetListPosition(panel->texLs, panel->textureIndex[section] - 2);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
WMColor *color;
|
GC gc;
|
||||||
|
|
||||||
color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
|
gc = XCreateGC(rc->dpy, WMWidgetXID(panel->parent), 0, NULL);
|
||||||
XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
|
XCopyArea(rc->dpy, panel->previewBack, panel->preview, gc,
|
||||||
positions[panel->oldsection].x, positions[panel->oldsection].y, 22, 22);
|
positions[panel->oldsection].x,
|
||||||
WMReleaseColor(color);
|
positions[panel->oldsection].y, 22, 22 ,
|
||||||
|
positions[panel->oldsection].x,
|
||||||
|
positions[panel->oldsection].y);
|
||||||
}
|
}
|
||||||
if (w) {
|
if (w) {
|
||||||
panel->oldsection = section;
|
panel->oldsection = section;
|
||||||
@@ -1206,7 +1226,10 @@ static void textureDoubleClick(WMWidget * w, void *data)
|
|||||||
|
|
||||||
WMRedisplayWidget(panel->texLs);
|
WMRedisplayWidget(panel->texLs);
|
||||||
|
|
||||||
updatePreviewBox(panel, 1 << section);
|
if (section == PBACKGROUND)
|
||||||
|
updatePreviewBox(panel, EVERYTHING);
|
||||||
|
else
|
||||||
|
updatePreviewBox(panel, 1 << section);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void paintListItem(WMList * lPtr, int index, Drawable d, char *text, int state, WMRect * rect)
|
static void paintListItem(WMList * lPtr, int index, Drawable d, char *text, int state, WMRect * rect)
|
||||||
@@ -1380,12 +1403,14 @@ static void changeColorPage(WMWidget * w, void *data)
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (panel->preview) {
|
if (panel->preview) {
|
||||||
WMColor *color;
|
GC gc;
|
||||||
|
|
||||||
color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
|
gc = XCreateGC(rc->dpy, WMWidgetXID(panel->parent), 0, NULL);
|
||||||
XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
|
XCopyArea(rc->dpy, panel->previewBack, panel->preview, gc,
|
||||||
positions[panel->oldcsection].x, positions[panel->oldcsection].y, 22, 22);
|
positions[panel->oldcsection].x,
|
||||||
WMReleaseColor(color);
|
positions[panel->oldcsection].y, 22, 22 ,
|
||||||
|
positions[panel->oldcsection].x,
|
||||||
|
positions[panel->oldcsection].y);
|
||||||
}
|
}
|
||||||
if (w) {
|
if (w) {
|
||||||
section = WMGetPopUpButtonSelectedItem(panel->colP);
|
section = WMGetPopUpButtonSelectedItem(panel->colP);
|
||||||
@@ -1668,8 +1693,8 @@ static void createPanel(Panel * p)
|
|||||||
WMAddPopUpButtonItem(panel->secP, _("Titlebar of Menus"));
|
WMAddPopUpButtonItem(panel->secP, _("Titlebar of Menus"));
|
||||||
WMAddPopUpButtonItem(panel->secP, _("Menu Items"));
|
WMAddPopUpButtonItem(panel->secP, _("Menu Items"));
|
||||||
WMAddPopUpButtonItem(panel->secP, _("Icon Background"));
|
WMAddPopUpButtonItem(panel->secP, _("Icon Background"));
|
||||||
/* WMAddPopUpButtonItem(panel->secP, _("Workspace Backgrounds"));
|
WMAddPopUpButtonItem(panel->secP, _("Workspace Background"));
|
||||||
*/
|
|
||||||
WMSetPopUpButtonSelectedItem(panel->secP, 0);
|
WMSetPopUpButtonSelectedItem(panel->secP, 0);
|
||||||
WMSetPopUpButtonAction(panel->secP, changePage, panel);
|
WMSetPopUpButtonAction(panel->secP, changePage, panel);
|
||||||
|
|
||||||
@@ -2044,7 +2069,7 @@ static void prepareForClose(_Panel * panel)
|
|||||||
textureList = WMCreatePLArray(NULL, NULL);
|
textureList = WMCreatePLArray(NULL, NULL);
|
||||||
|
|
||||||
/* store list of textures */
|
/* store list of textures */
|
||||||
for (i = 7; i < WMGetListNumberOfRows(panel->texLs); i++) {
|
for (i = 8; i < WMGetListNumberOfRows(panel->texLs); i++) {
|
||||||
item = WMGetListItem(panel->texLs, i);
|
item = WMGetListItem(panel->texLs, i);
|
||||||
titem = (TextureListItem *) item->clientData;
|
titem = (TextureListItem *) item->clientData;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user