titlebar: Fix titlebar less and placement
This commit is contained in:
parent
58682a269e
commit
385d76be05
20
src/client.c
20
src/client.c
@ -125,7 +125,7 @@ client_focus(Client *c)
|
||||
{
|
||||
grabbuttons(sel, False);
|
||||
XSetWindowBorder(dpy, sel->win, conf.client.bordernormal);
|
||||
if(conf.titlebar.height)
|
||||
if(conf.titlebar.exist)
|
||||
XSetWindowBorder(dpy, sel->tbar->win, conf.client.bordernormal);
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ client_focus(Client *c)
|
||||
if(c)
|
||||
{
|
||||
XSetWindowBorder(dpy, c->win, conf.client.borderfocus);
|
||||
if(conf.titlebar.height)
|
||||
if(conf.titlebar.exist)
|
||||
XSetWindowBorder(dpy, sel->tbar->win, conf.client.borderfocus);
|
||||
if(conf.raisefocus)
|
||||
client_raise(c);
|
||||
@ -168,7 +168,7 @@ void
|
||||
client_hide(Client *c)
|
||||
{
|
||||
XMoveWindow(dpy, c->win, c->geo.x + mw * 2, c->geo.y);
|
||||
if(conf.titlebar.height)
|
||||
if(conf.titlebar.exist)
|
||||
XMoveWindow(dpy, c->tbar->win, c->geo.x + mw * 2, c->geo.y);
|
||||
setwinstate(c->win, IconicState);
|
||||
|
||||
@ -210,7 +210,7 @@ client_map(Client *c)
|
||||
return;
|
||||
|
||||
XMapWindow(dpy, c->win);
|
||||
if(conf.titlebar.height)
|
||||
if(conf.titlebar.exist)
|
||||
{
|
||||
XMapWindow(dpy, c->tbar->win);
|
||||
bar_refresh(c->tbar);
|
||||
@ -237,7 +237,7 @@ client_manage(Window w, XWindowAttributes *wa)
|
||||
c->border = conf.client.borderheight;
|
||||
|
||||
/* Create titlebar */
|
||||
if(conf.titlebar.height)
|
||||
if(conf.titlebar.exist)
|
||||
titlebar_create(c);
|
||||
|
||||
winc.border_width = c->border;
|
||||
@ -331,7 +331,7 @@ client_moveresize(Client *c, XRectangle geo, bool r)
|
||||
XMoveResizeWindow(dpy, c->win, geo.x, geo.y,
|
||||
geo.width, geo.height);
|
||||
|
||||
if(conf.titlebar.height)
|
||||
if(conf.titlebar.exist)
|
||||
titlebar_update_position(c);
|
||||
|
||||
titlebar_update(c);
|
||||
@ -419,7 +419,7 @@ client_raise(Client *c)
|
||||
return;
|
||||
XRaiseWindow(dpy, c->win);
|
||||
|
||||
if(conf.titlebar.height)
|
||||
if(conf.titlebar.exist)
|
||||
{
|
||||
XRaiseWindow(dpy, c->tbar->win);
|
||||
titlebar_update(c);
|
||||
@ -440,7 +440,7 @@ void
|
||||
client_unhide(Client *c)
|
||||
{
|
||||
XMoveWindow(dpy, c->win, c->geo.x, c->geo.y);
|
||||
if(conf.titlebar.height)
|
||||
if(conf.titlebar.exist)
|
||||
titlebar_update_position(c);
|
||||
setwinstate(c->win, NormalState);
|
||||
|
||||
@ -461,7 +461,7 @@ client_unmanage(Client *c)
|
||||
XSync(dpy, False);
|
||||
XUngrabServer(dpy);
|
||||
|
||||
if(conf.titlebar.height)
|
||||
if(conf.titlebar.exist)
|
||||
bar_delete(c->tbar);
|
||||
free(c);
|
||||
|
||||
@ -477,7 +477,7 @@ client_unmap(Client *c)
|
||||
return;
|
||||
|
||||
XUnmapWindow(dpy, c->win);
|
||||
if(conf.titlebar.height)
|
||||
if(conf.titlebar.exist)
|
||||
XUnmapWindow(dpy, c->tbar->win);
|
||||
|
||||
return;
|
||||
|
||||
@ -374,6 +374,7 @@ init_conf(void)
|
||||
conf.titlebar.pos = False;
|
||||
|
||||
conf.titlebar.height = cfg_getint(cfg_titlebar, "height");
|
||||
conf.titlebar.exist = conf.titlebar.height ? True : False;
|
||||
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"));
|
||||
|
||||
@ -41,7 +41,7 @@ buttonpress(XEvent ev)
|
||||
char s[6];
|
||||
|
||||
/* Titlebar */
|
||||
if(conf.titlebar.height)
|
||||
if(conf.titlebar.exist)
|
||||
if((c = titlebar_get(ev.xbutton.window)))
|
||||
for(i = 0; i < conf.titlebar.nmouse; ++i)
|
||||
if(ev.xbutton.button == conf.titlebar.mouse[i].button)
|
||||
@ -140,7 +140,6 @@ configurerequest(XEvent ev)
|
||||
if(wc.y < mw && wc.x < mh)
|
||||
client_moveresize(c, geo, True);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -183,7 +182,7 @@ expose(XEvent ev)
|
||||
&& (ev.xexpose.window == bar->win))
|
||||
updatebar();
|
||||
|
||||
if(conf.titlebar.height)
|
||||
if(conf.titlebar.exist)
|
||||
for(c = clients; c; c = c->next)
|
||||
if(ev.xexpose.window == c->tbar->win)
|
||||
titlebar_update(c);
|
||||
|
||||
@ -189,6 +189,7 @@ tile(void)
|
||||
uint n, mwfact = tags[seltag].mwfact * sgeo.width;
|
||||
uint nmaster = tags[seltag].nmaster;
|
||||
uint tileheight, i, border = conf.client.borderheight * 2;
|
||||
int titlebarh = conf.titlebar.height;
|
||||
|
||||
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), ++n);
|
||||
if(!n)
|
||||
@ -238,9 +239,9 @@ tile(void)
|
||||
|
||||
/* Remainder */
|
||||
if(i + 1 == (n < nmaster ? n : nmaster))
|
||||
cgeo.height = (sgeo.height - mastergeo.height * i) + conf.titlebar.height;
|
||||
cgeo.height = (sgeo.height - mastergeo.height * i) + titlebarh;
|
||||
|
||||
cgeo.height -= border + conf.titlebar.height;
|
||||
cgeo.height -= border + titlebarh;
|
||||
}
|
||||
|
||||
/* Tiled Client */
|
||||
@ -258,13 +259,13 @@ tile(void)
|
||||
if(i + 1 == n)
|
||||
cgeo.height = (sgeo.y + sgeo.height) - cgeo.y - border;
|
||||
else
|
||||
cgeo.height = tileheight - (border + conf.titlebar.height);
|
||||
cgeo.height = tileheight - (border + titlebarh);
|
||||
}
|
||||
|
||||
client_moveresize(c, cgeo, tags[seltag].resizehint);
|
||||
|
||||
if(n > nmaster && tileheight != sgeo.height)
|
||||
cgeo.y = c->geo.y + c->geo.height + border + conf.titlebar.height;
|
||||
cgeo.y = c->geo.y + c->geo.height + border + titlebarh;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@ -172,6 +172,7 @@ typedef struct
|
||||
} client;
|
||||
struct
|
||||
{
|
||||
Bool exist;
|
||||
Bool pos;
|
||||
int height;
|
||||
uint bg;
|
||||
|
||||
@ -41,7 +41,7 @@ titlebar_create(Client *c)
|
||||
if(conf.titlebar.pos)
|
||||
y = c->geo.y + c->geo.height + conf.client.borderheight;
|
||||
else
|
||||
y = c->geo.y - conf.titlebar.height;
|
||||
y = c->geo.y - (conf.titlebar.height + conf.client.borderheight);
|
||||
|
||||
c->tbar = bar_create(c->geo.x,
|
||||
y,
|
||||
@ -60,7 +60,7 @@ titlebar_get(Window w)
|
||||
{
|
||||
Client *c;
|
||||
|
||||
if(!conf.titlebar.height)
|
||||
if(!conf.titlebar.exist)
|
||||
return NULL;
|
||||
|
||||
for(c = clients; c && c->tbar->win != w; c = c->next);
|
||||
@ -78,7 +78,6 @@ titlebar_update_position(Client *c)
|
||||
y = c->geo.y + c->geo.height + conf.client.borderheight;
|
||||
else
|
||||
y = c->geo.y - conf.titlebar.height;
|
||||
|
||||
bar_moveresize(c->tbar, c->geo.x, y, c->geo.width,
|
||||
conf.titlebar.height - conf.client.borderheight);
|
||||
|
||||
@ -95,7 +94,7 @@ titlebar_update(Client *c)
|
||||
if(!c->title)
|
||||
c->title = strdup("WMFS");
|
||||
|
||||
if(!conf.titlebar.height)
|
||||
if(!conf.titlebar.exist)
|
||||
return;
|
||||
|
||||
bar_refresh_color(c->tbar);
|
||||
|
||||
@ -178,16 +178,14 @@ init(void)
|
||||
updatebar();
|
||||
|
||||
/* INIT WORKABLE SPACE GEOMETRY */
|
||||
conf.titlebar.height += conf.client.borderheight;
|
||||
sgeo.x = 0;
|
||||
if(conf.bartop)
|
||||
sgeo.y = conf.titlebar.pos ? barheight : barheight + conf.titlebar.height;
|
||||
else
|
||||
sgeo.y = conf.titlebar.pos ? 0 : conf.titlebar.height;
|
||||
sgeo.width = DisplayWidth(dpy, screen);
|
||||
sgeo.width = DisplayWidth(dpy, screen);
|
||||
sgeo.height = DisplayHeight(dpy, screen) - (barheight + conf.titlebar.height);
|
||||
|
||||
|
||||
/* INIT STUFF */
|
||||
grabkeys();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user