diff options
| -rw-r--r-- | draw.c | 4 | ||||
| -rw-r--r-- | dwm.h | 38 | ||||
| -rw-r--r-- | dwm.html | 7 | ||||
| -rw-r--r-- | event.c | 35 | ||||
| -rw-r--r-- | main.c | 38 | ||||
| -rw-r--r-- | tag.c | 21 | ||||
| -rw-r--r-- | util.c | 4 |
7 files changed, 70 insertions, 77 deletions
| @@ -8,7 +8,7 @@ | |||
| 8 | #include <string.h> | 8 | #include <string.h> |
| 9 | #include <X11/Xlocale.h> | 9 | #include <X11/Xlocale.h> |
| 10 | 10 | ||
| 11 | /* static functions */ | 11 | /* static */ |
| 12 | 12 | ||
| 13 | static void | 13 | static void |
| 14 | drawborder(void) | 14 | drawborder(void) |
| @@ -90,7 +90,7 @@ drawtext(const char *text, Bool invert, Bool border) | |||
| 90 | } | 90 | } |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | /* extern functions */ | 93 | /* extern */ |
| 94 | 94 | ||
| 95 | void | 95 | void |
| 96 | drawall() | 96 | drawall() |
| @@ -37,28 +37,28 @@ union Arg { | |||
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | /* atoms */ | 39 | /* atoms */ |
| 40 | enum { WMProtocols, WMDelete, WMLast }; | ||
| 41 | enum { NetSupported, NetWMName, NetLast }; | 40 | enum { NetSupported, NetWMName, NetLast }; |
| 41 | enum { WMProtocols, WMDelete, WMLast }; | ||
| 42 | 42 | ||
| 43 | /* cursor */ | 43 | /* cursor */ |
| 44 | enum { CurNormal, CurResize, CurMove, CurInput, CurLast }; | 44 | enum { CurNormal, CurResize, CurMove, CurLast }; |
| 45 | 45 | ||
| 46 | struct Fnt { | 46 | struct Fnt { |
| 47 | XFontStruct *xfont; | ||
| 48 | XFontSet set; | ||
| 49 | int ascent; | 47 | int ascent; |
| 50 | int descent; | 48 | int descent; |
| 51 | int height; | 49 | int height; |
| 50 | XFontSet set; | ||
| 51 | XFontStruct *xfont; | ||
| 52 | }; | 52 | }; |
| 53 | 53 | ||
| 54 | struct DC { /* draw context */ | 54 | struct DC { /* draw context */ |
| 55 | GC gc; | ||
| 56 | Drawable drawable; | ||
| 57 | int x, y, w, h; | 55 | int x, y, w, h; |
| 58 | Fnt font; | ||
| 59 | unsigned long bg; | 56 | unsigned long bg; |
| 60 | unsigned long fg; | 57 | unsigned long fg; |
| 61 | unsigned long border; | 58 | unsigned long border; |
| 59 | Drawable drawable; | ||
| 60 | Fnt font; | ||
| 61 | GC gc; | ||
| 62 | }; | 62 | }; |
| 63 | 63 | ||
| 64 | struct Client { | 64 | struct Client { |
| @@ -72,10 +72,10 @@ struct Client { | |||
| 72 | unsigned int border; | 72 | unsigned int border; |
| 73 | long flags; | 73 | long flags; |
| 74 | Bool isfloat; | 74 | Bool isfloat; |
| 75 | Window win; | ||
| 76 | Window title; | ||
| 77 | Client *next; | 75 | Client *next; |
| 78 | Client *revert; | 76 | Client *revert; |
| 77 | Window win; | ||
| 78 | Window title; | ||
| 79 | }; | 79 | }; |
| 80 | 80 | ||
| 81 | struct Rule { | 81 | struct Rule { |
| @@ -92,20 +92,18 @@ struct Key { | |||
| 92 | Arg arg; | 92 | Arg arg; |
| 93 | }; | 93 | }; |
| 94 | 94 | ||
| 95 | extern Display *dpy; | 95 | extern char *tags[TLast], stext[1024]; |
| 96 | extern Window root, barwin; | 96 | extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw; |
| 97 | extern Atom wmatom[WMLast], netatom[NetLast]; | ||
| 98 | extern Cursor cursor[CurLast]; | ||
| 99 | extern Bool running, issel; | ||
| 100 | extern void (*handler[LASTEvent])(XEvent *); | 97 | extern void (*handler[LASTEvent])(XEvent *); |
| 101 | extern void (*arrange)(Arg *); | 98 | extern void (*arrange)(Arg *); |
| 102 | extern Key key[]; | 99 | extern Atom wmatom[WMLast], netatom[NetLast]; |
| 103 | 100 | extern Bool running, issel; | |
| 104 | extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw; | ||
| 105 | extern char *tags[TLast], stext[1024]; | ||
| 106 | |||
| 107 | extern DC dc; | ||
| 108 | extern Client *clients, *sel; | 101 | extern Client *clients, *sel; |
| 102 | extern Cursor cursor[CurLast]; | ||
| 103 | extern DC dc; | ||
| 104 | extern Display *dpy; | ||
| 105 | extern Key key[]; | ||
| 106 | extern Window root, barwin; | ||
| 109 | 107 | ||
| 110 | /* client.c */ | 108 | /* client.c */ |
| 111 | extern void ban(Client *c); | 109 | extern void ban(Client *c); |
| @@ -39,10 +39,9 @@ | |||
| 39 | </p> | 39 | </p> |
| 40 | <ul> | 40 | <ul> |
| 41 | <li> | 41 | <li> |
| 42 | dwm has no 9P support, no menu, no editable tagbars, | 42 | dwm has no 9P support, no editable tagbars, no shell-based |
| 43 | no shell-based configuration and remote control and comes without | 43 | configuration and remote control and comes without any additional |
| 44 | any additional tools like printing the selection or warping the | 44 | tools like printing the selection or warping the mouse. |
| 45 | mouse. | ||
| 46 | </li> | 45 | </li> |
| 47 | <li> | 46 | <li> |
| 48 | dwm is only a single binary, it's source code is intended to never | 47 | dwm is only a single binary, it's source code is intended to never |
| @@ -11,45 +11,44 @@ | |||
| 11 | #define ButtonMask (ButtonPressMask | ButtonReleaseMask) | 11 | #define ButtonMask (ButtonPressMask | ButtonReleaseMask) |
| 12 | #define MouseMask (ButtonMask | PointerMotionMask) | 12 | #define MouseMask (ButtonMask | PointerMotionMask) |
| 13 | 13 | ||
| 14 | /********** CUSTOMIZE **********/ | 14 | /* CUSTOMIZE */ |
| 15 | 15 | const char *browse[] = { "firefox", NULL }; | |
| 16 | const char *gimp[] = { "gimp", NULL }; | ||
| 16 | const char *term[] = { | 17 | const char *term[] = { |
| 17 | "urxvtc", "-tr", "+sb", "-bg", "black", "-fg", "white", "-cr", "white", | 18 | "urxvtc", "-tr", "+sb", "-bg", "black", "-fg", "white", "-cr", "white", |
| 18 | "-fn", "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", NULL | 19 | "-fn", "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", NULL |
| 19 | }; | 20 | }; |
| 20 | const char *browse[] = { "firefox", NULL }; | ||
| 21 | const char *xlock[] = { "xlock", NULL }; | 21 | const char *xlock[] = { "xlock", NULL }; |
| 22 | 22 | ||
| 23 | Key key[] = { | 23 | Key key[] = { |
| 24 | /* modifier key function arguments */ | 24 | /* modifier key function arguments */ |
| 25 | { Mod1Mask, XK_Return, zoom, { 0 } }, | 25 | { ControlMask, XK_0, appendtag, { .i = Tscratch } }, |
| 26 | { Mod1Mask, XK_k, focusprev, { 0 } }, | 26 | { ControlMask, XK_1, appendtag, { .i = Tdev } }, |
| 27 | { Mod1Mask, XK_j, focusnext, { 0 } }, | 27 | { ControlMask, XK_2, appendtag, { .i = Twww } }, |
| 28 | { Mod1Mask, XK_m, maximize, { 0 } }, | 28 | { ControlMask, XK_3, appendtag, { .i = Twork } }, |
| 29 | { Mod1Mask, XK_0, view, { .i = Tscratch } }, | 29 | { Mod1Mask, XK_0, view, { .i = Tscratch } }, |
| 30 | { Mod1Mask, XK_1, view, { .i = Tdev } }, | 30 | { Mod1Mask, XK_1, view, { .i = Tdev } }, |
| 31 | { Mod1Mask, XK_2, view, { .i = Twww } }, | 31 | { Mod1Mask, XK_2, view, { .i = Twww } }, |
| 32 | { Mod1Mask, XK_3, view, { .i = Twork } }, | 32 | { Mod1Mask, XK_3, view, { .i = Twork } }, |
| 33 | { Mod1Mask, XK_j, focusnext, { 0 } }, | ||
| 34 | { Mod1Mask, XK_k, focusprev, { 0 } }, | ||
| 35 | { Mod1Mask, XK_m, maximize, { 0 } }, | ||
| 33 | { Mod1Mask, XK_space, dotile, { 0 } }, | 36 | { Mod1Mask, XK_space, dotile, { 0 } }, |
| 34 | { Mod1Mask|ShiftMask, XK_space, dofloat, { 0 } }, | 37 | { Mod1Mask, XK_Return, zoom, { 0 } }, |
| 35 | { Mod1Mask|ShiftMask, XK_0, replacetag, { .i = Tscratch } }, | 38 | { Mod1Mask|ShiftMask, XK_0, replacetag, { .i = Tscratch } }, |
| 36 | { Mod1Mask|ShiftMask, XK_1, replacetag, { .i = Tdev } }, | 39 | { Mod1Mask|ShiftMask, XK_1, replacetag, { .i = Tdev } }, |
| 37 | { Mod1Mask|ShiftMask, XK_2, replacetag, { .i = Twww } }, | 40 | { Mod1Mask|ShiftMask, XK_2, replacetag, { .i = Twww } }, |
| 38 | { Mod1Mask|ShiftMask, XK_3, replacetag, { .i = Twork } }, | 41 | { Mod1Mask|ShiftMask, XK_3, replacetag, { .i = Twork } }, |
| 39 | { Mod1Mask|ShiftMask, XK_c, killclient, { 0 } }, | 42 | { Mod1Mask|ShiftMask, XK_c, killclient, { 0 } }, |
| 43 | { Mod1Mask|ShiftMask, XK_g, spawn, { .argv = gimp } }, | ||
| 44 | { Mod1Mask|ShiftMask, XK_l, spawn, { .argv = xlock } }, | ||
| 40 | { Mod1Mask|ShiftMask, XK_q, quit, { 0 } }, | 45 | { Mod1Mask|ShiftMask, XK_q, quit, { 0 } }, |
| 41 | { Mod1Mask|ShiftMask, XK_Return, spawn, { .argv = term } }, | 46 | { Mod1Mask|ShiftMask, XK_space, dofloat, { 0 } }, |
| 42 | { Mod1Mask|ShiftMask, XK_w, spawn, { .argv = browse } }, | 47 | { Mod1Mask|ShiftMask, XK_w, spawn, { .argv = browse } }, |
| 43 | { Mod1Mask|ShiftMask, XK_l, spawn, { .argv = xlock } }, | 48 | { Mod1Mask|ShiftMask, XK_Return, spawn, { .argv = term } }, |
| 44 | { ControlMask, XK_0, appendtag, { .i = Tscratch } }, | ||
| 45 | { ControlMask, XK_1, appendtag, { .i = Tdev } }, | ||
| 46 | { ControlMask, XK_2, appendtag, { .i = Twww } }, | ||
| 47 | { ControlMask, XK_3, appendtag, { .i = Twork } }, | ||
| 48 | }; | 49 | }; |
| 49 | 50 | ||
| 50 | /********** CUSTOMIZE **********/ | 51 | /* static */ |
| 51 | |||
| 52 | /* static functions */ | ||
| 53 | 52 | ||
| 54 | static void | 53 | static void |
| 55 | movemouse(Client *c) | 54 | movemouse(Client *c) |
| @@ -337,7 +336,7 @@ unmapnotify(XEvent *e) | |||
| 337 | unmanage(c); | 336 | unmanage(c); |
| 338 | } | 337 | } |
| 339 | 338 | ||
| 340 | /* extern functions */ | 339 | /* extern */ |
| 341 | 340 | ||
| 342 | void (*handler[LASTEvent]) (XEvent *) = { | 341 | void (*handler[LASTEvent]) (XEvent *) = { |
| 343 | [ButtonPress] = buttonpress, | 342 | [ButtonPress] = buttonpress, |
| @@ -14,26 +14,12 @@ | |||
| 14 | #include <X11/Xatom.h> | 14 | #include <X11/Xatom.h> |
| 15 | #include <X11/Xproto.h> | 15 | #include <X11/Xproto.h> |
| 16 | 16 | ||
| 17 | Display *dpy; | ||
| 18 | Window root, barwin; | ||
| 19 | Atom wmatom[WMLast], netatom[NetLast]; | ||
| 20 | Cursor cursor[CurLast]; | ||
| 21 | Bool running = True; | ||
| 22 | Bool issel = True; | ||
| 23 | |||
| 24 | int tsel = Tdev; /* default tag */ | ||
| 25 | int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; | ||
| 26 | char stext[1024]; | ||
| 27 | 17 | ||
| 28 | DC dc = {0}; | 18 | /* static */ |
| 29 | Client *clients = NULL; | ||
| 30 | Client *sel = NULL; | ||
| 31 | 19 | ||
| 32 | static Bool otherwm; | 20 | static Bool otherwm; |
| 33 | static int (*xerrorxlib)(Display *, XErrorEvent *); | 21 | static int (*xerrorxlib)(Display *, XErrorEvent *); |
| 34 | 22 | ||
| 35 | /* static functions */ | ||
| 36 | |||
| 37 | static void | 23 | static void |
| 38 | cleanup() | 24 | cleanup() |
| 39 | { | 25 | { |
| @@ -97,7 +83,20 @@ xerrorstart(Display *dsply, XErrorEvent *ee) | |||
| 97 | return -1; | 83 | return -1; |
| 98 | } | 84 | } |
| 99 | 85 | ||
| 100 | /* extern functions */ | 86 | /* extern */ |
| 87 | |||
| 88 | char stext[1024]; | ||
| 89 | int tsel = Tdev; /* default tag */ | ||
| 90 | int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; | ||
| 91 | Atom wmatom[WMLast], netatom[NetLast]; | ||
| 92 | Bool running = True; | ||
| 93 | Bool issel = True; | ||
| 94 | Client *clients = NULL; | ||
| 95 | Client *sel = NULL; | ||
| 96 | Cursor cursor[CurLast]; | ||
| 97 | Display *dpy; | ||
| 98 | DC dc = {0}; | ||
| 99 | Window root, barwin; | ||
| 101 | 100 | ||
| 102 | int | 101 | int |
| 103 | getproto(Window w) | 102 | getproto(Window w) |
| @@ -141,10 +140,9 @@ quit(Arg *arg) | |||
| 141 | } | 140 | } |
| 142 | 141 | ||
| 143 | /* | 142 | /* |
| 144 | * There's no way to check accesses to destroyed windows, thus | 143 | * There's no way to check accesses to destroyed windows, thus those cases are |
| 145 | * those cases are ignored (especially on UnmapNotify's). | 144 | * ignored (especially on UnmapNotify's). Other types of errors call Xlibs |
| 146 | * Other types of errors call Xlib's default error handler, which | 145 | * default error handler, which calls exit(). |
| 147 | * calls exit(). | ||
| 148 | */ | 146 | */ |
| 149 | int | 147 | int |
| 150 | xerror(Display *dpy, XErrorEvent *ee) | 148 | xerror(Display *dpy, XErrorEvent *ee) |
| @@ -7,24 +7,23 @@ | |||
| 7 | #include <string.h> | 7 | #include <string.h> |
| 8 | #include <X11/Xutil.h> | 8 | #include <X11/Xutil.h> |
| 9 | 9 | ||
| 10 | /********** CUSTOMIZE **********/ | 10 | /* static */ |
| 11 | |||
| 12 | char *tags[TLast] = { | ||
| 13 | [Tscratch] = "scratch", | ||
| 14 | [Tdev] = "dev", | ||
| 15 | [Twww] = "www", | ||
| 16 | [Twork] = "work", | ||
| 17 | }; | ||
| 18 | 11 | ||
| 12 | /* CUSTOMIZE */ | ||
| 19 | static Rule rule[] = { | 13 | static Rule rule[] = { |
| 20 | /* class instance tags isfloat */ | 14 | /* class instance tags isfloat */ |
| 21 | { "Firefox-bin", "Gecko", { [Twww] = "www" }, False }, | 15 | { "Firefox-bin", "Gecko", { [Twww] = "www" }, False }, |
| 22 | }; | 16 | }; |
| 23 | 17 | ||
| 24 | /********** CUSTOMIZE **********/ | 18 | /* extern */ |
| 25 | |||
| 26 | /* extern functions */ | ||
| 27 | 19 | ||
| 20 | /* CUSTOMIZE */ | ||
| 21 | char *tags[TLast] = { | ||
| 22 | [Tscratch] = "scratch", | ||
| 23 | [Tdev] = "dev", | ||
| 24 | [Twww] = "www", | ||
| 25 | [Twork] = "work", | ||
| 26 | }; | ||
| 28 | void (*arrange)(Arg *) = dotile; | 27 | void (*arrange)(Arg *) = dotile; |
| 29 | 28 | ||
| 30 | void | 29 | void |
| @@ -10,7 +10,7 @@ | |||
| 10 | #include <sys/wait.h> | 10 | #include <sys/wait.h> |
| 11 | #include <unistd.h> | 11 | #include <unistd.h> |
| 12 | 12 | ||
| 13 | /* static functions */ | 13 | /* static */ |
| 14 | 14 | ||
| 15 | static void | 15 | static void |
| 16 | bad_malloc(unsigned int size) | 16 | bad_malloc(unsigned int size) |
| @@ -20,7 +20,7 @@ bad_malloc(unsigned int size) | |||
| 20 | exit(1); | 20 | exit(1); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | /* extern functions */ | 23 | /* extern */ |
| 24 | 24 | ||
| 25 | void * | 25 | void * |
| 26 | emallocz(unsigned int size) | 26 | emallocz(unsigned int size) |
