Browse Source

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

config
Anselm R. Garbe 18 years ago
parent
commit
352cae4380
10 changed files with 184 additions and 183 deletions
  1. +2
    -42
      client.c
  2. +34
    -33
      config.arg.h
  3. +31
    -30
      config.default.h
  4. +9
    -6
      dwm.1
  5. +15
    -15
      dwm.h
  6. +10
    -10
      event.c
  7. +64
    -28
      layout.c
  8. +1
    -1
      main.c
  9. +14
    -14
      tag.c
  10. +4
    -4
      util.c

+ 2
- 42
client.c View File

@ -83,24 +83,6 @@ setclientstate(Client *c, long state) {
PropModeReplace, (unsigned char *)data, 2); 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 static int
xerrordummy(Display *dsply, XErrorEvent *ee) { xerrordummy(Display *dsply, XErrorEvent *ee) {
return 0; return 0;
@ -171,7 +153,7 @@ focus(Client *c) {
} }
void void
killclient(Arg *arg) {
killclient(Arg arg) {
if(!sel) if(!sel)
return; return;
if(isprotodel(sel)) if(isprotodel(sel))
@ -303,7 +285,7 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
} }
void void
toggleversatile(Arg *arg) {
toggleversatile(Arg arg) {
if(!sel || lt->arrange == versatile) if(!sel || lt->arrange == versatile)
return; return;
sel->isversatile = !sel->isversatile; sel->isversatile = !sel->isversatile;
@ -402,25 +384,3 @@ unmanage(Client *c) {
XUngrabServer(dpy); XUngrabServer(dpy);
lt->arrange(); 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();
}

+ 34
- 33
config.arg.h View File

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

+ 31
- 30
config.default.h View File

@ -14,7 +14,6 @@
#define TOPBAR True /* False */ #define TOPBAR True /* False */
/* behavior */ /* behavior */
#define SNAP 20 /* pixel */
#define TAGS \ #define TAGS \
const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL }; const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
/* Query class:instance:title for regex matching info with following command: /* Query class:instance:title for regex matching info with following command:
@ -34,22 +33,36 @@ static Layout layout[] = { \
{ "[]=", tile }, /* first entry is default */ \ { "[]=", tile }, /* first entry is default */ \
{ "><>", versatile }, \ { "><>", versatile }, \
}; };
#define MASTER 600 /* per thousand */
#define MASTERWIDTH 600 /* master width per thousand */
#define NMASTER 1 /* clients in master area */ #define NMASTER 1 /* clients in master area */
#define SNAP 20 /* versatile snap pixel */
/* key definitions */ /* key definitions */
#define MODKEY Mod1Mask #define MODKEY Mod1Mask
#define KEYS \ #define KEYS \
static Key key[] = { \ static Key key[] = { \
/* modifier key function argument */ \ /* 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_Return, zoom, { 0 } }, \
{ MODKEY, XK_g, resizemaster, { .i = 15 } }, \
{ MODKEY, XK_s, resizemaster, { .i = -15 } }, \
{ MODKEY, XK_i, incnmaster, { .i = 1 } }, \
{ MODKEY, XK_space, setlayout, { .i = -1 } }, \
{ MODKEY, XK_0, view, { .i = -1 } }, \
{ MODKEY, XK_1, view, { .i = 0 } }, \
{ MODKEY, XK_2, view, { .i = 1 } }, \
{ MODKEY, XK_3, view, { .i = 2 } }, \
{ MODKEY, XK_4, view, { .i = 3 } }, \
{ MODKEY, XK_5, view, { .i = 4 } }, \
{ MODKEY, XK_6, view, { .i = 5 } }, \
{ 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_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_0, tag, { .i = -1 } }, \
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \ { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \ { MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
@ -60,28 +73,8 @@ static Key key[] = { \
{ MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \ { MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \
{ MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \ { MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \
{ MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \ { 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|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 } }, \
{ MODKEY, XK_3, view, { .i = 2 } }, \
{ MODKEY, XK_4, view, { .i = 3 } }, \
{ MODKEY, XK_5, view, { .i = 4 } }, \
{ MODKEY, XK_6, view, { .i = 5 } }, \
{ MODKEY, XK_7, view, { .i = 6 } }, \
{ MODKEY, XK_8, view, { .i = 7 } }, \
{ MODKEY, XK_9, view, { .i = 8 } }, \
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
{ MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \ { MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \
{ MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \ { MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \
{ MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \ { MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \
@ -91,5 +84,13 @@ static Key key[] = { \
{ MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \ { MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \
{ MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \ { MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \
{ MODKEY|ControlMask, XK_9, toggleview, { .i = 8 } }, \ { 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 } }, \
}; };

+ 9
- 6
dwm.1 View File

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


+ 15
- 15
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 screen, sx, sy, sw, sh; /* screen geometry */
extern int wax, way, wah, waw; /* windowarea geometry */ extern int wax, way, wah, waw; /* windowarea geometry */
extern unsigned int bh, blw; /* bar height, bar layout label width */ 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 unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
extern void (*handler[LASTEvent])(XEvent *); /* event handler */ extern void (*handler[LASTEvent])(XEvent *); /* event handler */
extern Atom wmatom[WMLast], netatom[NetLast]; extern Atom wmatom[WMLast], netatom[NetLast];
@ -105,15 +104,14 @@ extern Window root, barwin;
/* client.c */ /* client.c */
extern void configure(Client *c); /* send synthetic configure event */ extern void configure(Client *c); /* send synthetic configure event */
extern void focus(Client *c); /* focus c, c may be NULL */ 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 manage(Window w, XWindowAttributes *wa); /* manage new client */
extern void resize(Client *c, int x, int y, extern void resize(Client *c, int x, int y,
int w, int h, Bool sizehints); /* resize with given coordinates c*/ 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 updatesizehints(Client *c); /* update the size hint variables of c */
extern void updatetitle(Client *c); /* update the name of c */ extern void updatetitle(Client *c); /* update the name of c */
extern void unmanage(Client *c); /* destroy 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 */ /* draw.c */
extern void drawstatus(void); /* draw the bar */ 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 */ extern void grabkeys(void); /* grab all keys defined in config.h */
/* layout.c */ /* 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 void initlayouts(void); /* initialize layout array */
extern Client *nexttiled(Client *c); /* returns tiled successor of c */ 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 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 */ extern void versatile(void); /* arranges all windows versatile */
/* main.c */ /* 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 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 */ 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 void compileregs(void); /* initialize regexps of rules defined in config.h */
extern Bool isvisible(Client *c); /* returns True if client is visible */ extern Bool isvisible(Client *c); /* returns True if client is visible */
extern void settags(Client *c, Client *trans); /* sets tags of c */ 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 */ /* util.c */
extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */ 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 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 */

+ 10
- 10
event.c View File

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


+ 64
- 28
layout.c View File

@ -3,14 +3,14 @@
*/ */
#include "dwm.h" #include "dwm.h"
unsigned int master = MASTER;
unsigned int nmaster = NMASTER;
unsigned int blw = 0; unsigned int blw = 0;
Layout *lt = NULL; Layout *lt = NULL;
/* static */ /* static */
static unsigned int nlayouts = 0; static unsigned int nlayouts = 0;
static unsigned int masterw = MASTERWIDTH;
static unsigned int nmaster = NMASTER;
static void static void
tile(void) { tile(void) {
@ -21,7 +21,7 @@ tile(void) {
n++; n++;
/* window geoms */ /* window geoms */
mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1); 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; th = (n > nmaster) ? wah / (n - nmaster) : 0;
tw = waw - mw; tw = waw - mw;
@ -69,7 +69,7 @@ LAYOUTS
/* extern */ /* extern */
void void
focusnext(Arg *arg) {
focusnext(Arg arg) {
Client *c; Client *c;
if(!sel) if(!sel)
@ -84,7 +84,7 @@ focusnext(Arg *arg) {
} }
void void
focusprev(Arg *arg) {
focusprev(Arg arg) {
Client *c; Client *c;
if(!sel) if(!sel)
@ -101,11 +101,26 @@ focusprev(Arg *arg) {
} }
void 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;
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; return;
nmaster += arg->i;
nmaster += arg.i;
if(sel) if(sel)
lt->arrange(); lt->arrange();
else else
@ -131,21 +146,6 @@ nexttiled(Client *c) {
return 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 void
restack(void) { restack(void) {
Client *c; Client *c;
@ -170,10 +170,10 @@ restack(void) {
} }
void void
setlayout(Arg *arg) {
setlayout(Arg arg) {
unsigned int i; unsigned int i;
if(arg->i == -1) {
if(arg.i == -1) {
for(i = 0; i < nlayouts && lt != &layout[i]; i++); for(i = 0; i < nlayouts && lt != &layout[i]; i++);
if(i == nlayouts - 1) if(i == nlayouts - 1)
lt = &layout[0]; lt = &layout[0];
@ -181,9 +181,9 @@ setlayout(Arg *arg) {
lt = &layout[++i]; lt = &layout[++i];
} }
else { else {
if(arg->i < 0 || arg->i >= nlayouts)
if(arg.i < 0 || arg.i >= nlayouts)
return; return;
lt = &layout[arg->i];
lt = &layout[arg.i];
} }
if(sel) if(sel)
lt->arrange(); lt->arrange();
@ -191,6 +191,24 @@ setlayout(Arg *arg) {
drawstatus(); 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 void
versatile(void) { versatile(void) {
Client *c; Client *c;
@ -213,3 +231,21 @@ versatile(void) {
} }
restack(); 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();
}

+ 1
- 1
main.c View File

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


+ 14
- 14
tag.c View File

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

+ 4
- 4
util.c View File

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


Loading…
Cancel
Save