barwin/frame: Add stipple in the titlebar.

This commit is contained in:
Martin Duquesnoy 2009-01-02 21:16:16 +01:00
parent c6b6bf2cab
commit b69cce353d
7 changed files with 109 additions and 51 deletions

View File

@ -48,8 +48,10 @@ barwin_create(Window parent,
int y,
uint w,
uint h,
uint color,
Bool entermask)
uint bg,
char *fg,
Bool entermask,
Bool stipple)
{
XSetWindowAttributes at;
BarWindow *bw;
@ -74,8 +76,8 @@ barwin_create(Window parent,
bw->dr = XCreatePixmap(dpy, parent, w, h, DefaultDepth(dpy, SCREEN));
/* His border */
CWIN(bw->border.left, bw->win, 0, 0, SHADH, h, 0, CWBackPixel, color_enlight(color), &at);
CWIN(bw->border.top, bw->win, 0, 0, w, SHADH, 0, CWBackPixel, color_enlight(color), &at);
CWIN(bw->border.left, bw->win, 0, 0, SHADH, h, 0, CWBackPixel, color_enlight(bg), &at);
CWIN(bw->border.top, bw->win, 0, 0, w, SHADH, 0, CWBackPixel, color_enlight(bg), &at);
CWIN(bw->border.bottom, bw->win, 0, h - SHADH, w, SHADH, 0, CWBackPixel, SHADC, &at);
CWIN(bw->border.right, bw->win, w - SHADH, 0, SHADH, h, 0, CWBackPixel, SHADC, &at);
@ -84,13 +86,32 @@ barwin_create(Window parent,
bw->geo.y = y;
bw->geo.width = w;
bw->geo.height = h;
bw->color = color;
bw->border.light = color_enlight(color);
bw->bg = bg;
bw->fg = fg;
bw->border.light = color_enlight(bg);
bw->border.dark = SHADC;
bw->stipple = stipple;
return bw;
}
/** Draw text in a Barwindow
*/
void
barwin_draw_text(BarWindow *bw, int x, int y, char *text)
{
/* Background color of the text if there is stipple */
if(bw->stipple)
draw_rectangle(bw->dr, x - 4, 0, textw(text) + 8, bw->geo.height, bw->bg);
/* Draw text */
draw_text(bw->dr, x, y, bw->fg, 0, text);
barwin_refresh(bw);
return;
}
/** Delete a BarWindow
* \param bw BarWindow pointer
*/
@ -232,7 +253,13 @@ barwin_refresh_color(BarWindow *bw)
{
CHECK(bw);
draw_rectangle(bw->dr, 0, 0, bw->geo.width, bw->geo.height, bw->color);
draw_rectangle(bw->dr, 0, 0, bw->geo.width, bw->geo.height, bw->bg);
if(bw->stipple)
{
XSetForeground(dpy, gc_stipple, getcolor(bw->fg));
XFillRectangle(dpy, bw->dr, gc_stipple, 3, 2, bw->geo.width - 6, bw->geo.height - 4);
}
XSetWindowBackground(dpy, bw->border.left, bw->border.light);
XSetWindowBackground(dpy, bw->border.top, bw->border.light);

View File

@ -70,7 +70,12 @@ frame_create(Client *c)
/* Create titlebar window */
if(TBARH)
c->titlebar = barwin_create(c->frame, 0, 0, c->frame_geo.width, TBARH + BORDH, c->colors.frame, True);
c->titlebar = barwin_create(c->frame, 0, 0,
c->frame_geo.width,
TBARH + BORDH,
c->colors.frame,
c->colors.fg,
True, True);
at.event_mask &= ~(EnterWindowMask | LeaveWindowMask); /* <- Delete useless mask */
@ -164,8 +169,11 @@ frame_update(Client *c)
if(TBARH)
{
c->titlebar->color = c->colors.frame;
c->titlebar->bg = c->colors.frame;
c->titlebar->fg = c->colors.fg;
barwin_refresh_color(c->titlebar);
barwin_refresh(c->titlebar);
}
XSetWindowBackground(dpy, c->frame, c->colors.frame);
@ -183,14 +191,10 @@ frame_update(Client *c)
XClearWindow(dpy, c->bottom);
if(TBARH && (TBARH + BORDH + 1) > font->height)
{
draw_text(c->titlebar->dr,
(c->frame_geo.width / 2) - (textw(c->title) / 2),
(font->height - (font->descent)) + (((TBARH + BORDH) - font->height) / 2),
c->colors.fg, 0, c->title);
barwin_refresh(c->titlebar);
}
barwin_draw_text(c->titlebar,
(c->frame_geo.width / 2) - (textw(c->title) / 2),
(font->height - (font->descent)) + (((TBARH + BORDH) - font->height) / 2),
c->title);
return;
}

View File

@ -52,21 +52,26 @@ infobar_init(void)
/* Create infobar barwindow */
infobar[sc].bar = barwin_create(ROOT, sgeo[sc].x - BORDH, infobar[sc].geo.y,
sgeo[sc].width, infobar[sc].geo.height, conf.colors.bar, False);
sgeo[sc].width, infobar[sc].geo.height,
conf.colors.bar, conf.colors.text, False, False);
/* Create tags window */
for(i = 1; i < conf.ntag[sc] + 1; ++i)
{
infobar[sc].tags[i] = barwin_create(infobar[sc].bar->win, j, 0, textw(tags[sc][i].name) + PAD,
infobar[sc].geo.height, conf.colors.bar, False);
infobar[sc].tags[i] = barwin_create(infobar[sc].bar->win, j, 0,
textw(tags[sc][i].name) + PAD,
infobar[sc].geo.height,
conf.colors.bar, conf.colors.text, False, False);
j += textw(tags[sc][i].name) + PAD;
barwin_map_subwin(infobar[sc].tags[i]);
}
/* Create layout switch & layout type switch barwindow */
infobar[sc].layout_button = barwin_create(infobar[sc].bar->win, j + PAD / 2, 0,
textw(tags[sc][seltag[sc]].layout.symbol) + PAD,
infobar[sc].geo.height, conf.colors.layout_bg, False);
textw(tags[sc][seltag[sc]].layout.symbol) + PAD,
infobar[sc].geo.height,
conf.colors.layout_bg, conf.colors.layout_fg,
False, False);
/* Map/Refresh all */
barwin_map(infobar[sc].bar);
@ -91,15 +96,7 @@ infobar_draw(int sc)
infobar_draw_taglist(sc);
infobar_draw_layout(sc);
barwin_refresh_color(infobar[sc].bar);
/* DRAW status text */
draw_text(infobar[sc].bar->dr,
(sgeo[sc].width - SHADH) - textw(statustext),
font->height,
conf.colors.text, 0,
statustext);
barwin_refresh(infobar[sc].bar);
barwin_draw_text(infobar[sc].bar, (sgeo[sc].width - SHADH) - textw(statustext), font->height, statustext);
return;
}
@ -113,9 +110,7 @@ infobar_draw_layout(int sc)
barwin_resize(infobar[sc].layout_button, textw(tags[sc][seltag[sc]].layout.symbol) + PAD, infobar[sc].geo.height);
barwin_refresh_color(infobar[sc].layout_button);
if(tags[sc][seltag[sc]].layout.symbol)
draw_text(infobar[sc].layout_button->dr, PAD / 2, font->height,
conf.colors.layout_fg, 0, tags[sc][seltag[sc]].layout.symbol);
barwin_refresh(infobar[sc].layout_button);
barwin_draw_text(infobar[sc].layout_button, PAD / 2, font->height, tags[sc][seltag[sc]].layout.symbol);
return;
}
@ -131,7 +126,8 @@ infobar_draw_taglist(int sc)
for(i = 1; i < conf.ntag[sc] + 1; ++i)
{
infobar[sc].tags[i]->color = ((i == seltag[sc]) ? conf.colors.tagselbg : conf.colors.bar);
infobar[sc].tags[i]->bg = ((i == seltag[sc]) ? conf.colors.tagselbg : conf.colors.bar);
infobar[sc].tags[i]->fg = ((i == seltag[sc]) ? conf.colors.tagselfg : conf.colors.text);
barwin_refresh_color(infobar[sc].tags[i]);
/* Colorize a tag if there are clients in this */
@ -139,19 +135,15 @@ infobar_draw_taglist(int sc)
{
if(c->screen == sc)
{
infobar[sc].tags[c->tag]->color = ((c->tag == seltag[sc])
? conf.colors.tagselbg
: conf.colors.tag_occupied_bg);
barwin_refresh_color(infobar[sc].tags[i]);
infobar[sc].tags[c->tag]->bg = ((c->tag == seltag[sc])
? conf.colors.tagselbg
: conf.colors.tag_occupied_bg);
barwin_refresh_color(infobar[sc].tags[i]);
}
}
if(tags[sc][i].name)
draw_text(infobar[sc].tags[i]->dr,
PAD / 2, font->height,
((i == seltag[sc]) ? conf.colors.tagselfg : conf.colors.text),
0, tags[sc][i].name);
barwin_refresh(infobar[sc].tags[i]);
barwin_draw_text(infobar[sc].tags[i], PAD / 2, font->height, tags[sc][i].name);
}
return;

