X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=view.c;h=abd8ca6cd0ad5a309517f340aaedcfcbb75cce89;hb=4b5b3d90af58f860569178e554604717ef51152d;hp=0f9cb68138735b3d6f5c4e953f8b0c040ac4ad78;hpb=10885d349a8426f0a55f34e78a2592267e8e55be;p=dwm.git diff --git a/view.c b/view.c index 0f9cb68..abd8ca6 100644 --- a/view.c +++ b/view.c @@ -1,5 +1,4 @@ -/* - * (C)opyright MMVI Anselm R. Garbe +/* (C)opyright MMVI Anselm R. Garbe * See LICENSE file for license details. */ #include "dwm.h" @@ -43,9 +42,12 @@ reorder(void) { } static void -togglemax(Client *c) -{ +togglemax(Client *c) { XEvent ev; + + if(c->isfixed) + return; + if((c->ismax = !c->ismax)) { c->rx = c->x; c->x = sx; c->ry = c->y; c->y = bh; @@ -64,7 +66,7 @@ togglemax(Client *c) /* extern */ -void (*arrange)(Arg *) = DEFMODE; +void (*arrange)(void) = DEFMODE; void detach(Client *c) { @@ -78,7 +80,7 @@ detach(Client *c) { } void -dofloat(Arg *arg) { +dofloat(void) { Client *c; for(c = clients; c; c = c->next) { @@ -95,28 +97,21 @@ dofloat(Arg *arg) { restack(); } -/* This algorithm is based on a (M)aster area and a (S)tacking area. - * It supports following arrangements: - * SSMMM MMMMM MMMSS - * SSMMM SSSSS MMMSS - */ void -dotile(Arg *arg) { - unsigned int i, n, md, stackw, stackh, th; +dotile(void) { + unsigned int i, n, mpx, stackw, stackh, th; Client *c; for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) n++; - - md = (sw * master) / 1000; - stackw = sw - md; + mpx = (sw * master) / 1000; + stackw = sw - mpx; stackh = sh - bh; - th = stackh; if(n > 1) th /= (n - 1); - for(i = 0, c = clients; c; c = c->next) { + for(i = 0, c = clients; c; c = c->next) if(isvisible(c)) { if(c->isfloat) { resize(c, True, TopLeft); @@ -130,29 +125,28 @@ dotile(Arg *arg) { c->h = sh - 2 * BORDERPX - bh; } else if(i == 0) { /* master window */ - c->w = md - 2 * BORDERPX; + c->w = mpx - 2 * BORDERPX; c->h = sh - bh - 2 * BORDERPX; } else { /* tile window */ - c->x += md; + c->x += mpx; + c->w = stackw - 2 * BORDERPX; if(th > bh) { c->y = sy + (i - 1) * th + bh; if(i + 1 == n) c->h = sh - c->y - 2 * BORDERPX; - c->w = stackw - 2 * BORDERPX; - c->h = th - 2 * BORDERPX; + else + c->h = th - 2 * BORDERPX; } - else { /* fallback if th < bh */ - c->w = stackw - 2 * BORDERPX; + else /* fallback if th < bh */ c->h = stackh - 2 * BORDERPX; - } } resize(c, False, TopLeft); i++; } else ban(c); - } + if(!sel || !isvisible(sel)) { for(c = stack; c && !isvisible(c); c = c->snext); focus(c); @@ -166,7 +160,6 @@ focusnext(Arg *arg) { if(!sel) return; - if(!(c = getnext(sel->next))) c = getnext(clients); if(c) { @@ -181,7 +174,6 @@ focusprev(Arg *arg) { if(!sel) return; - if(!(c = getprev(sel->prev))) { for(c = clients; c && c->next; c = c->next); c = getprev(c); @@ -203,27 +195,11 @@ isvisible(Client *c) { } void -resizecol(Arg *arg) { - unsigned int n; - Client *c; - - for(n = 0, c = clients; c; c = c->next) - if(isvisible(c) && !c->isfloat) - n++; - if(!sel || sel->isfloat || n < 2 || (arrange == dofloat)) +resizemaster(Arg *arg) { + if(master + arg->i > 950 || master + arg->i < 50) return; - - if(sel == getnext(clients)) { - if(master + arg->i > 950 || master + arg->i < 50) - return; - master += arg->i; - } - else { - if(master - arg->i > 950 || master - arg->i < 50) - return; - master -= arg->i; - } - arrange(NULL); + master += arg->i; + arrange(); } void @@ -260,7 +236,7 @@ void togglemode(Arg *arg) { arrange = (arrange == dofloat) ? dotile : dofloat; if(sel) - arrange(NULL); + arrange(); else drawstatus(); } @@ -274,7 +250,7 @@ toggleview(Arg *arg) { if(i == ntags) seltag[arg->i] = True; /* cannot toggle last view */ reorder(); - arrange(NULL); + arrange(); } void @@ -285,7 +261,7 @@ view(Arg *arg) { seltag[i] = False; seltag[arg->i] = True; reorder(); - arrange(NULL); + arrange(); } void @@ -295,11 +271,9 @@ viewall(Arg *arg) { for(i = 0; i < ntags; i++) seltag[i] = True; reorder(); - arrange(NULL); + arrange(); } - - void zoom(Arg *arg) { unsigned int n; @@ -307,18 +281,15 @@ zoom(Arg *arg) { if(!sel) return; - if(sel->isfloat || (arrange == dofloat)) { togglemax(sel); return; } - for(n = 0, c = clients; c; c = c->next) if(isvisible(c) && !c->isfloat) n++; if(n < 2 || (arrange == dofloat)) return; - if((c = sel) == nexttiled(clients)) if(!(c = nexttiled(c->next))) return; @@ -328,5 +299,5 @@ zoom(Arg *arg) { c->next = clients; clients = c; focus(c); - arrange(NULL); + arrange(); }