X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=layout.c;h=5a32fd380d0e9761fb118af37175f421d8980b6d;hp=5a7d4b45349b4786289508c79752a1e0a6c3061c;hb=a730213c3b47397c890eea0df7e03e45d5d38b6d;hpb=4bd4f421d39823a5514ff43640401719be3efbf3 diff --git a/layout.c b/layout.c index 5a7d4b4..5a32fd3 100644 --- a/layout.c +++ b/layout.c @@ -1,7 +1,8 @@ -/* (C)opyright MMVI-MMVII Anselm R. Garbe - * See LICENSE file for license details. - */ +/* © 2006-2007 Anselm R. Garbe + * © 2006-2007 Sander van Dijk + * See LICENSE file for license details. */ #include "dwm.h" +#include unsigned int blw = 0; Layout *lt = NULL; @@ -30,7 +31,7 @@ tile(void) { if(c->isbanned) XMoveWindow(dpy, c->win, c->x, c->y); c->isbanned = False; - if(c->isversatile) + if(c->isfloating) continue; c->ismax = False; nx = wax; @@ -69,30 +70,45 @@ LAYOUTS /* extern */ void -focusnext(Arg arg) { +floating(void) { Client *c; - - if(!sel) - return; - for(c = sel->next; c && !isvisible(c); c = c->next); - if(!c) - for(c = clients; c && !isvisible(c); c = c->next); - if(c) { + + for(c = clients; c; c = c->next) { + if(isvisible(c)) { + if(c->isbanned) + XMoveWindow(dpy, c->win, c->x, c->y); + c->isbanned = False; + resize(c, c->x, c->y, c->w, c->h, True); + } + else { + c->isbanned = True; + XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); + } + } + if(!sel || !isvisible(sel)) { + for(c = stack; c && !isvisible(c); c = c->snext); focus(c); - restack(); } + restack(); } void -focusprev(Arg arg) { +focusclient(const char *arg) { Client *c; - - if(!sel) + + if(!sel || !arg) return; - for(c = sel->prev; c && !isvisible(c); c = c->prev); - if(!c) { - for(c = clients; c && c->next; c = c->next); - for(; c && !isvisible(c); c = c->prev); + if(atoi(arg) < 0) { + for(c = sel->prev; c && !isvisible(c); c = c->prev); + if(!c) { + for(c = clients; c && c->next; c = c->next); + for(; c && !isvisible(c); c = c->prev); + } + } + else { + for(c = sel->next; c && !isvisible(c); c = c->next); + if(!c) + for(c = clients; c && !isvisible(c); c = c->next); } if(c) { focus(c); @@ -101,26 +117,35 @@ focusprev(Arg arg) { } void -incmasterw(Arg arg) { +incmasterw(const char *arg) { + int i; if(lt->arrange != tile) return; - if(arg.i == 0) + if(!arg) masterw = MASTERWIDTH; else { - if(waw * (masterw + arg.i) / 1000 >= waw - 2 * BORDERPX - || waw * (masterw + arg.i) / 1000 <= 2 * BORDERPX) + i = atoi(arg); + if(waw * (masterw + i) / 1000 >= waw - 2 * BORDERPX + || waw * (masterw + i) / 1000 <= 2 * BORDERPX) return; - masterw += arg.i; + masterw += i; } lt->arrange(); } void -incnmaster(Arg arg) { - if((lt->arrange != tile) || (nmaster + arg.i < 1) - || (wah / (nmaster + arg.i) <= 2 * BORDERPX)) - return; - nmaster += arg.i; +incnmaster(const char *arg) { + int i; + + if(!arg) + nmaster = NMASTER; + else { + i = atoi(arg); + if((lt->arrange != tile) || (nmaster + i < 1) + || (wah / (nmaster + i) <= 2 * BORDERPX)) + return; + nmaster += i; + } if(sel) lt->arrange(); else @@ -142,7 +167,7 @@ initlayouts(void) { Client * nexttiled(Client *c) { - for(; c && (c->isversatile || !isvisible(c)); c = c->next); + for(; c && (c->isfloating || !isvisible(c)); c = c->next); return c; } @@ -154,10 +179,10 @@ restack(void) { drawstatus(); if(!sel) return; - if(sel->isversatile || lt->arrange == versatile) + if(sel->isfloating || lt->arrange == floating) XRaiseWindow(dpy, sel->win); - if(lt->arrange != versatile) { - if(!sel->isversatile) + if(lt->arrange != floating) { + if(!sel->isfloating) XLowerWindow(dpy, sel->win); for(c = nexttiled(clients); c; c = nexttiled(c->next)) { if(c == sel) @@ -170,10 +195,10 @@ restack(void) { } void -setlayout(Arg arg) { - unsigned int i; +setlayout(const char *arg) { + int i; - if(arg.i == -1) { + if(!arg) { for(i = 0; i < nlayouts && lt != &layout[i]; i++); if(i == nlayouts - 1) lt = &layout[0]; @@ -181,9 +206,10 @@ setlayout(Arg arg) { lt = &layout[++i]; } else { - if(arg.i < 0 || arg.i >= nlayouts) + i = atoi(arg); + if(i < 0 || i >= nlayouts) return; - lt = &layout[arg.i]; + lt = &layout[i]; } if(sel) lt->arrange(); @@ -192,10 +218,10 @@ setlayout(Arg arg) { } void -togglemax(Arg arg) { +togglemax(const char *arg) { XEvent ev; - if(!sel || (lt->arrange != versatile && !sel->isversatile) || sel->isfixed) + if(!sel || (lt->arrange != floating && !sel->isfloating) || sel->isfixed) return; if((sel->ismax = !sel->ismax)) { sel->rx = sel->x; @@ -211,34 +237,11 @@ togglemax(Arg arg) { } void -versatile(void) { - Client *c; - - for(c = clients; c; c = c->next) { - if(isvisible(c)) { - if(c->isbanned) - XMoveWindow(dpy, c->win, c->x, c->y); - c->isbanned = False; - resize(c, c->x, c->y, c->w, c->h, True); - } - else { - c->isbanned = True; - XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); - } - } - if(!sel || !isvisible(sel)) { - for(c = stack; c && !isvisible(c); c = c->snext); - focus(c); - } - restack(); -} - -void -zoom(Arg arg) { +zoom(const char *arg) { unsigned int n; Client *c; - if(!sel || lt->arrange != tile || sel->isversatile) + if(!sel || lt->arrange != tile || sel->isfloating) return; for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) n++;