View File

@ -38,7 +38,7 @@ void
init(void)
{
/* First init */
gc = DefaultGC(dpy, SCREEN);
init_gc();
init_font();
init_cursor();
init_key();
@ -69,6 +69,32 @@ init_font(void)
}
}
/** Init the graphic context
*/
void
init_gc(void)
{
XGCValues gcv;
/* Bits sequences */
const char pix_bits[] =
{
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55,
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55,
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55,
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55
};
gc = DefaultGC(dpy, SCREEN);
gcv.function = GXcopy;
gcv.fill_style = FillStippled;
gcv.stipple = XCreateBitmapFromData(dpy, ROOT, pix_bits, 10, 4);
gc_stipple = XCreateGC(dpy, ROOT, GCFunction|GCFillStyle|GCStipple, &gcv);
return;
}
/** Init WMFS cursor
*/
void

View File

@ -98,9 +98,10 @@ typedef struct
/* Border color */
uint dark, light;
} border;
uint color;
uint bg;
char *fg;
XRectangle geo;
Bool mapped;
Bool mapped, stipple;
} BarWindow;
/* Client Structure. */

View File

@ -85,7 +85,14 @@
#define PAD 14
/* barwin.c */
BarWindow *barwin_create(Window parent, int x, int y, uint w, uint h, uint color, Bool entermask);
BarWindow *barwin_create(Window parent,
int x, int y,
uint w, uint h,
uint bg, char*fg,
Bool entermask,
Bool stipple);
void barwin_draw_text(BarWindow *bw, int x, int y, char *text);
void barwin_delete(BarWindow *bw);
void barwin_delete_subwin(BarWindow *bw);
void barwin_map(BarWindow *bw);
@ -248,6 +255,7 @@ void uicb_set_nmaster(uicb_t);
void init(void);
void init_root(void);
void init_font(void);
void init_gc(void);
void init_cursor(void);
void init_key(void);
void init_geometry(void);
@ -266,7 +274,7 @@ void uicb_reload(uicb_t);
/* Principal */
Display *dpy;
GC gc;
GC gc, gc_stipple;
int selscreen;
Conf conf;
Key *keys;

4
wmfsrc
View File

@ -82,8 +82,8 @@ client
titlebar
{
height = 11
fg_normal = "#D4D4D4"
fg_focus = "#D4D4D4"
fg_normal = "#003366"
fg_focus = "#7E89A2"
mouse { button = "1" func = "client_raise" }
mouse { button = "1" func = "mouse_move" }