diff options
Diffstat (limited to 'dwm.c')
| -rw-r--r-- | dwm.c | 88 |
1 files changed, 42 insertions, 46 deletions
| @@ -63,21 +63,17 @@ enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */ | |||
| 63 | enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, | 63 | enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, |
| 64 | ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ | 64 | ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ |
| 65 | 65 | ||
| 66 | /* typedefs */ | ||
| 67 | typedef unsigned int uint; | ||
| 68 | typedef unsigned long ulong; | ||
| 69 | |||
| 70 | typedef union { | 66 | typedef union { |
| 71 | int i; | 67 | int i; |
| 72 | uint ui; | 68 | unsigned int ui; |
| 73 | float f; | 69 | float f; |
| 74 | void *v; | 70 | void *v; |
| 75 | } Arg; | 71 | } Arg; |
| 76 | 72 | ||
| 77 | typedef struct { | 73 | typedef struct { |
| 78 | uint click; | 74 | unsigned int click; |
| 79 | uint mask; | 75 | unsigned int mask; |
| 80 | uint button; | 76 | unsigned int button; |
| 81 | void (*func)(const Arg *arg); | 77 | void (*func)(const Arg *arg); |
| 82 | const Arg arg; | 78 | const Arg arg; |
| 83 | } Button; | 79 | } Button; |
| @@ -89,7 +85,7 @@ struct Client { | |||
| 89 | int x, y, w, h; | 85 | int x, y, w, h; |
| 90 | int basew, baseh, incw, inch, maxw, maxh, minw, minh; | 86 | int basew, baseh, incw, inch, maxw, maxh, minw, minh; |
| 91 | int bw, oldbw; | 87 | int bw, oldbw; |
| 92 | uint tags; | 88 | unsigned int tags; |
| 93 | Bool isfixed, isfloating, isurgent; | 89 | Bool isfixed, isfloating, isurgent; |
| 94 | Client *next; | 90 | Client *next; |
| 95 | Client *snext; | 91 | Client *snext; |
| @@ -98,8 +94,8 @@ struct Client { | |||
| 98 | 94 | ||
| 99 | typedef struct { | 95 | typedef struct { |
| 100 | int x, y, w, h; | 96 | int x, y, w, h; |
| 101 | ulong norm[ColLast]; | 97 | unsigned long norm[ColLast]; |
| 102 | ulong sel[ColLast]; | 98 | unsigned long sel[ColLast]; |
| 103 | Drawable drawable; | 99 | Drawable drawable; |
| 104 | GC gc; | 100 | GC gc; |
| 105 | struct { | 101 | struct { |
| @@ -112,7 +108,7 @@ typedef struct { | |||
| 112 | } DC; /* draw context */ | 108 | } DC; /* draw context */ |
| 113 | 109 | ||
| 114 | typedef struct { | 110 | typedef struct { |
| 115 | uint mod; | 111 | unsigned int mod; |
| 116 | KeySym keysym; | 112 | KeySym keysym; |
| 117 | void (*func)(const Arg *); | 113 | void (*func)(const Arg *); |
| 118 | const Arg arg; | 114 | const Arg arg; |
| @@ -127,7 +123,7 @@ typedef struct { | |||
| 127 | const char *class; | 123 | const char *class; |
| 128 | const char *instance; | 124 | const char *instance; |
| 129 | const char *title; | 125 | const char *title; |
| 130 | uint tags; | 126 | unsigned int tags; |
| 131 | Bool isfloating; | 127 | Bool isfloating; |
| 132 | } Rule; | 128 | } Rule; |
| 133 | 129 | ||
| @@ -148,23 +144,23 @@ static void detach(Client *c); | |||
| 148 | static void detachstack(Client *c); | 144 | static void detachstack(Client *c); |
| 149 | static void die(const char *errstr, ...); | 145 | static void die(const char *errstr, ...); |
| 150 | static void drawbar(void); | 146 | static void drawbar(void); |
| 151 | static void drawsquare(Bool filled, Bool empty, Bool invert, ulong col[ColLast]); | 147 | static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]); |
| 152 | static void drawtext(const char *text, ulong col[ColLast], Bool invert); | 148 | static void drawtext(const char *text, unsigned long col[ColLast], Bool invert); |
| 153 | static void enternotify(XEvent *e); | 149 | static void enternotify(XEvent *e); |
| 154 | static void expose(XEvent *e); | 150 | static void expose(XEvent *e); |
| 155 | static void focus(Client *c); | 151 | static void focus(Client *c); |
| 156 | static void focusin(XEvent *e); | 152 | static void focusin(XEvent *e); |
| 157 | static void focusstack(const Arg *arg); | 153 | static void focusstack(const Arg *arg); |
| 158 | static Client *getclient(Window w); | 154 | static Client *getclient(Window w); |
| 159 | static ulong getcolor(const char *colstr); | 155 | static unsigned long getcolor(const char *colstr); |
| 160 | static long getstate(Window w); | 156 | static long getstate(Window w); |
| 161 | static Bool gettextprop(Window w, Atom atom, char *text, uint size); | 157 | static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); |
| 162 | static void grabbuttons(Client *c, Bool focused); | 158 | static void grabbuttons(Client *c, Bool focused); |
| 163 | static void grabkeys(void); | 159 | static void grabkeys(void); |
| 164 | static void initfont(const char *fontstr); | 160 | static void initfont(const char *fontstr); |
| 165 | static Bool isoccupied(uint t); | 161 | static Bool isoccupied(unsigned int t); |
| 166 | static Bool isprotodel(Client *c); | 162 | static Bool isprotodel(Client *c); |
| 167 | static Bool isurgent(uint t); | 163 | static Bool isurgent(unsigned int t); |
| 168 | static void keypress(XEvent *e); | 164 | static void keypress(XEvent *e); |
| 169 | static void killclient(const Arg *arg); | 165 | static void killclient(const Arg *arg); |
| 170 | static void manage(Window w, XWindowAttributes *wa); | 166 | static void manage(Window w, XWindowAttributes *wa); |
| @@ -186,7 +182,7 @@ static void setmfact(const Arg *arg); | |||
| 186 | static void setup(void); | 182 | static void setup(void); |
| 187 | static void spawn(const Arg *arg); | 183 | static void spawn(const Arg *arg); |
| 188 | static void tag(const Arg *arg); | 184 | static void tag(const Arg *arg); |
| 189 | static int textnw(const char *text, uint len); | 185 | static int textnw(const char *text, unsigned int len); |
| 190 | static void tile(void); | 186 | static void tile(void); |
| 191 | static void togglebar(const Arg *arg); | 187 | static void togglebar(const Arg *arg); |
| 192 | static void togglefloating(const Arg *arg); | 188 | static void togglefloating(const Arg *arg); |
| @@ -209,9 +205,9 @@ static void zoom(const Arg *arg); | |||
| 209 | static char stext[256]; | 205 | static char stext[256]; |
| 210 | static int screen, sx, sy, sw, sh; | 206 | static int screen, sx, sy, sw, sh; |
| 211 | static int by, bh, blw, wx, wy, ww, wh; | 207 | static int by, bh, blw, wx, wy, ww, wh; |
| 212 | static uint seltags = 0, sellt = 0; | 208 | static unsigned int seltags = 0, sellt = 0; |
| 213 | static int (*xerrorxlib)(Display *, XErrorEvent *); | 209 | static int (*xerrorxlib)(Display *, XErrorEvent *); |
| 214 | static uint numlockmask = 0; | 210 | static unsigned int numlockmask = 0; |
| 215 | static void (*handler[LASTEvent]) (XEvent *) = { | 211 | static void (*handler[LASTEvent]) (XEvent *) = { |
| 216 | [ButtonPress] = buttonpress, | 212 | [ButtonPress] = buttonpress, |
| 217 | [ConfigureRequest] = configurerequest, | 213 | [ConfigureRequest] = configurerequest, |
| @@ -229,7 +225,7 @@ static void (*handler[LASTEvent]) (XEvent *) = { | |||
| 229 | static Atom wmatom[WMLast], netatom[NetLast]; | 225 | static Atom wmatom[WMLast], netatom[NetLast]; |
| 230 | static Bool otherwm, readin; | 226 | static Bool otherwm, readin; |
| 231 | static Bool running = True; | 227 | static Bool running = True; |
| 232 | static uint tagset[] = {1, 1}; /* after start, first tag is selected */ | 228 | static unsigned int tagset[] = {1, 1}; /* after start, first tag is selected */ |
| 233 | static Client *clients = NULL; | 229 | static Client *clients = NULL; |
| 234 | static Client *sel = NULL; | 230 | static Client *sel = NULL; |
| 235 | static Client *stack = NULL; | 231 | static Client *stack = NULL; |
| @@ -241,13 +237,13 @@ static Window root, barwin; | |||
| 241 | /* configuration, allows nested code to access above variables */ | 237 | /* configuration, allows nested code to access above variables */ |
| 242 | #include "config.h" | 238 | #include "config.h" |
| 243 | 239 | ||
| 244 | /* compile-time check if all tags fit into an uint bit array. */ | 240 | /* compile-time check if all tags fit into an unsigned int bit array. */ |
| 245 | struct NumTags { char limitexceeded[sizeof(uint) * 8 < LENGTH(tags) ? -1 : 1]; }; | 241 | struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 : 1]; }; |
| 246 | 242 | ||
| 247 | /* function implementations */ | 243 | /* function implementations */ |
| 248 | void | 244 | void |
| 249 | applyrules(Client *c) { | 245 | applyrules(Client *c) { |
| 250 | uint i; | 246 | unsigned int i; |
| 251 | Rule *r; | 247 | Rule *r; |
| 252 | XClassHint ch = { 0 }; | 248 | XClassHint ch = { 0 }; |
| 253 | 249 | ||
| @@ -304,7 +300,7 @@ attachstack(Client *c) { | |||
| 304 | 300 | ||
| 305 | void | 301 | void |
| 306 | buttonpress(XEvent *e) { | 302 | buttonpress(XEvent *e) { |
| 307 | uint i, x, click; | 303 | unsigned int i, x, click; |
| 308 | Arg arg = {0}; | 304 | Arg arg = {0}; |
| 309 | Client *c; | 305 | Client *c; |
| 310 | XButtonPressedEvent *ev = &e->xbutton; | 306 | XButtonPressedEvent *ev = &e->xbutton; |
| @@ -546,7 +542,7 @@ drawbar(void) { | |||
| 546 | } | 542 | } |
| 547 | 543 | ||
| 548 | void | 544 | void |
| 549 | drawsquare(Bool filled, Bool empty, Bool invert, ulong col[ColLast]) { | 545 | drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) { |
| 550 | int x; | 546 | int x; |
| 551 | XGCValues gcv; | 547 | XGCValues gcv; |
| 552 | XRectangle r = { dc.x, dc.y, dc.w, dc.h }; | 548 | XRectangle r = { dc.x, dc.y, dc.w, dc.h }; |
| @@ -567,7 +563,7 @@ drawsquare(Bool filled, Bool empty, Bool invert, ulong col[ColLast]) { | |||
| 567 | } | 563 | } |
| 568 | 564 | ||
| 569 | void | 565 | void |
| 570 | drawtext(const char *text, ulong col[ColLast], Bool invert) { | 566 | drawtext(const char *text, unsigned long col[ColLast], Bool invert) { |
| 571 | int i, x, y, h, len, olen; | 567 | int i, x, y, h, len, olen; |
| 572 | XRectangle r = { dc.x, dc.y, dc.w, dc.h }; | 568 | XRectangle r = { dc.x, dc.y, dc.w, dc.h }; |
| 573 | char buf[256]; | 569 | char buf[256]; |
| @@ -679,7 +675,7 @@ getclient(Window w) { | |||
| 679 | return c; | 675 | return c; |
| 680 | } | 676 | } |
| 681 | 677 | ||
| 682 | ulong | 678 | unsigned long |
| 683 | getcolor(const char *colstr) { | 679 | getcolor(const char *colstr) { |
| 684 | Colormap cmap = DefaultColormap(dpy, screen); | 680 | Colormap cmap = DefaultColormap(dpy, screen); |
| 685 | XColor color; | 681 | XColor color; |
| @@ -694,7 +690,7 @@ getstate(Window w) { | |||
| 694 | int format, status; | 690 | int format, status; |
| 695 | long result = -1; | 691 | long result = -1; |
| 696 | unsigned char *p = NULL; | 692 | unsigned char *p = NULL; |
| 697 | ulong n, extra; | 693 | unsigned long n, extra; |
| 698 | Atom real; | 694 | Atom real; |
| 699 | 695 | ||
| 700 | status = XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState], | 696 | status = XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState], |
| @@ -708,7 +704,7 @@ getstate(Window w) { | |||
| 708 | } | 704 | } |
| 709 | 705 | ||
| 710 | Bool | 706 | Bool |
| 711 | gettextprop(Window w, Atom atom, char *text, uint size) { | 707 | gettextprop(Window w, Atom atom, char *text, unsigned int size) { |
| 712 | char **list = NULL; | 708 | char **list = NULL; |
| 713 | int n; | 709 | int n; |
| 714 | XTextProperty name; | 710 | XTextProperty name; |
| @@ -735,8 +731,8 @@ gettextprop(Window w, Atom atom, char *text, uint size) { | |||
| 735 | 731 | ||
| 736 | void | 732 | void |
| 737 | grabbuttons(Client *c, Bool focused) { | 733 | grabbuttons(Client *c, Bool focused) { |
| 738 | uint i, j; | 734 | unsigned int i, j; |
| 739 | uint modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask }; | 735 | unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask }; |
| 740 | 736 | ||
| 741 | XUngrabButton(dpy, AnyButton, AnyModifier, c->win); | 737 | XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
| 742 | if(focused) { | 738 | if(focused) { |
| @@ -751,7 +747,7 @@ grabbuttons(Client *c, Bool focused) { | |||
| 751 | 747 | ||
| 752 | void | 748 | void |
| 753 | grabkeys(void) { | 749 | grabkeys(void) { |
| 754 | uint i, j; | 750 | unsigned int i, j; |
| 755 | KeyCode code; | 751 | KeyCode code; |
| 756 | XModifierKeymap *modmap; | 752 | XModifierKeymap *modmap; |
| 757 | 753 | ||
| @@ -819,7 +815,7 @@ initfont(const char *fontstr) { | |||
| 819 | } | 815 | } |
| 820 | 816 | ||
| 821 | Bool | 817 | Bool |
| 822 | isoccupied(uint t) { | 818 | isoccupied(unsigned int t) { |
| 823 | Client *c; | 819 | Client *c; |
| 824 | 820 | ||
| 825 | for(c = clients; c; c = c->next) | 821 | for(c = clients; c; c = c->next) |
| @@ -844,7 +840,7 @@ isprotodel(Client *c) { | |||
| 844 | } | 840 | } |
| 845 | 841 | ||
| 846 | Bool | 842 | Bool |
| 847 | isurgent(uint t) { | 843 | isurgent(unsigned int t) { |
| 848 | Client *c; | 844 | Client *c; |
| 849 | 845 | ||
| 850 | for(c = clients; c; c = c->next) | 846 | for(c = clients; c; c = c->next) |
| @@ -855,7 +851,7 @@ isurgent(uint t) { | |||
| 855 | 851 | ||
| 856 | void | 852 | void |
| 857 | keypress(XEvent *e) { | 853 | keypress(XEvent *e) { |
| 858 | uint i; | 854 | unsigned int i; |
| 859 | KeySym keysym; | 855 | KeySym keysym; |
| 860 | XKeyEvent *ev; | 856 | XKeyEvent *ev; |
| 861 | 857 | ||
| @@ -979,7 +975,7 @@ monocle(void) { | |||
| 979 | void | 975 | void |
| 980 | movemouse(const Arg *arg) { | 976 | movemouse(const Arg *arg) { |
| 981 | int x1, y1, ocx, ocy, di, nx, ny; | 977 | int x1, y1, ocx, ocy, di, nx, ny; |
| 982 | uint dui; | 978 | unsigned int dui; |
| 983 | Client *c; | 979 | Client *c; |
| 984 | Window dummy; | 980 | Window dummy; |
| 985 | XEvent ev; | 981 | XEvent ev; |
| @@ -1216,7 +1212,7 @@ run(void) { | |||
| 1216 | char sbuf[sizeof stext]; | 1212 | char sbuf[sizeof stext]; |
| 1217 | fd_set rd; | 1213 | fd_set rd; |
| 1218 | int r, xfd; | 1214 | int r, xfd; |
| 1219 | uint len, offset; | 1215 | unsigned int len, offset; |
| 1220 | XEvent ev; | 1216 | XEvent ev; |
| 1221 | 1217 | ||
| 1222 | /* main event loop, also reads status text from stdin */ | 1218 | /* main event loop, also reads status text from stdin */ |
| @@ -1272,7 +1268,7 @@ run(void) { | |||
| 1272 | 1268 | ||
| 1273 | void | 1269 | void |
| 1274 | scan(void) { | 1270 | scan(void) { |
| 1275 | uint i, num; | 1271 | unsigned int i, num; |
| 1276 | Window *wins, d1, d2; | 1272 | Window *wins, d1, d2; |
| 1277 | XWindowAttributes wa; | 1273 | XWindowAttributes wa; |
| 1278 | 1274 | ||
| @@ -1333,7 +1329,7 @@ setmfact(const Arg *arg) { | |||
| 1333 | 1329 | ||
| 1334 | void | 1330 | void |
| 1335 | setup(void) { | 1331 | setup(void) { |
| 1336 | uint i; | 1332 | unsigned int i; |
| 1337 | int w; | 1333 | int w; |
| 1338 | XSetWindowAttributes wa; | 1334 | XSetWindowAttributes wa; |
| 1339 | 1335 | ||
| @@ -1436,7 +1432,7 @@ tag(const Arg *arg) { | |||
| 1436 | } | 1432 | } |
| 1437 | 1433 | ||
| 1438 | int | 1434 | int |
| 1439 | textnw(const char *text, uint len) { | 1435 | textnw(const char *text, unsigned int len) { |
| 1440 | XRectangle r; | 1436 | XRectangle r; |
| 1441 | 1437 | ||
| 1442 | if(dc.font.set) { | 1438 | if(dc.font.set) { |
| @@ -1449,7 +1445,7 @@ textnw(const char *text, uint len) { | |||
| 1449 | void | 1445 | void |
| 1450 | tile(void) { | 1446 | tile(void) { |
| 1451 | int x, y, h, w, mw; | 1447 | int x, y, h, w, mw; |
| 1452 | uint i, n; | 1448 | unsigned int i, n; |
| 1453 | Client *c; | 1449 | Client *c; |
| 1454 | 1450 | ||
| 1455 | for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++); | 1451 | for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++); |
| @@ -1500,7 +1496,7 @@ togglefloating(const Arg *arg) { | |||
| 1500 | 1496 | ||
| 1501 | void | 1497 | void |
| 1502 | toggletag(const Arg *arg) { | 1498 | toggletag(const Arg *arg) { |
| 1503 | uint mask = sel->tags ^ (arg->ui & TAGMASK); | 1499 | unsigned int mask = sel->tags ^ (arg->ui & TAGMASK); |
| 1504 | 1500 | ||
| 1505 | if(sel && mask) { | 1501 | if(sel && mask) { |
| 1506 | sel->tags = mask; | 1502 | sel->tags = mask; |
| @@ -1510,7 +1506,7 @@ toggletag(const Arg *arg) { | |||
| 1510 | 1506 | ||
| 1511 | void | 1507 | void |
| 1512 | toggleview(const Arg *arg) { | 1508 | toggleview(const Arg *arg) { |
| 1513 | uint mask = tagset[seltags] ^ (arg->ui & TAGMASK); | 1509 | unsigned int mask = tagset[seltags] ^ (arg->ui & TAGMASK); |
| 1514 | 1510 | ||
| 1515 | if(mask) { | 1511 | if(mask) { |
| 1516 | tagset[seltags] = mask; | 1512 | tagset[seltags] = mask; |
