diff --git a/src/bar.c b/src/bar.c index a936e5a..faf1f72 100644 --- a/src/bar.c +++ b/src/bar.c @@ -210,6 +210,8 @@ uicb_togglebarpos(uicb_t cmd) int i; conf.bartop = !conf.bartop; + sgeo.y = (conf.bartop) ? barheight : 0; + if(conf.bartop) bary = 0; else diff --git a/src/client.c b/src/client.c index 0801ee8..e79dc1e 100644 --- a/src/client.c +++ b/src/client.c @@ -193,9 +193,8 @@ client_hide(Client *c) XMoveWindow(dpy, c->win, c->x, c->y+mh*2); if(conf.ttbarheight) - bar_moveresize(c->tbar, c->x, c->y+mh*2, c->w, c->h); + bar_moveresize(c->tbar, c->x, c->y+mh*2, c->w, c->h); - //unmapclient(c); setwinstate(c->win, IconicState); c->hide = True; @@ -262,7 +261,7 @@ client_manage(Window w, XWindowAttributes *wa) c->x = wa->x; c->y = wa->y + conf.ttbarheight + barheight; c->w = wa->width; - c->h = wa->height; + c->h = wa->height - conf.ttbarheight-1; c->tag = seltag; /* Create titlebar */ @@ -288,7 +287,7 @@ client_manage(Window w, XWindowAttributes *wa) raiseclient(c); client_attach(c); - XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); + client_moveresize(c, c->x, c->y, c->w, c->h, True); mapclient(c); setwinstate(c->win, NormalState); client_focus(c); @@ -351,10 +350,10 @@ client_moveresize(Client *c, int x, int y, int w, int h, bool r) c->x = x; c->y = y; c->w = w; c->h = h; - XMoveResizeWindow(dpy, c->win, x, y, w ,h); + XMoveResizeWindow(dpy, c->win, x, y + conf.ttbarheight, w, h - conf.ttbarheight - 1); if(conf.ttbarheight) - bar_moveresize(c->tbar, x, y - conf.ttbarheight, w, conf.ttbarheight); + bar_moveresize(c->tbar, x, y - 1, w, conf.ttbarheight); updatetitlebar(c); XSync(dpy, False); @@ -450,11 +449,9 @@ client_unhide(Client *c) { if(!c) return; - XMoveWindow(dpy, c->win, c->x, c->y); + XMoveWindow(dpy, c->win, c->x, c->y + conf.ttbarheight); if(conf.ttbarheight) - bar_moveresize(c->tbar, c->x, c->y - conf.ttbarheight, c->w, conf.ttbarheight); - - //mapclient(c); + bar_moveresize(c->tbar, c->x, c->y - 1, c->w, conf.ttbarheight); setwinstate(c->win, NormalState); c->hide = False; diff --git a/src/config.c b/src/config.c index bea1580..59058cb 100644 --- a/src/config.c +++ b/src/config.c @@ -318,7 +318,7 @@ init_conf(void) if((cfg_size(cfg_variables, "var")) > 256) { - fprintf(stderr,"WMFS Configuration: Too much of variables !\n"); + fprintf(stderr,"WMFS Configuration: Too many variables !\n"); exit(EXIT_FAILURE); } @@ -355,7 +355,7 @@ init_conf(void) if((conf.nlayout = cfg_size(cfg_layouts, "layout")) > MAXLAYOUT || !(conf.nlayout = cfg_size(cfg_layouts, "layout"))) { - fprintf(stderr, "WMFS Configuration: Too much or no layouts\n"); + fprintf(stderr, "WMFS Configuration: Too many or no layouts\n"); conf.nlayout = 1; conf.layout[0].symbol = strdup("TILE"); conf.layout[0].func = tile; @@ -389,7 +389,7 @@ init_conf(void) conf.ntag = cfg_size(cfg_tags, "tag"); if(!conf.ntag || conf.ntag > MAXTAG) { - fprintf(stderr, "WMFS Configuration: Too much or no tag" + fprintf(stderr, "WMFS Configuration: Too many or no tag" " (%d) in the configration file\n", conf.ntag); conf.ntag = 1; conf.tag[0].name = strdup("WMFS"); diff --git a/src/draw.c b/src/draw.c index b68c2df..2170822 100644 --- a/src/draw.c +++ b/src/draw.c @@ -90,8 +90,8 @@ draw_taglist(Drawable dr) void draw_layout(void) { - draw_text(bar->dr, taglen[conf.ntag] + PAD/2, fonth, conf.colors.layout_fg, - conf.colors.layout_bg, PAD, tags[seltag].layout.symbol); + draw_text(bar->dr, taglen[conf.ntag] + BPAD/2, fonth, conf.colors.layout_fg, + conf.colors.layout_bg, BPAD, tags[seltag].layout.symbol); return; } diff --git a/src/event.c b/src/event.c index 91e3cde..0aff484 100644 --- a/src/event.c +++ b/src/event.c @@ -481,7 +481,8 @@ unmapnotify(XEvent ev) Client *c; if((c = getclient(ev.xunmap.window))) - client_unmanage(c); + if(!c->hide) + client_unmanage(c); return; } diff --git a/src/layout.c b/src/layout.c index 3c104c8..2e92a80 100644 --- a/src/layout.c +++ b/src/layout.c @@ -125,9 +125,9 @@ maxlayout(void) c->ox = c->x; c->oy = c->y; c->ow = c->w; c->oh = c->h; - client_moveresize(c, 0, (conf.ttbarheight + ((conf.bartop) ? barheight : 0)), - (mw - (conf.borderheight * 2)), - (mh - (conf.borderheight * 2) - conf.ttbarheight - barheight), False); + client_moveresize(c, sgeo.x, sgeo.y, + (sgeo.width - (conf.borderheight * 2)), + (sgeo.height - (conf.borderheight * 2)), False); } return; @@ -176,72 +176,83 @@ uicb_set_nmaster(uicb_t cmd) void tile(void) { - uint i, n, x, y, yt, w, h, ww, hh, th; - uint barto, bord, mwf, nm, mht; Client *c; + XRectangle mastergeo = {0, 0, 0, 0}; + XRectangle cgeo = {sgeo.x, sgeo.y, 0, 0}; + uint n, mwfact = tags[seltag].mwfact * sgeo.width; + uint nmaster = tags[seltag].nmaster; + uint tileheight, i, border = conf.borderheight*2; - bord = conf.borderheight * 2; - barto = conf.ttbarheight + barheight; - mwf = tags[seltag].mwfact * mw; - nm = tags[seltag].nmaster; - mht = mh - ((conf.bartop) ? 0 : barheight); - - /* count all the "can-be-tiled" client */ for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), ++n); if(!n) return; - /* window geoms */ - hh = ((n <= nm) ? mht / (n > 0 ? n : 1) : mht / nm) - bord*2; - ww = (n <= nm) ? mw : mwf; - th = (n > nm) ? mht / (n - nm) : 0; - if(n > nm && th < barheight) - th = mht; + /* Define the master(s) client(s) size */ + if(n <= nmaster) + { + mastergeo.height = sgeo.height / (n > 0 ? n : 1); + mastergeo.width = sgeo.width; + } + else + { + mastergeo.height = sgeo.height / nmaster; + mastergeo.width = mwfact; + } - x = 0; - y = yt = barto; + /* Define the tiled clients size, so if the clients number > nmaster */ + if(n > nmaster) + tileheight = sgeo.height / (n - nmaster); + else + tileheight = 0; + + if(n > nmaster && tileheight < barheight) + tileheight = sgeo.height; - if(!conf.bartop) - y = yt = conf.ttbarheight; for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) { - c->max = False; - c->lmax = False; + /* Set client property */ + c->max = c->lmax = False; c->tile = True; c->ox = c->x; c->oy = c->y; c->ow = c->w; c->oh = c->h; - /* MASTER CLIENT */ - if(i < nm) + /* Master Client */ + if(i < nmaster) { - y = yt + i * hh; - w = ww - bord; - h = hh; - /* remainder */ - if(i + 1 == (n < nm ? n : nm)) - h = (mht - hh*i) - - ((conf.bartop) ? barheight: 0); - h -= bord + conf.ttbarheight; + cgeo.y = sgeo.y + (i * mastergeo.height); + cgeo.width = mastergeo.width - border; + cgeo.height = mastergeo.height; + + /* Remainder */ + if(i + 1 == (n < nmaster ? n : nmaster)) + cgeo.height = (sgeo.height - mastergeo.height * i); + + cgeo.height -= border; } - /* TILE CLIENT */ + + /* Tiled Client */ else { - if(i == nm) + if(i == nmaster) { - y = yt; - x += ww; + cgeo.y = sgeo.y; + cgeo.x += mastergeo.width; } - w = mw - ww - bord; - /* remainder */ + + cgeo.width = sgeo.width - mastergeo.width - border; + + /* Remainder */ if(i + 1 == n) - h = (barto + mht) - y - (bord + barto); + cgeo.height = (sgeo.y + sgeo.height) - cgeo.y - border; else - h = th - (bord + conf.ttbarheight) - bord*2; + cgeo.height = tileheight - border; } - client_moveresize(c, x, y, w, h, tags[seltag].resizehint); - if(n > nm && th != mht) - y = c->y + c->h + bord + conf.ttbarheight; + + client_moveresize(c, cgeo.x, cgeo.y, cgeo.width, cgeo.height, tags[seltag].resizehint); + + if(n > nmaster && tileheight != sgeo.height) + cgeo.y = c->y + c->h + border; } return; diff --git a/src/tag.c b/src/tag.c index 41b22d7..621f9ff 100644 --- a/src/tag.c +++ b/src/tag.c @@ -81,6 +81,7 @@ uicb_tag_prev(uicb_t cmd) void uicb_tagtransfert(uicb_t cmd) { + Client *c; int n = atoi(cmd); if(!sel) @@ -91,6 +92,9 @@ uicb_tagtransfert(uicb_t cmd) sel->tag = n; selbytag[n] = sel; + c = (sel->next->tag == seltag) ? sel->next : NULL; + client_focus(((c) ? c : NULL)); + arrange(); return; diff --git a/src/wmfs.c b/src/wmfs.c index 835656b..fd18cd2 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -32,7 +32,6 @@ #include "wmfs.h" - void checkotherwm(void) { @@ -121,6 +120,7 @@ init(void) mw = DisplayWidth (dpy, screen); mh = DisplayHeight (dpy, screen); + /* INIT TAG / LAYOUT ATTRIBUTE */ seltag = 1; for(i = 0; i < conf.ntag + 1; ++i) @@ -175,6 +175,13 @@ init(void) updatebutton(False); updatebar(); + /* INIT WORKABLE SPACE */ + sgeo.x = 0; + sgeo.y = (conf.bartop) ? barheight+1 : 1; + sgeo.width = DisplayWidth(dpy, screen); + sgeo.height = DisplayHeight(dpy, screen) - barheight; + + /* INIT STUFF */ grabkeys(); diff --git a/src/wmfs.h b/src/wmfs.h index 7b731cf..68dac44 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -171,6 +171,7 @@ Display *dpy; XEvent event; GC gc; Window root; +XRectangle sgeo; int screen; int mw, mh; Conf conf;