titlebar: Add bg_normal & focus in the conf

This commit is contained in:
Martin Duquesnoy 2008-11-04 20:33:27 +01:00
parent 0dfdf50694
commit d2255a2581
7 changed files with 33 additions and 14 deletions

View File

@ -95,6 +95,8 @@ void
bar_refresh_color(BarWindow *bw) bar_refresh_color(BarWindow *bw)
{ {
draw_rectangle(bw->dr, 0, 0, bw->w, bw->h, bw->color); draw_rectangle(bw->dr, 0, 0, bw->w, bw->h, bw->color);
if(bw->bord)
XSetWindowBorder(dpy, bw->win, bw->color);
return; return;
} }

View File

@ -206,7 +206,8 @@ init_conf(void)
{ {
CFG_STR("position", "top", CFGF_NONE), CFG_STR("position", "top", CFGF_NONE),
CFG_INT("height", 0, CFGF_NONE), CFG_INT("height", 0, CFGF_NONE),
CFG_STR("bg", "#090909", CFGF_NONE), CFG_STR("bg_normal", "#090909", CFGF_NONE),
CFG_STR("bg_focus", "#090909", CFGF_NONE),
CFG_STR("fg_focus", "#FFFFFF", CFGF_NONE), CFG_STR("fg_focus", "#FFFFFF", CFGF_NONE),
CFG_STR("fg_normal", "#FFFFFF", CFGF_NONE), CFG_STR("fg_normal", "#FFFFFF", CFGF_NONE),
CFG_STR("text_align", "left", CFGF_NONE), CFG_STR("text_align", "left", CFGF_NONE),
@ -387,7 +388,8 @@ init_conf(void)
conf.titlebar.height = cfg_getint(cfg_titlebar, "height"); conf.titlebar.height = cfg_getint(cfg_titlebar, "height");
conf.titlebar.exist = conf.titlebar.height ? True : False; conf.titlebar.exist = conf.titlebar.height ? True : False;
conf.titlebar.bg = getcolor(var_to_str(cfg_getstr(cfg_titlebar, "bg"))); conf.titlebar.bg_normal = getcolor(var_to_str(cfg_getstr(cfg_titlebar, "bg_normal")));
conf.titlebar.bg_focus = getcolor(var_to_str(cfg_getstr(cfg_titlebar, "bg_focus")));
conf.titlebar.fg_focus = var_to_str(cfg_getstr(cfg_titlebar, "fg_focus")); conf.titlebar.fg_focus = var_to_str(cfg_getstr(cfg_titlebar, "fg_focus"));
conf.titlebar.fg_normal = var_to_str(cfg_getstr(cfg_titlebar, "fg_normal")); conf.titlebar.fg_normal = var_to_str(cfg_getstr(cfg_titlebar, "fg_normal"));

View File

@ -227,7 +227,7 @@ grid(void)
cgeo.width = sgeo.width - cgeo.x - border; cgeo.width = sgeo.width - cgeo.x - border;
/* Resize */ /* Resize */
client_moveresize(c, cgeo, False); client_moveresize(c, cgeo, tags[seltag].resizehint);
/* Set all the other size with current client info */ /* Set all the other size with current client info */
cgeo.y = c->geo.y + c->geo.height + border + conf.titlebar.height; cgeo.y = c->geo.y + c->geo.height + border + conf.titlebar.height;

View File

@ -182,7 +182,8 @@ typedef struct
Bool exist; Bool exist;
Position pos; Position pos;
int height; int height;
uint bg; uint bg_normal;
uint bg_focus;
char *fg_focus; char *fg_focus;
char *fg_normal; char *fg_normal;
Position text_align; Position text_align;

View File

@ -52,8 +52,8 @@ titlebar_create(Client *c)
c->tbar = bar_create(c->geo.x, y, c->geo.width, c->tbar = bar_create(c->geo.x, y, c->geo.width,
conf.titlebar.height - conf.client.borderheight, conf.titlebar.height - conf.client.borderheight,
conf.client.borderheight, conf.client.borderheight,
conf.titlebar.bg, True); conf.titlebar.bg_normal, True);
XSetWindowBorder(dpy, c->tbar->win, conf.titlebar.bg); XSetWindowBorder(dpy, c->tbar->win, conf.titlebar.bg_normal);
return; return;
} }
@ -108,6 +108,8 @@ void
titlebar_update(Client *c) titlebar_update(Client *c)
{ {
int pos_y, pos_x; int pos_y, pos_x;
uint bg;
char *fg;
XFetchName(dpy, c->win, &(c->title)); XFetchName(dpy, c->win, &(c->title));
if(!c->title) if(!c->title)
@ -116,10 +118,20 @@ titlebar_update(Client *c)
if(!conf.titlebar.exist) if(!conf.titlebar.exist)
return; return;
/* Set titlebar color */
bg = (c == sel)
? conf.titlebar.bg_focus
: conf.titlebar.bg_normal;
fg = (c == sel)
? conf.titlebar.fg_focus
: conf.titlebar.fg_normal;
c->tbar->color = bg;
/* Refresh titlebar color */
bar_refresh_color(c->tbar); bar_refresh_color(c->tbar);
/* Draw the client title in the titlebar *logeek* */ /* Draw the client title in the titlebar *logeek* */
if(conf.titlebar.height > 9) if(conf.titlebar.height > fonth)
{ {
/* Set the text alignement */ /* Set the text alignement */
switch(conf.titlebar.text_align) switch(conf.titlebar.text_align)
@ -140,11 +152,9 @@ titlebar_update(Client *c)
pos_y = (fonth - (xftfont->descent )) + ((conf.titlebar.height - fonth) / 2); pos_y = (fonth - (xftfont->descent )) + ((conf.titlebar.height - fonth) / 2);
/* Draw title */ /* Draw title */
//if(c->title) draw_text(c->tbar->dr, pos_x, pos_y, fg, bg, 0, c->title);
draw_text(c->tbar->dr, pos_x, pos_y,
(c == sel) ? conf.titlebar.fg_focus : conf.titlebar.fg_normal,
conf.titlebar.bg, 0, c->title);
} }
bar_refresh(c->tbar); bar_refresh(c->tbar);
return; return;

View File

@ -132,7 +132,6 @@ init(void)
fonth = (xftfont->ascent + xftfont->descent); fonth = (xftfont->ascent + xftfont->descent);
barheight = fonth + (float)4.5; barheight = fonth + (float)4.5;
/* INIT CURSOR */ /* INIT CURSOR */
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
@ -184,6 +183,10 @@ init(void)
/* INIT STUFF */ /* INIT STUFF */
grabkeys(); grabkeys();
/* MISC WARNING */
if(conf.titlebar.height - 1 < fonth)
fprintf(stderr, "WMFS Warning: Font too big, can't draw any text in the titlebar.\n");
return; return;
} }

5
wmfsrc
View File

@ -77,8 +77,9 @@ client
titlebar titlebar
{ {
position = "top" position = "top"
height = 12 height = 13
bg = "#191919" bg_normal = "#191919"
bg_focus = "#191919"
fg_normal = "#D4D4D4" fg_normal = "#D4D4D4"
fg_focus = "#D4D4D4" fg_focus = "#D4D4D4"
text_align = "center" text_align = "center"