several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH

This commit is contained in:
Anselm R. Garbe 2007-02-22 07:59:13 +01:00
parent b3b58c08e4
commit 352cae4380
10 changed files with 188 additions and 187 deletions

View file

@ -83,24 +83,6 @@ setclientstate(Client *c, long state) {
PropModeReplace, (unsigned char *)data, 2);
}
static void
togglemax(Client *c) {
XEvent ev;
if(c->isfixed)
return;
if((c->ismax = !c->ismax)) {
c->rx = c->x;
c->ry = c->y;
c->rw = c->w;
c->rh = c->h;
resize(c, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
}
else
resize(c, c->rx, c->ry, c->rw, c->rh, True);
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}
static int
xerrordummy(Display *dsply, XErrorEvent *ee) {
return 0;
@ -171,7 +153,7 @@ focus(Client *c) {
}
void
killclient(Arg *arg) {
killclient(Arg arg) {
if(!sel)
return;
if(isprotodel(sel))
@ -303,7 +285,7 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
}
void
toggleversatile(Arg *arg) {
toggleversatile(Arg arg) {
if(!sel || lt->arrange == versatile)
return;
sel->isversatile = !sel->isversatile;
@ -402,25 +384,3 @@ unmanage(Client *c) {
XUngrabServer(dpy);
lt->arrange();
}
void
zoom(Arg *arg) {
unsigned int n;
Client *c;
if(!sel)
return;
if(sel->isversatile || (lt->arrange == versatile)) {
togglemax(sel);
return;
}
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
n++;
if((c = sel) == nexttiled(clients))
if(!(c = nexttiled(c->next)))
return;
detach(c);
attach(c);
focus(c);
lt->arrange();
}

View file

@ -14,7 +14,6 @@
#define TOPBAR True /* False */
/* behavior */
#define SNAP 40 /* pixel */
#define TAGS \
const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
#define RULES \
@ -33,49 +32,17 @@ static Layout layout[] = { \
{ "[]=", tile }, /* first entry is default */ \
{ "><>", versatile }, \
};
#define MASTER 600 /* per thousand */
#define MASTERWIDTH 600 /* master width per thousand */
#define NMASTER 1 /* clients in master area */
#define SNAP 40 /* versatile snap pixel */
/* key definitions */
#define MODKEY Mod1Mask
#define KEYS \
static Key key[] = { \
/* modifier key function argument */ \
{ MODKEY|ShiftMask, XK_Return, spawn, \
{ .cmd = "exec urxvtcd -tr -bg '#292929' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" } }, \
{ MODKEY, XK_p, spawn, \
{ .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \
" | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \
"-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \
{ MODKEY, XK_j, focusnext, { 0 } }, \
{ MODKEY, XK_k, focusprev, { 0 } }, \
{ MODKEY, XK_Return, zoom, { 0 } }, \
{ MODKEY, XK_g, resizemaster, { .i = 15 } }, \
{ MODKEY, XK_s, resizemaster, { .i = -15 } }, \
{ MODKEY, XK_i, incnmaster, { .i = 1 } }, \
{ MODKEY, XK_d, incnmaster, { .i = -1 } }, \
{ MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
{ MODKEY|ShiftMask, XK_4, tag, { .i = 3 } }, \
{ MODKEY|ShiftMask, XK_5, tag, { .i = 4 } }, \
{ MODKEY|ShiftMask, XK_6, tag, { .i = 5 } }, \
{ MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \
{ MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \
{ MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
{ MODKEY, XK_space, setlayout, { .i = -1 } }, \
{ MODKEY|ShiftMask, XK_space, toggleversatile,{ 0 } }, \
{ MODKEY, XK_0, view, { .i = -1 } }, \
{ MODKEY, XK_1, view, { .i = 0 } }, \
{ MODKEY, XK_2, view, { .i = 1 } }, \
@ -86,6 +53,32 @@ static Key key[] = { \
{ MODKEY, XK_7, view, { .i = 6 } }, \
{ MODKEY, XK_8, view, { .i = 7 } }, \
{ MODKEY, XK_9, view, { .i = 8 } }, \
{ MODKEY, XK_d, incnmaster, { .i = -1 } }, \
{ MODKEY, XK_h, incmasterw, { .i = -15 } }, \
{ MODKEY, XK_i, incnmaster, { .i = 1 } }, \
{ MODKEY, XK_j, focusnext, { 0 } }, \
{ MODKEY, XK_k, focusprev, { 0 } }, \
{ MODKEY, XK_l, incmasterw, { .i = 15 } }, \
{ MODKEY, XK_m, togglemax, { 0 } }, \
{ MODKEY, XK_p, spawn, \
{ .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \
" | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \
"-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \
{ MODKEY|ShiftMask, XK_Return, spawn, \
{ .cmd = "exec urxvtcd -tr -bg '#292929' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" } }, \
{ MODKEY|ShiftMask, XK_space, toggleversatile,{ 0 } }, \
{ MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
{ MODKEY|ShiftMask, XK_4, tag, { .i = 3 } }, \
{ MODKEY|ShiftMask, XK_5, tag, { .i = 4 } }, \
{ MODKEY|ShiftMask, XK_6, tag, { .i = 5 } }, \
{ MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \
{ MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \
{ MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
{ MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \
{ MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \
{ MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \
@ -95,5 +88,13 @@ static Key key[] = { \
{ MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \
{ MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \
{ MODKEY|ControlMask, XK_9, toggleview, { .i = 8 } }, \
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \
};

View file

@ -14,7 +14,6 @@
#define TOPBAR True /* False */
/* behavior */
#define SNAP 20 /* pixel */
#define TAGS \
const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
/* Query class:instance:title for regex matching info with following command:
@ -34,44 +33,17 @@ static Layout layout[] = { \
{ "[]=", tile }, /* first entry is default */ \
{ "><>", versatile }, \
};
#define MASTER 600 /* per thousand */
#define MASTERWIDTH 600 /* master width per thousand */
#define NMASTER 1 /* clients in master area */
#define SNAP 20 /* versatile snap pixel */
/* key definitions */
#define MODKEY Mod1Mask
#define KEYS \
static Key key[] = { \
/* modifier key function argument */ \
{ MODKEY|ShiftMask, XK_Return, spawn, { .cmd = "exec xterm" } }, \
{ MODKEY, XK_Tab, focusnext, { 0 } }, \
{ MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \
{ MODKEY, XK_Return, zoom, { 0 } }, \
{ MODKEY, XK_g, resizemaster, { .i = 15 } }, \
{ MODKEY, XK_s, resizemaster, { .i = -15 } }, \
{ MODKEY, XK_i, incnmaster, { .i = 1 } }, \
{ MODKEY, XK_d, incnmaster, { .i = -1 } }, \
{ MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
{ MODKEY|ShiftMask, XK_4, tag, { .i = 3 } }, \
{ MODKEY|ShiftMask, XK_5, tag, { .i = 4 } }, \
{ MODKEY|ShiftMask, XK_6, tag, { .i = 5 } }, \
{ MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \
{ MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \
{ MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
{ MODKEY, XK_space, setlayout, { .i = -1 } }, \
{ MODKEY|ShiftMask, XK_space, toggleversatile,{ 0 } }, \
{ MODKEY, XK_0, view, { .i = -1 } }, \
{ MODKEY, XK_1, view, { .i = 0 } }, \
{ MODKEY, XK_2, view, { .i = 1 } }, \
@ -82,6 +54,27 @@ static Key key[] = { \
{ MODKEY, XK_7, view, { .i = 6 } }, \
{ MODKEY, XK_8, view, { .i = 7 } }, \
{ MODKEY, XK_9, view, { .i = 8 } }, \
{ MODKEY, XK_d, incnmaster, { .i = -1 } }, \
{ MODKEY, XK_h, incmasterw, { .i = -15 } }, \
{ MODKEY, XK_i, incnmaster, { .i = 1 } }, \
{ MODKEY, XK_j, focusnext, { 0 } }, \
{ MODKEY, XK_k, focusprev, { 0 } }, \
{ MODKEY, XK_l, incmasterw, { .i = 15 } }, \
{ MODKEY, XK_m, togglemax, { 0 } }, \
{ MODKEY|ShiftMask, XK_Return, spawn, { .cmd = "exec xterm" } }, \
{ MODKEY|ShiftMask, XK_space, toggleversatile,{ 0 } }, \
{ MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
{ MODKEY|ShiftMask, XK_4, tag, { .i = 3 } }, \
{ MODKEY|ShiftMask, XK_5, tag, { .i = 4 } }, \
{ MODKEY|ShiftMask, XK_6, tag, { .i = 5 } }, \
{ MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \
{ MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \
{ MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
{ MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \
{ MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \
{ MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \
@ -91,5 +84,13 @@ static Key key[] = { \
{ MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \
{ MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \
{ MODKEY|ControlMask, XK_9, toggleview, { .i = 8 } }, \
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \
};

15
dwm.1
View file

@ -60,19 +60,19 @@ click on a tag label adds/removes that tag to/from the focused window.
Start
.BR xterm (1).
.TP
.B Mod1-Tab
.B Mod1-j
Focus next window.
.TP
.B Mod1-Shift-Tab
.B Mod1-k
Focus previous window.
.TP
.B Mod1-Return
Zooms/cycles current window to/from master area (tiling layout), toggles maximization of current window (versatile layout).
Zooms/cycles current window to/from master area (tiling layout only).
.TP
.B Mod1-g
.B Mod1-l
Grow master area (tiling layout only).
.TP
.B Mod1-s
.B Mod1-h
Shrink master area (tiling layout only).
.TP
.B Mod1-i
@ -81,6 +81,9 @@ Increase the number of windows in the master area (tiling layout only).
.B Mod1-d
Decrease the number of windows in the master area (tiling layout only).
.TP
.B Mod1-m
Toggles maximization of current window (versatile layout only).
.TP
.B Mod1-Shift-[1..n]
Apply
.RB nth
@ -124,7 +127,7 @@ Quit dwm.
Move current window while dragging (versatile layout only).
.TP
.B Mod1-Button2
Zooms/cycles current window to/from master area (tiling layout), toggles maximization of current window (versatile layout).
Zooms/cycles current window to/from master area (tiling layout only).
.TP
.B Mod1-Button3
Resize current window while dragging (versatile layout only).

30
dwm.h
View file

@ -90,7 +90,6 @@ extern char stext[256]; /* status text */
extern int screen, sx, sy, sw, sh; /* screen geometry */
extern int wax, way, wah, waw; /* windowarea geometry */
extern unsigned int bh, blw; /* bar height, bar layout label width */
extern unsigned int master, nmaster; /* master percent, number of master clients */
extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
extern void (*handler[LASTEvent])(XEvent *); /* event handler */
extern Atom wmatom[WMLast], netatom[NetLast];
@ -105,15 +104,14 @@ extern Window root, barwin;
/* client.c */
extern void configure(Client *c); /* send synthetic configure event */
extern void focus(Client *c); /* focus c, c may be NULL */
extern void killclient(Arg *arg); /* kill c nicely */
extern void killclient(Arg arg); /* kill c nicely */
extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
extern void resize(Client *c, int x, int y,
int w, int h, Bool sizehints); /* resize with given coordinates c*/
extern void toggleversatile(Arg *arg); /* toggles focused client between versatile/and non-versatile state */
extern void toggleversatile(Arg arg); /* toggles focused client between versatile/and non-versatile state */
extern void updatesizehints(Client *c); /* update the size hint variables of c */
extern void updatetitle(Client *c); /* update the name of c */
extern void unmanage(Client *c); /* destroy c */
extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */
/* draw.c */
extern void drawstatus(void); /* draw the bar */
@ -125,18 +123,19 @@ extern unsigned int textw(const char *text); /* return the width of text in px*/
extern void grabkeys(void); /* grab all keys defined in config.h */
/* layout.c */
extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
extern void incnmaster(Arg *arg); /* increments nmaster with arg's index value */
extern void focusnext(Arg arg); /* focuses next visible client, arg is ignored */
extern void focusprev(Arg arg); /* focuses previous visible client, arg is ignored */
extern void incmasterw(Arg arg); /* increments the master width with arg's index value */
extern void incnmaster(Arg arg); /* increments nmaster with arg's index value */
extern void initlayouts(void); /* initialize layout array */
extern Client *nexttiled(Client *c); /* returns tiled successor of c */
extern void resizemaster(Arg *arg); /* resizes the master percent with arg's index value */
extern void restack(void); /* restores z layers of all clients */
extern void setlayout(Arg *arg); /* sets layout, -1 toggles */
extern void setlayout(Arg arg); /* sets layout, -1 toggles */
extern void togglemax(Arg arg); /* toggles maximization of versatile client */
extern void versatile(void); /* arranges all windows versatile */
/* main.c */
extern void quit(Arg *arg); /* quit dwm nicely */
extern void quit(Arg arg); /* quit dwm nicely */
extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
@ -144,13 +143,14 @@ extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
extern void compileregs(void); /* initialize regexps of rules defined in config.h */
extern Bool isvisible(Client *c); /* returns True if client is visible */
extern void settags(Client *c, Client *trans); /* sets tags of c */
extern void tag(Arg *arg); /* tags c with arg's index */
extern void toggletag(Arg *arg); /* toggles c tags with arg's index */
extern void toggleview(Arg *arg); /* toggles the tag with arg's index (in)visible */
extern void view(Arg *arg); /* views the tag with arg's index */
extern void tag(Arg arg); /* tags c with arg's index */
extern void toggletag(Arg arg); /* toggles c tags with arg's index */
extern void toggleview(Arg arg); /* toggles the tag with arg's index (in)visible */
extern void view(Arg arg); /* views the tag with arg's index */
extern void zoom(Arg arg); /* zooms the focused client to master area, arg is ignored */
/* util.c */
extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */
extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
extern void spawn(Arg *arg); /* forks a new subprocess with arg's cmd */
extern void spawn(Arg arg); /* forks a new subprocess with arg's cmd */

20
event.c
View file

@ -11,7 +11,7 @@
typedef struct {
unsigned long mod;
KeySym keysym;
void (*func)(Arg *arg);
void (*func)(Arg arg);
Arg arg;
} Key;
@ -124,15 +124,15 @@ buttonpress(XEvent *e) {
if(ev->x < x) {
if(ev->button == Button1) {
if(ev->state & MODKEY)
tag(&a);
tag(a);
else
view(&a);
view(a);
}
else if(ev->button == Button3) {
if(ev->state & MODKEY)
toggletag(&a);
toggletag(a);
else
toggleview(&a);
toggleview(a);
}
return;
}
@ -141,15 +141,15 @@ buttonpress(XEvent *e) {
switch(ev->button) {
case Button1:
a.i = -1;
setlayout(&a);
setlayout(a);
break;
case Button4:
a.i = 1;
incnmaster(&a);
incnmaster(a);
break;
case Button5:
a.i = -1;
incnmaster(&a);
incnmaster(a);
break;
}
}
@ -162,7 +162,7 @@ buttonpress(XEvent *e) {
movemouse(c);
}
else if(ev->button == Button2)
zoom(NULL);
zoom(a);
else if(ev->button == Button3
&& (lt->arrange == versatile || c->isversatile) && !c->isfixed)
{
@ -261,7 +261,7 @@ keypress(XEvent *e) {
&& CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
{
if(key[i].func)
key[i].func(&key[i].arg);
key[i].func(key[i].arg);
}
}

View file

@ -3,14 +3,14 @@
*/
#include "dwm.h"
unsigned int master = MASTER;
unsigned int nmaster = NMASTER;
unsigned int blw = 0;
Layout *lt = NULL;
/* static */
static unsigned int nlayouts = 0;
static unsigned int masterw = MASTERWIDTH;
static unsigned int nmaster = NMASTER;
static void
tile(void) {
@ -21,7 +21,7 @@ tile(void) {
n++;
/* window geoms */
mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
mw = (n > nmaster) ? (waw * master) / 1000 : waw;
mw = (n > nmaster) ? (waw * masterw) / 1000 : waw;
th = (n > nmaster) ? wah / (n - nmaster) : 0;
tw = waw - mw;
@ -69,7 +69,7 @@ LAYOUTS
/* extern */
void
focusnext(Arg *arg) {
focusnext(Arg arg) {
Client *c;
if(!sel)
@ -84,7 +84,7 @@ focusnext(Arg *arg) {
}
void
focusprev(Arg *arg) {
focusprev(Arg arg) {
Client *c;
if(!sel)
@ -101,11 +101,26 @@ focusprev(Arg *arg) {
}
void
incnmaster(Arg *arg) {
if((lt->arrange != tile) || (nmaster + arg->i < 1)
|| (wah / (nmaster + arg->i) <= 2 * BORDERPX))
incmasterw(Arg arg) {
if(lt->arrange != tile)
return;
nmaster += arg->i;
if(arg.i == 0)
masterw = MASTERWIDTH;
else {
if(waw * (masterw + arg.i) / 1000 >= waw - 2 * BORDERPX
|| waw * (masterw + arg.i) / 1000 <= 2 * BORDERPX)
return;
masterw += arg.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;
if(sel)
lt->arrange();
else
@ -131,21 +146,6 @@ nexttiled(Client *c) {
return c;
}
void
resizemaster(Arg *arg) {
if(lt->arrange != tile)
return;
if(arg->i == 0)
master = MASTER;
else {
if(waw * (master + arg->i) / 1000 >= waw - 2 * BORDERPX
|| waw * (master + arg->i) / 1000 <= 2 * BORDERPX)
return;
master += arg->i;
}
lt->arrange();
}
void
restack(void) {
Client *c;
@ -170,10 +170,10 @@ restack(void) {
}
void
setlayout(Arg *arg) {
setlayout(Arg arg) {
unsigned int i;
if(arg->i == -1) {
if(arg.i == -1) {
for(i = 0; i < nlayouts && lt != &layout[i]; i++);
if(i == nlayouts - 1)
lt = &layout[0];
@ -181,9 +181,9 @@ setlayout(Arg *arg) {
lt = &layout[++i];
}
else {
if(arg->i < 0 || arg->i >= nlayouts)
if(arg.i < 0 || arg.i >= nlayouts)
return;
lt = &layout[arg->i];
lt = &layout[arg.i];
}
if(sel)
lt->arrange();
@ -191,6 +191,24 @@ setlayout(Arg *arg) {
drawstatus();
}
void
togglemax(Arg arg) {
XEvent ev;
if(!sel || !sel->isversatile || sel->isfixed || lt->arrange != versatile)
return;
if((sel->ismax = !sel->ismax)) {
sel->rx = sel->x;
sel->ry = sel->y;
sel->rw = sel->w;
sel->rh = sel->h;
resize(sel, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
}
else
resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}
void
versatile(void) {
Client *c;
@ -213,3 +231,21 @@ versatile(void) {
}
restack();
}
void
zoom(Arg arg) {
unsigned int n;
Client *c;
if(!sel || lt->arrange != tile || sel->isversatile)
return;
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
n++;
if((c = sel) == nexttiled(clients))
if(!(c = nexttiled(c->next)))
return;
detach(c);
attach(c);
focus(c);
lt->arrange();
}

2
main.c
View file

@ -236,7 +236,7 @@ sendevent(Window w, Atom a, long value) {
}
void
quit(Arg *arg) {
quit(Arg arg) {
readin = running = False;
}

28
tag.c
View file

@ -102,49 +102,49 @@ settags(Client *c, Client *trans) {
}
void
tag(Arg *arg) {
tag(Arg arg) {
unsigned int i;
if(!sel)
return;
for(i = 0; i < ntags; i++)
sel->tags[i] = (arg->i == -1) ? True : False;
if(arg->i >= 0 && arg->i < ntags)
sel->tags[arg->i] = True;
sel->tags[i] = (arg.i == -1) ? True : False;
if(arg.i >= 0 && arg.i < ntags)
sel->tags[arg.i] = True;
lt->arrange();
}
void
toggletag(Arg *arg) {
toggletag(Arg arg) {
unsigned int i;
if(!sel)
return;
sel->tags[arg->i] = !sel->tags[arg->i];
sel->tags[arg.i] = !sel->tags[arg.i];
for(i = 0; i < ntags && !sel->tags[i]; i++);
if(i == ntags)
sel->tags[arg->i] = True;
sel->tags[arg.i] = True;
lt->arrange();
}
void
toggleview(Arg *arg) {
toggleview(Arg arg) {
unsigned int i;
seltag[arg->i] = !seltag[arg->i];
seltag[arg.i] = !seltag[arg.i];
for(i = 0; i < ntags && !seltag[i]; i++);
if(i == ntags)
seltag[arg->i] = True; /* cannot toggle last view */
seltag[arg.i] = True; /* cannot toggle last view */
lt->arrange();
}
void
view(Arg *arg) {
view(Arg arg) {
unsigned int i;
for(i = 0; i < ntags; i++)
seltag[i] = (arg->i == -1) ? True : False;
if(arg->i >= 0 && arg->i < ntags)
seltag[arg->i] = True;
seltag[i] = (arg.i == -1) ? True : False;
if(arg.i >= 0 && arg.i < ntags)
seltag[arg.i] = True;
lt->arrange();
}

8
util.c
View file

@ -30,12 +30,12 @@ eprint(const char *errstr, ...) {
}
void
spawn(Arg *arg) {
spawn(Arg arg) {
static char *shell = NULL;
if(!shell && !(shell = getenv("SHELL")))
shell = "/bin/sh";
if(!arg->cmd)
if(!arg.cmd)
return;
/* The double-fork construct avoids zombie processes and keeps the code
* clean from stupid signal handlers. */
@ -44,8 +44,8 @@ spawn(Arg *arg) {
if(dpy)
close(ConnectionNumber(dpy));
setsid();
execl(shell, shell, "-c", arg->cmd, (char *)NULL);
fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg->cmd);
execl(shell, shell, "-c", arg.cmd, (char *)NULL);
fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg.cmd);
perror(" failed");
}
exit(0);