titlebar: Massive change for the titlebar : Add a titlebar section in the configuration file + text alignement : left / center / right. Remove the titlebar border (useless)
This commit is contained in:
parent
5a9ac485eb
commit
bfefc41d96
32
src/bar.c
32
src/bar.c
@ -210,7 +210,7 @@ uicb_togglebarpos(uicb_t cmd)
|
||||
int i;
|
||||
|
||||
conf.bartop = !conf.bartop;
|
||||
sgeo.y = (conf.bartop) ? barheight + conf.ttbarheight : conf.ttbarheight;
|
||||
sgeo.y = (conf.bartop) ? barheight + conf.titlebar.height : conf.titlebar.height;
|
||||
|
||||
if(conf.bartop)
|
||||
bary = 0;
|
||||
@ -232,19 +232,35 @@ uicb_togglebarpos(uicb_t cmd)
|
||||
void
|
||||
updatetitlebar(Client *c)
|
||||
{
|
||||
|
||||
int pos_y, pos_x;
|
||||
XFetchName(dpy, c->win, &(c->title));
|
||||
if(!c->title)
|
||||
c->title = strdup("WMFS");
|
||||
|
||||
if(conf.ttbarheight > 10)
|
||||
{
|
||||
bar_refresh_color(c->tbar);
|
||||
draw_text(c->tbar->dr, 3, ((fonth - xftfont->descent) + ((conf.ttbarheight - fonth) / 2)),
|
||||
((c == sel) ? conf.colors.ttbar_text_focus : conf.colors.ttbar_text_normal),
|
||||
conf.colors.bar, 0, c->title);
|
||||
bar_refresh_color(c->tbar);
|
||||
|
||||
bar_refresh(c->tbar);
|
||||
/* Draw the client title in the titlebar *logeek* */
|
||||
if(conf.titlebar.height > 9)
|
||||
{
|
||||
/* Set the text alignement */
|
||||
switch(conf.titlebar.text_align)
|
||||
{
|
||||
case Center: pos_x = (c->geo.width / 2) - (textw(c->title) / 2); break;
|
||||
case Right: pos_x = c->geo.width - textw(c->title) - 2; break;
|
||||
default: case Left: pos_x = 2; break;
|
||||
}
|
||||
|
||||
/* Set y text position (always at the middle) */
|
||||
pos_y = (fonth - (xftfont->descent - 1)) + ((conf.titlebar.height - fonth) / 2);
|
||||
|
||||
/* Draw 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);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
37
src/client.c
37
src/client.c
@ -132,8 +132,6 @@ client_focus(Client *c)
|
||||
{
|
||||
grabbuttons(sel, False);
|
||||
XSetWindowBorder(dpy, sel->win, conf.colors.bordernormal);
|
||||
if(conf.ttbarheight)
|
||||
XSetWindowBorder(dpy, sel->tbar->win, conf.colors.bordernormal);
|
||||
}
|
||||
|
||||
if(c)
|
||||
@ -145,8 +143,6 @@ client_focus(Client *c)
|
||||
if(c)
|
||||
{
|
||||
XSetWindowBorder(dpy, c->win, conf.colors.borderfocus);
|
||||
if(c->tbar->win)
|
||||
XSetWindowBorder(dpy, c->tbar->win, conf.colors.borderfocus);
|
||||
if(conf.raisefocus)
|
||||
client_raise(c);
|
||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||
@ -176,7 +172,7 @@ client_gettbar(Window w)
|
||||
{
|
||||
Client *c;
|
||||
|
||||
if(!conf.ttbarheight)
|
||||
if(!conf.titlebar.height)
|
||||
return NULL;
|
||||
|
||||
for(c = clients; c && c->tbar->win != w; c = c->next);
|
||||
@ -188,7 +184,7 @@ void
|
||||
client_hide(Client *c)
|
||||
{
|
||||
XUnmapWindow(dpy, c->win);
|
||||
if(conf.ttbarheight)
|
||||
if(conf.titlebar.height)
|
||||
XUnmapWindow(dpy, c->tbar->win);
|
||||
setwinstate(c->win, IconicState);
|
||||
|
||||
@ -233,7 +229,7 @@ client_map(Client *c)
|
||||
return;
|
||||
|
||||
XMapWindow(dpy, c->win);
|
||||
if(conf.ttbarheight)
|
||||
if(conf.titlebar.height)
|
||||
{
|
||||
XMapWindow(dpy, c->tbar->win);
|
||||
bar_refresh(c->tbar);
|
||||
@ -253,17 +249,19 @@ client_manage(Window w, XWindowAttributes *wa)
|
||||
c = emalloc(1, sizeof(Client));
|
||||
c->win = w;
|
||||
c->geo.x = wa->x;
|
||||
c->geo.y = wa->y + sgeo.y + conf.ttbarheight; /* Default free placement */
|
||||
c->geo.y = wa->y + sgeo.y + conf.titlebar.height; /* Default free placement */
|
||||
c->geo.width = wa->width;
|
||||
c->geo.height = wa->height;
|
||||
c->tag = seltag;
|
||||
c->border = conf.borderheight;
|
||||
|
||||
/* Create titlebar */
|
||||
if(conf.ttbarheight)
|
||||
c->tbar = bar_create(c->geo.x, c->geo.y - conf.ttbarheight,
|
||||
c->geo.width, conf.ttbarheight, conf.borderheight,
|
||||
conf.colors.bar, True);
|
||||
if(conf.titlebar.height)
|
||||
c->tbar = bar_create(c->geo.x,
|
||||
c->geo.y - conf.titlebar.height,
|
||||
c->geo.width + c->border,
|
||||
conf.titlebar.height, 0,
|
||||
conf.titlebar.bg, True);
|
||||
|
||||
winc.border_width = c->border;
|
||||
XConfigureWindow(dpy, w, CWBorderWidth, &winc);
|
||||
@ -356,8 +354,11 @@ client_moveresize(Client *c, XRectangle geo, bool r)
|
||||
XMoveResizeWindow(dpy, c->win, geo.x, geo.y,
|
||||
geo.width, geo.height);
|
||||
|
||||
if(conf.ttbarheight)
|
||||
bar_moveresize(c->tbar, geo.x, geo.y - conf.ttbarheight, geo.width, conf.ttbarheight);
|
||||
if(conf.titlebar.height)
|
||||
bar_moveresize(c->tbar, geo.x,
|
||||
geo.y - conf.titlebar.height,
|
||||
geo.width + c->border*2,
|
||||
conf.titlebar.height);
|
||||
|
||||
updatetitlebar(c);
|
||||
XSync(dpy, False);
|
||||
@ -444,7 +445,7 @@ client_raise(Client *c)
|
||||
return;
|
||||
XRaiseWindow(dpy, c->win);
|
||||
|
||||
if(conf.ttbarheight)
|
||||
if(conf.titlebar.height)
|
||||
{
|
||||
XRaiseWindow(dpy, c->tbar->win);
|
||||
updatetitlebar(c);
|
||||
@ -457,7 +458,7 @@ void
|
||||
client_unhide(Client *c)
|
||||
{
|
||||
XMapWindow(dpy, c->win);
|
||||
if(conf.ttbarheight)
|
||||
if(conf.titlebar.height)
|
||||
XMapWindow(dpy, c->tbar->win);
|
||||
setwinstate(c->win, NormalState);
|
||||
|
||||
@ -472,7 +473,7 @@ client_unmanage(Client *c)
|
||||
sel = ((sel == c) ? ((c->next) ? c->next : NULL) : NULL);
|
||||
selbytag[seltag] = (sel && sel->tag == seltag) ? sel : NULL;
|
||||
client_detach(c);
|
||||
if(conf.ttbarheight)
|
||||
if(conf.titlebar.height)
|
||||
bar_delete(c->tbar);
|
||||
setwinstate(c->win, WithdrawnState);
|
||||
free(c);
|
||||
@ -490,7 +491,7 @@ client_unmap(Client *c)
|
||||
return;
|
||||
|
||||
XUnmapWindow(dpy, c->win);
|
||||
if(conf.ttbarheight)
|
||||
if(conf.titlebar.height)
|
||||
XUnmapWindow(dpy, c->tbar->win);
|
||||
|
||||
return;
|
||||
|
||||
31
src/config.c
31
src/config.c
@ -170,7 +170,6 @@ init_conf(void)
|
||||
CFG_BOOL("raisefocus", cfg_false, CFGF_NONE),
|
||||
CFG_BOOL("raiseswitch", cfg_true, CFGF_NONE),
|
||||
CFG_INT("border_height", 1, CFGF_NONE),
|
||||
CFG_INT("titlebar_height", 0, CFGF_NONE),
|
||||
CFG_INT("tag_border_width", 0, CFGF_NONE),
|
||||
CFG_END()
|
||||
};
|
||||
@ -186,11 +185,18 @@ init_conf(void)
|
||||
CFG_STR("tag_border", "#090909", CFGF_NONE),
|
||||
CFG_STR("layout_fg", "#FFFFFF", CFGF_NONE),
|
||||
CFG_STR("layout_bg", "#292929", CFGF_NONE),
|
||||
CFG_STR("titlebar_text_focus", "#FFFFFF", CFGF_NONE),
|
||||
CFG_STR("titlebar_text_normal", "#FFFFFF", CFGF_NONE),
|
||||
CFG_END()
|
||||
};
|
||||
|
||||
static cfg_opt_t titlebar_opts[] =
|
||||
{
|
||||
CFG_INT("height", 0, CFGF_NONE),
|
||||
CFG_STR("bg", "#090909", CFGF_NONE),
|
||||
CFG_STR("fg_focus", "#FFFFFF", CFGF_NONE),
|
||||
CFG_STR("fg_normal", "#FFFFFF", CFGF_NONE),
|
||||
CFG_STR("text_align", "left", CFGF_NONE),
|
||||
};
|
||||
|
||||
static cfg_opt_t layout_opts[] =
|
||||
{
|
||||
CFG_STR("type", "", CFGF_NONE),
|
||||
@ -275,6 +281,7 @@ init_conf(void)
|
||||
{
|
||||
CFG_SEC("misc", misc_opts, CFGF_NONE),
|
||||
CFG_SEC("variables", variables_opts, CFGF_NONE),
|
||||
CFG_SEC("titlebar", titlebar_opts, CFGF_NONE),
|
||||
CFG_SEC("colors", colors_opts, CFGF_NONE),
|
||||
CFG_SEC("layouts", layouts_opts, CFGF_NONE),
|
||||
CFG_SEC("tags", tags_opts, CFGF_NONE),
|
||||
@ -287,6 +294,7 @@ init_conf(void)
|
||||
cfg_t *cfg_misc;
|
||||
cfg_t *cfg_colors;
|
||||
cfg_t *cfg_variables;
|
||||
cfg_t *cfg_titlebar;
|
||||
cfg_t *cfg_layouts;
|
||||
cfg_t *cfg_tags;
|
||||
cfg_t *cfg_keys;
|
||||
@ -314,6 +322,7 @@ init_conf(void)
|
||||
|
||||
cfg_misc = cfg_getsec(cfg, "misc");
|
||||
cfg_variables = cfg_getsec(cfg, "variables");
|
||||
cfg_titlebar = cfg_getsec(cfg, "titlebar");
|
||||
cfg_colors = cfg_getsec(cfg, "colors");
|
||||
cfg_layouts = cfg_getsec(cfg, "layouts");
|
||||
cfg_tags = cfg_getsec(cfg, "tags");
|
||||
@ -338,7 +347,6 @@ init_conf(void)
|
||||
conf.raisefocus = cfg_getbool(cfg_misc, "raisefocus");
|
||||
conf.raiseswitch = cfg_getbool(cfg_misc, "raiseswitch");
|
||||
conf.borderheight = cfg_getint(cfg_misc, "border_height");
|
||||
conf.ttbarheight = cfg_getint(cfg_misc, "titlebar_height");
|
||||
conf.tagbordwidth = cfg_getint(cfg_misc, "tag_border_width");
|
||||
conf.bartop = (strcmp(strdup(cfg_getstr(cfg_misc, "bar_position")), "top") == 0) ? True : False;
|
||||
|
||||
@ -352,8 +360,19 @@ init_conf(void)
|
||||
conf.colors.tagbord = getcolor(var_to_str(cfg_getstr(cfg_colors, "tag_border")));
|
||||
conf.colors.layout_fg = strdup(var_to_str(cfg_getstr(cfg_colors, "layout_fg")));
|
||||
conf.colors.layout_bg = getcolor(var_to_str(cfg_getstr(cfg_colors, "layout_bg")));
|
||||
conf.colors.ttbar_text_focus = strdup(var_to_str(cfg_getstr(cfg_colors, "titlebar_text_focus")));
|
||||
conf.colors.ttbar_text_normal = strdup(var_to_str(cfg_getstr(cfg_colors, "titlebar_text_normal")));
|
||||
|
||||
/* titlebar */
|
||||
conf.titlebar.height = cfg_getint(cfg_titlebar, "height");
|
||||
conf.titlebar.bg = getcolor(var_to_str(cfg_getstr(cfg_titlebar, "bg")));
|
||||
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"));
|
||||
|
||||
if(strcmp(var_to_str(cfg_getstr(cfg_titlebar, "text_align")), "center") == 0)
|
||||
conf.titlebar.text_align = Center;
|
||||
else if(strcmp(var_to_str(cfg_getstr(cfg_titlebar, "text_align")), "right") == 0)
|
||||
conf.titlebar.text_align = Right;
|
||||
else
|
||||
conf.titlebar.text_align = Left;
|
||||
|
||||
/* layout */
|
||||
if((conf.nlayout = cfg_size(cfg_layouts, "layout")) > MAXLAYOUT
|
||||
|
||||
@ -43,7 +43,7 @@ buttonpress(XEvent ev)
|
||||
int i, j;
|
||||
char s[6];
|
||||
|
||||
if(conf.ttbarheight)
|
||||
if(conf.titlebar.height)
|
||||
{
|
||||
/* ******** */
|
||||
/* TITLEBAR */
|
||||
@ -287,7 +287,7 @@ expose(XEvent ev)
|
||||
&& (ev.xexpose.window == bar->win))
|
||||
updatebar();
|
||||
|
||||
if(conf.ttbarheight)
|
||||
if(conf.titlebar.height)
|
||||
for(c = clients; c; c = c->next)
|
||||
if(ev.xexpose.window == c->tbar->win)
|
||||
updatetitlebar(c);
|
||||
|
||||
@ -233,9 +233,9 @@ tile(void)
|
||||
|
||||
/* Remainder */
|
||||
if(i + 1 == (n < nmaster ? n : nmaster))
|
||||
cgeo.height = (sgeo.height - mastergeo.height * i) + conf.ttbarheight;
|
||||
cgeo.height = (sgeo.height - mastergeo.height * i) + conf.titlebar.height;
|
||||
|
||||
cgeo.height -= border + conf.ttbarheight;
|
||||
cgeo.height -= border + conf.titlebar.height;
|
||||
}
|
||||
|
||||
/* Tiled Client */
|
||||
@ -253,13 +253,13 @@ tile(void)
|
||||
if(i + 1 == n)
|
||||
cgeo.height = (sgeo.y + sgeo.height) - cgeo.y - border;
|
||||
else
|
||||
cgeo.height = tileheight - (border + conf.ttbarheight);
|
||||
cgeo.height = tileheight - (border + conf.titlebar.height);
|
||||
}
|
||||
|
||||
client_moveresize(c, cgeo, tags[seltag].resizehint);
|
||||
|
||||
if(n > nmaster && tileheight != sgeo.height)
|
||||
cgeo.y = c->geo.y + c->geo.height + border + conf.ttbarheight;
|
||||
cgeo.y = c->geo.y + c->geo.height + border + conf.titlebar.height;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@ -50,6 +50,7 @@ typedef unsigned char uchar;
|
||||
enum { CurNormal, CurResize, CurMove, CurLast };
|
||||
enum { WMState, WMProtocols, WMName, WMDelete, WMLast };
|
||||
enum { NetSupported, NetWMName, NetLast };
|
||||
enum { Left = 0, Center, Right, AlignLast};
|
||||
|
||||
/* BarWindow Structure
|
||||
* (titlebar, topbar..) */
|
||||
@ -143,7 +144,6 @@ typedef struct
|
||||
bool raiseswitch;
|
||||
bool bartop;
|
||||
int borderheight;
|
||||
int ttbarheight;
|
||||
int tagbordwidth;
|
||||
struct
|
||||
{
|
||||
@ -158,9 +158,15 @@ typedef struct
|
||||
uint tagbord;
|
||||
char *layout_fg;
|
||||
uint layout_bg;
|
||||
char *ttbar_text_focus;
|
||||
char *ttbar_text_normal;
|
||||
} colors;
|
||||
struct
|
||||
{
|
||||
int height;
|
||||
uint bg;
|
||||
char *fg_focus;
|
||||
char *fg_normal;
|
||||
int text_align;
|
||||
} titlebar;
|
||||
Tag tag[MAXTAG];
|
||||
Layout layout[MAXLAYOUT];
|
||||
BarButton *barbutton;
|
||||
|
||||
@ -177,9 +177,9 @@ init(void)
|
||||
|
||||
/* INIT WORKABLE SPACE */
|
||||
sgeo.x = 0;
|
||||
sgeo.y = (conf.bartop) ? barheight + conf.ttbarheight : conf.ttbarheight;
|
||||
sgeo.y = (conf.bartop) ? barheight + conf.titlebar.height : conf.titlebar.height;
|
||||
sgeo.width = DisplayWidth(dpy, screen);
|
||||
sgeo.height = DisplayHeight(dpy, screen) - (barheight + conf.ttbarheight);
|
||||
sgeo.height = DisplayHeight(dpy, screen) - (barheight + conf.titlebar.height);
|
||||
|
||||
|
||||
/* INIT STUFF */
|
||||
|
||||
12
wmfsrc
12
wmfsrc
@ -12,7 +12,6 @@ misc
|
||||
raisefocus = false
|
||||
raiseswitch = true
|
||||
border_height = 1
|
||||
titlebar_height = 12
|
||||
tag_border_width = 1
|
||||
}
|
||||
|
||||
@ -34,10 +33,15 @@ colors
|
||||
#Layout
|
||||
layout_fg = "#191919"
|
||||
layout_bg = "#7E89A2"
|
||||
}
|
||||
|
||||
#Titlebar
|
||||
titlebar_text_focus = "#D4D4D4"
|
||||
titlebar_text_normal = "#D4D4D4"
|
||||
titlebar
|
||||
{
|
||||
height = 12
|
||||
bg = "#191919"
|
||||
fg_normal = "#D4D4D4"
|
||||
fg_focus = "#D4D4D4"
|
||||
text_align = "center"
|
||||
}
|
||||
|
||||
layouts
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user