From 385d76be0506505d8b2432f25c389e131e52081d Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sat, 25 Oct 2008 17:36:01 +0200 Subject: [PATCH] titlebar: Fix titlebar less and placement --- src/client.c | 20 ++++++++++---------- src/config.c | 1 + src/event.c | 5 ++--- src/layout.c | 9 +++++---- src/structs.h | 1 + src/titlebar.c | 7 +++---- src/wmfs.c | 4 +--- 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/client.c b/src/client.c index 697adcf..520c4d2 100644 --- a/src/client.c +++ b/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; diff --git a/src/config.c b/src/config.c index e35a1ef..b294f21 100644 --- a/src/config.c +++ b/src/config.c @@ -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")); diff --git a/src/event.c b/src/event.c index 649c8b3..3742a89 100644 --- a/src/event.c +++ b/src/event.c @@ -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); diff --git a/src/layout.c b/src/layout.c index 4c7c6f0..516d500 100644 --- a/src/layout.c +++ b/src/layout.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; diff --git a/src/structs.h b/src/structs.h index 2d07650..6a0fb8c 100644 --- a/src/structs.h +++ b/src/structs.h @@ -172,6 +172,7 @@ typedef struct } client; struct { + Bool exist; Bool pos; int height; uint bg; diff --git a/src/titlebar.c b/src/titlebar.c index 253836f..5da3f94 100644 --- a/src/titlebar.c +++ b/src/titlebar.c @@ -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); diff --git a/src/wmfs.c b/src/wmfs.c index 4b99b32..7b293b1 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -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();