diff options
| author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2015-11-07 14:04:49 +0100 |
|---|---|---|
| committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2015-11-08 20:35:25 +0100 |
| commit | 43e82adf0dc37411fdcc6406b3cdf5d572387b9f (patch) | |
| tree | 339e67345546ef560877003da618d4165d994b34 /dwm.c | |
| parent | Makefile: package all files with make dist (diff) | |
| download | dwm-43e82adf0dc37411fdcc6406b3cdf5d572387b9f.tar.gz dwm-43e82adf0dc37411fdcc6406b3cdf5d572387b9f.zip | |
separate program-specific c99 bool and X11
True, False are X11-specific (int), make sure to use c99 stdbool for
program-specific things.
Diffstat (limited to '')
| -rw-r--r-- | dwm.c | 142 |
1 files changed, 72 insertions, 70 deletions
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <locale.h> | 24 | #include <locale.h> |
| 25 | #include <stdarg.h> | 25 | #include <stdarg.h> |
| 26 | #include <signal.h> | 26 | #include <signal.h> |
| 27 | #include <stdbool.h> | ||
| 27 | #include <stdio.h> | 28 | #include <stdio.h> |
| 28 | #include <stdlib.h> | 29 | #include <stdlib.h> |
| 29 | #include <string.h> | 30 | #include <string.h> |
| @@ -92,7 +93,7 @@ struct Client { | |||
| 92 | int basew, baseh, incw, inch, maxw, maxh, minw, minh; | 93 | int basew, baseh, incw, inch, maxw, maxh, minw, minh; |
| 93 | int bw, oldbw; | 94 | int bw, oldbw; |
| 94 | unsigned int tags; | 95 | unsigned int tags; |
| 95 | Bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; | 96 | bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; |
| 96 | Client *next; | 97 | Client *next; |
| 97 | Client *snext; | 98 | Client *snext; |
| 98 | Monitor *mon; | 99 | Monitor *mon; |
| @@ -122,8 +123,8 @@ struct Monitor { | |||
| 122 | unsigned int seltags; | 123 | unsigned int seltags; |
| 123 | unsigned int sellt; | 124 | unsigned int sellt; |
| 124 | unsigned int tagset[2]; | 125 | unsigned int tagset[2]; |
| 125 | Bool showbar; | 126 | bool showbar; |
| 126 | Bool topbar; | 127 | bool topbar; |
| 127 | Client *clients; | 128 | Client *clients; |
| 128 | Client *sel; | 129 | Client *sel; |
| 129 | Client *stack; | 130 | Client *stack; |
| @@ -137,13 +138,13 @@ typedef struct { | |||
| 137 | const char *instance; | 138 | const char *instance; |
| 138 | const char *title; | 139 | const char *title; |
| 139 | unsigned int tags; | 140 | unsigned int tags; |
| 140 | Bool isfloating; | 141 | bool isfloating; |
| 141 | int monitor; | 142 | int monitor; |
| 142 | } Rule; | 143 | } Rule; |
| 143 | 144 | ||
| 144 | /* function declarations */ | 145 | /* function declarations */ |
| 145 | static void applyrules(Client *c); | 146 | static void applyrules(Client *c); |
| 146 | static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact); | 147 | static bool applysizehints(Client *c, int *x, int *y, int *w, int *h, bool interact); |
| 147 | static void arrange(Monitor *m); | 148 | static void arrange(Monitor *m); |
| 148 | static void arrangemon(Monitor *m); | 149 | static void arrangemon(Monitor *m); |
| 149 | static void attach(Client *c); | 150 | static void attach(Client *c); |
| @@ -170,10 +171,10 @@ static void focus(Client *c); | |||
| 170 | static void focusin(XEvent *e); | 171 | static void focusin(XEvent *e); |
| 171 | static void focusmon(const Arg *arg); | 172 | static void focusmon(const Arg *arg); |
| 172 | static void focusstack(const Arg *arg); | 173 | static void focusstack(const Arg *arg); |
| 173 | static Bool getrootptr(int *x, int *y); | 174 | static bool getrootptr(int *x, int *y); |
| 174 | static long getstate(Window w); | 175 | static long getstate(Window w); |
| 175 | static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); | 176 | static bool gettextprop(Window w, Atom atom, char *text, unsigned int size); |
| 176 | static void grabbuttons(Client *c, Bool focused); | 177 | static void grabbuttons(Client *c, bool focused); |
| 177 | static void grabkeys(void); | 178 | static void grabkeys(void); |
| 178 | static void incnmaster(const Arg *arg); | 179 | static void incnmaster(const Arg *arg); |
| 179 | static void keypress(XEvent *e); | 180 | static void keypress(XEvent *e); |
| @@ -189,17 +190,17 @@ static void pop(Client *); | |||
| 189 | static void propertynotify(XEvent *e); | 190 | static void propertynotify(XEvent *e); |
| 190 | static void quit(const Arg *arg); | 191 | static void quit(const Arg *arg); |
| 191 | static Monitor *recttomon(int x, int y, int w, int h); | 192 | static Monitor *recttomon(int x, int y, int w, int h); |
| 192 | static void resize(Client *c, int x, int y, int w, int h, Bool interact); | 193 | static void resize(Client *c, int x, int y, int w, int h, bool interact); |
| 193 | static void resizeclient(Client *c, int x, int y, int w, int h); | 194 | static void resizeclient(Client *c, int x, int y, int w, int h); |
| 194 | static void resizemouse(const Arg *arg); | 195 | static void resizemouse(const Arg *arg); |
| 195 | static void restack(Monitor *m); | 196 | static void restack(Monitor *m); |
| 196 | static void run(void); | 197 | static void run(void); |
| 197 | static void scan(void); | 198 | static void scan(void); |
| 198 | static Bool sendevent(Client *c, Atom proto); | 199 | static bool sendevent(Client *c, Atom proto); |
| 199 | static void sendmon(Client *c, Monitor *m); | 200 | static void sendmon(Client *c, Monitor *m); |
| 200 | static void setclientstate(Client *c, long state); | 201 | static void setclientstate(Client *c, long state); |
| 201 | static void setfocus(Client *c); | 202 | static void setfocus(Client *c); |
| 202 | static void setfullscreen(Client *c, Bool fullscreen); | 203 | static void setfullscreen(Client *c, bool fullscreen); |
| 203 | static void setlayout(const Arg *arg); | 204 | static void setlayout(const Arg *arg); |
| 204 | static void setmfact(const Arg *arg); | 205 | static void setmfact(const Arg *arg); |
| 205 | static void setup(void); | 206 | static void setup(void); |
| @@ -213,10 +214,10 @@ static void togglebar(const Arg *arg); | |||
| 213 | static void togglefloating(const Arg *arg); | 214 | static void togglefloating(const Arg *arg); |
| 214 | static void toggletag(const Arg *arg); | 215 | static void toggletag(const Arg *arg); |
| 215 | static void toggleview(const Arg *arg); | 216 | static void toggleview(const Arg *arg); |
| 216 | static void unfocus(Client *c, Bool setfocus); | 217 | static void unfocus(Client *c, bool setfocus); |
| 217 | static void unmanage(Client *c, Bool destroyed); | 218 | static void unmanage(Client *c, bool destroyed); |
| 218 | static void unmapnotify(XEvent *e); | 219 | static void unmapnotify(XEvent *e); |
| 219 | static Bool updategeom(void); | 220 | static bool updategeom(void); |
| 220 | static void updatebarpos(Monitor *m); | 221 | static void updatebarpos(Monitor *m); |
| 221 | static void updatebars(void); | 222 | static void updatebars(void); |
| 222 | static void updateclientlist(void); | 223 | static void updateclientlist(void); |
| @@ -259,7 +260,7 @@ static void (*handler[LASTEvent]) (XEvent *) = { | |||
| 259 | [UnmapNotify] = unmapnotify | 260 | [UnmapNotify] = unmapnotify |
| 260 | }; | 261 | }; |
| 261 | static Atom wmatom[WMLast], netatom[NetLast]; | 262 | static Atom wmatom[WMLast], netatom[NetLast]; |
| 262 | static Bool running = True; | 263 | static bool running = true; |
| 263 | static Cur *cursor[CurLast]; | 264 | static Cur *cursor[CurLast]; |
| 264 | static ClrScheme scheme[SchemeLast]; | 265 | static ClrScheme scheme[SchemeLast]; |
| 265 | static Display *dpy; | 266 | static Display *dpy; |
| @@ -283,7 +284,8 @@ applyrules(Client *c) { | |||
| 283 | XClassHint ch = { NULL, NULL }; | 284 | XClassHint ch = { NULL, NULL }; |
| 284 | 285 | ||
| 285 | /* rule matching */ | 286 | /* rule matching */ |
| 286 | c->isfloating = c->tags = 0; | 287 | c->isfloating = false; |
| 288 | c->tags = 0; | ||
| 287 | XGetClassHint(dpy, c->win, &ch); | 289 | XGetClassHint(dpy, c->win, &ch); |
| 288 | class = ch.res_class ? ch.res_class : broken; | 290 | class = ch.res_class ? ch.res_class : broken; |
| 289 | instance = ch.res_name ? ch.res_name : broken; | 291 | instance = ch.res_name ? ch.res_name : broken; |
| @@ -308,9 +310,9 @@ applyrules(Client *c) { | |||
| 308 | c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags]; | 310 | c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags]; |
| 309 | } | 311 | } |
| 310 | 312 | ||
| 311 | Bool | 313 | bool |
| 312 | applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact) { | 314 | applysizehints(Client *c, int *x, int *y, int *w, int *h, bool interact) { |
| 313 | Bool baseismin; | 315 | bool baseismin; |
| 314 | Monitor *m = c->mon; | 316 | Monitor *m = c->mon; |
| 315 | 317 | ||
| 316 | /* set minimum possible */ | 318 | /* set minimum possible */ |
| @@ -417,7 +419,7 @@ buttonpress(XEvent *e) { | |||
| 417 | click = ClkRootWin; | 419 | click = ClkRootWin; |
| 418 | /* focus monitor if necessary */ | 420 | /* focus monitor if necessary */ |
| 419 | if((m = wintomon(ev->window)) && m != selmon) { | 421 | if((m = wintomon(ev->window)) && m != selmon) { |
| 420 | unfocus(selmon->sel, True); | 422 | unfocus(selmon->sel, true); |
| 421 | selmon = m; | 423 | selmon = m; |
| 422 | focus(NULL); | 424 | focus(NULL); |
| 423 | } | 425 | } |
| @@ -468,7 +470,7 @@ cleanup(void) { | |||
| 468 | selmon->lt[selmon->sellt] = &foo; | 470 | selmon->lt[selmon->sellt] = &foo; |
| 469 | for(m = mons; m; m = m->next) | 471 | for(m = mons; m; m = m->next) |
| 470 | while(m->stack) | 472 | while(m->stack) |
| 471 | unmanage(m->stack, False); | 473 | unmanage(m->stack, false); |
| 472 | XUngrabKey(dpy, AnyKey, AnyModifier, root); | 474 | XUngrabKey(dpy, AnyKey, AnyModifier, root); |
| 473 | while(mons) | 475 | while(mons) |
| 474 | cleanupmon(mons); | 476 | cleanupmon(mons); |
| @@ -504,7 +506,7 @@ void | |||
| 504 | clearurgent(Client *c) { | 506 | clearurgent(Client *c) { |
| 505 | XWMHints *wmh; | 507 | XWMHints *wmh; |
| 506 | 508 | ||
| 507 | c->isurgent = False; | 509 | c->isurgent = false; |
| 508 | if(!(wmh = XGetWMHints(dpy, c->win))) | 510 | if(!(wmh = XGetWMHints(dpy, c->win))) |
| 509 | return; | 511 | return; |
| 510 | wmh->flags &= ~XUrgencyHint; | 512 | wmh->flags &= ~XUrgencyHint; |
| @@ -555,7 +557,7 @@ void | |||
| 555 | configurenotify(XEvent *e) { | 557 | configurenotify(XEvent *e) { |
| 556 | Monitor *m; | 558 | Monitor *m; |
| 557 | XConfigureEvent *ev = &e->xconfigure; | 559 | XConfigureEvent *ev = &e->xconfigure; |
| 558 | Bool dirty; | 560 | bool dirty; |
| 559 | 561 | ||
| 560 | /* TODO: updategeom handling sucks, needs to be simplified */ | 562 | /* TODO: updategeom handling sucks, needs to be simplified */ |
| 561 | if(ev->window == root) { | 563 | if(ev->window == root) { |
| @@ -648,7 +650,7 @@ destroynotify(XEvent *e) { | |||
| 648 | XDestroyWindowEvent *ev = &e->xdestroywindow; | 650 | XDestroyWindowEvent *ev = &e->xdestroywindow; |
| 649 | 651 | ||
| 650 | if((c = wintoclient(ev->window))) | 652 | if((c = wintoclient(ev->window))) |
| 651 | unmanage(c, True); | 653 | unmanage(c, true); |
| 652 | } | 654 | } |
| 653 | 655 | ||
| 654 | void | 656 | void |
| @@ -759,7 +761,7 @@ enternotify(XEvent *e) { | |||
| 759 | c = wintoclient(ev->window); | 761 | c = wintoclient(ev->window); |
| 760 | m = c ? c->mon : wintomon(ev->window); | 762 | m = c ? c->mon : wintomon(ev->window); |
| 761 | if(m != selmon) { | 763 | if(m != selmon) { |
| 762 | unfocus(selmon->sel, True); | 764 | unfocus(selmon->sel, true); |
| 763 | selmon = m; | 765 | selmon = m; |
| 764 | } | 766 | } |
| 765 | else if(!c || c == selmon->sel) | 767 | else if(!c || c == selmon->sel) |
| @@ -782,7 +784,7 @@ focus(Client *c) { | |||
| 782 | for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext); | 784 | for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext); |
| 783 | /* was if(selmon->sel) */ | 785 | /* was if(selmon->sel) */ |
| 784 | if(selmon->sel && selmon->sel != c) | 786 | if(selmon->sel && selmon->sel != c) |
| 785 | unfocus(selmon->sel, False); | 787 | unfocus(selmon->sel, false); |
| 786 | if(c) { | 788 | if(c) { |
| 787 | if(c->mon != selmon) | 789 | if(c->mon != selmon) |
| 788 | selmon = c->mon; | 790 | selmon = c->mon; |
| @@ -790,7 +792,7 @@ focus(Client *c) { | |||
| 790 | clearurgent(c); | 792 | clearurgent(c); |
| 791 | detachstack(c); | 793 | detachstack(c); |
| 792 | attachstack(c); | 794 | attachstack(c); |
| 793 | grabbuttons(c, True); | 795 | grabbuttons(c, true); |
| 794 | XSetWindowBorder(dpy, c->win, scheme[SchemeSel].border->pix); | 796 | XSetWindowBorder(dpy, c->win, scheme[SchemeSel].border->pix); |
| 795 | setfocus(c); | 797 | setfocus(c); |
| 796 | } | 798 | } |
| @@ -818,7 +820,7 @@ focusmon(const Arg *arg) { | |||
| 818 | return; | 820 | return; |
| 819 | if((m = dirtomon(arg->i)) == selmon) | 821 | if((m = dirtomon(arg->i)) == selmon) |
| 820 | return; | 822 | return; |
| 821 | unfocus(selmon->sel, False); /* s/True/False/ fixes input focus issues | 823 | unfocus(selmon->sel, false); /* s/true/false/ fixes input focus issues |
| 822 | in gedit and anjuta */ | 824 | in gedit and anjuta */ |
| 823 | selmon = m; | 825 | selmon = m; |
| 824 | focus(NULL); | 826 | focus(NULL); |
| @@ -865,13 +867,13 @@ getatomprop(Client *c, Atom prop) { | |||
| 865 | return atom; | 867 | return atom; |
| 866 | } | 868 | } |
| 867 | 869 | ||
| 868 | Bool | 870 | bool |
| 869 | getrootptr(int *x, int *y) { | 871 | getrootptr(int *x, int *y) { |
| 870 | int di; | 872 | int di; |
| 871 | unsigned int dui; | 873 | unsigned int dui; |
| 872 | Window dummy; | 874 | Window dummy; |
| 873 | 875 | ||
| 874 | return XQueryPointer(dpy, root, &dummy, &dummy, x, y, &di, &di, &dui); | 876 | return XQueryPointer(dpy, root, &dummy, &dummy, x, y, &di, &di, &dui) == True; |
| 875 | } | 877 | } |
| 876 | 878 | ||
| 877 | long | 879 | long |
| @@ -891,18 +893,18 @@ getstate(Window w) { | |||
| 891 | return result; | 893 | return result; |
| 892 | } | 894 | } |
| 893 | 895 | ||
| 894 | Bool | 896 | bool |
| 895 | gettextprop(Window w, Atom atom, char *text, unsigned int size) { | 897 | gettextprop(Window w, Atom atom, char *text, unsigned int size) { |
| 896 | char **list = NULL; | 898 | char **list = NULL; |
| 897 | int n; | 899 | int n; |
| 898 | XTextProperty name; | 900 | XTextProperty name; |
| 899 | 901 | ||
| 900 | if(!text || size == 0) | 902 | if(!text || size == 0) |
| 901 | return False; | 903 | return false; |
| 902 | text[0] = '\0'; | 904 | text[0] = '\0'; |
| 903 | XGetTextProperty(dpy, w, &name, atom); | 905 | XGetTextProperty(dpy, w, &name, atom); |
| 904 | if(!name.nitems) | 906 | if(!name.nitems) |
| 905 | return False; | 907 | return false; |
| 906 | if(name.encoding == XA_STRING) | 908 | if(name.encoding == XA_STRING) |
| 907 | strncpy(text, (char *)name.value, size - 1); | 909 | strncpy(text, (char *)name.value, size - 1); |
| 908 | else { | 910 | else { |
| @@ -913,11 +915,11 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size) { | |||
| 913 | } | 915 | } |
| 914 | text[size - 1] = '\0'; | 916 | text[size - 1] = '\0'; |
| 915 | XFree(name.value); | 917 | XFree(name.value); |
| 916 | return True; | 918 | return true; |
| 917 | } | 919 | } |
| 918 | 920 | ||
| 919 | void | 921 | void |
| 920 | grabbuttons(Client *c, Bool focused) { | 922 | grabbuttons(Client *c, bool focused) { |
| 921 | updatenumlockmask(); | 923 | updatenumlockmask(); |
| 922 | { | 924 | { |
| 923 | unsigned int i, j; | 925 | unsigned int i, j; |
| @@ -962,13 +964,13 @@ incnmaster(const Arg *arg) { | |||
| 962 | } | 964 | } |
| 963 | 965 | ||
| 964 | #ifdef XINERAMA | 966 | #ifdef XINERAMA |
| 965 | static Bool | 967 | static bool |
| 966 | isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info) { | 968 | isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info) { |
| 967 | while(n--) | 969 | while(n--) |
| 968 | if(unique[n].x_org == info->x_org && unique[n].y_org == info->y_org | 970 | if(unique[n].x_org == info->x_org && unique[n].y_org == info->y_org |
| 969 | && unique[n].width == info->width && unique[n].height == info->height) | 971 | && unique[n].width == info->width && unique[n].height == info->height) |
| 970 | return False; | 972 | return false; |
| 971 | return True; | 973 | return true; |
| 972 | } | 974 | } |
| 973 | #endif /* XINERAMA */ | 975 | #endif /* XINERAMA */ |
| 974 | 976 | ||
| @@ -1044,7 +1046,7 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 1044 | updatesizehints(c); | 1046 | updatesizehints(c); |
| 1045 | updatewmhints(c); | 1047 | updatewmhints(c); |
| 1046 | XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); | 1048 | XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); |
| 1047 | grabbuttons(c, False); | 1049 | grabbuttons(c, false); |
| 1048 | if(!c->isfloating) | 1050 | if(!c->isfloating) |
| 1049 | c->isfloating = c->oldstate = trans != None || c->isfixed; | 1051 | c->isfloating = c->oldstate = trans != None || c->isfixed; |
| 1050 | if(c->isfloating) | 1052 | if(c->isfloating) |
| @@ -1056,7 +1058,7 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 1056 | XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */ | 1058 | XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */ |
| 1057 | setclientstate(c, NormalState); | 1059 | setclientstate(c, NormalState); |
| 1058 | if (c->mon == selmon) | 1060 | if (c->mon == selmon) |
| 1059 | unfocus(selmon->sel, False); | 1061 | unfocus(selmon->sel, false); |
| 1060 | c->mon->sel = c; | 1062 | c->mon->sel = c; |
| 1061 | arrange(c->mon); | 1063 | arrange(c->mon); |
| 1062 | XMapWindow(dpy, c->win); | 1064 | XMapWindow(dpy, c->win); |
| @@ -1096,7 +1098,7 @@ monocle(Monitor *m) { | |||
| 1096 | if(n > 0) /* override layout symbol */ | 1098 | if(n > 0) /* override layout symbol */ |
| 1097 | snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); | 1099 | snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); |
| 1098 | for(c = nexttiled(m->clients); c; c = nexttiled(c->next)) | 1100 | for(c = nexttiled(m->clients); c; c = nexttiled(c->next)) |
| 1099 | resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False); | 1101 | resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, false); |
| 1100 | } | 1102 | } |
| 1101 | 1103 | ||
| 1102 | void | 1104 | void |
| @@ -1108,7 +1110,7 @@ motionnotify(XEvent *e) { | |||
| 1108 | if(ev->window != root) | 1110 | if(ev->window != root) |
| 1109 | return; | 1111 | return; |
| 1110 | if((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) { | 1112 | if((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) { |
| 1111 | unfocus(selmon->sel, True); | 1113 | unfocus(selmon->sel, true); |
| 1112 | selmon = m; | 1114 | selmon = m; |
| 1113 | focus(NULL); | 1115 | focus(NULL); |
| 1114 | } | 1116 | } |
| @@ -1165,7 +1167,7 @@ movemouse(const Arg *arg) { | |||
| 1165 | togglefloating(NULL); | 1167 | togglefloating(NULL); |
| 1166 | } | 1168 | } |
| 1167 | if(!selmon->lt[selmon->sellt]->arrange || c->isfloating) | 1169 | if(!selmon->lt[selmon->sellt]->arrange || c->isfloating) |
| 1168 | resize(c, nx, ny, c->w, c->h, True); | 1170 | resize(c, nx, ny, c->w, c->h, true); |
| 1169 | break; | 1171 | break; |
| 1170 | } | 1172 | } |
| 1171 | } while(ev.type != ButtonRelease); | 1173 | } while(ev.type != ButtonRelease); |
| @@ -1229,7 +1231,7 @@ propertynotify(XEvent *e) { | |||
| 1229 | 1231 | ||
| 1230 | void | 1232 | void |
| 1231 | quit(const Arg *arg) { | 1233 | quit(const Arg *arg) { |
| 1232 | running = False; | 1234 | running = false; |
| 1233 | } | 1235 | } |
| 1234 | 1236 | ||
| 1235 | Monitor * | 1237 | Monitor * |
| @@ -1246,7 +1248,7 @@ recttomon(int x, int y, int w, int h) { | |||
| 1246 | } | 1248 | } |
| 1247 | 1249 | ||
| 1248 | void | 1250 | void |
| 1249 | resize(Client *c, int x, int y, int w, int h, Bool interact) { | 1251 | resize(Client *c, int x, int y, int w, int h, bool interact) { |
| 1250 | if(applysizehints(c, &x, &y, &w, &h, interact)) | 1252 | if(applysizehints(c, &x, &y, &w, &h, interact)) |
| 1251 | resizeclient(c, x, y, w, h); | 1253 | resizeclient(c, x, y, w, h); |
| 1252 | } | 1254 | } |
| @@ -1307,7 +1309,7 @@ resizemouse(const Arg *arg) { | |||
| 1307 | togglefloating(NULL); | 1309 | togglefloating(NULL); |
| 1308 | } | 1310 | } |
| 1309 | if(!selmon->lt[selmon->sellt]->arrange || c->isfloating) | 1311 | if(!selmon->lt[selmon->sellt]->arrange || c->isfloating) |
| 1310 | resize(c, c->x, c->y, nw, nh, True); | 1312 | resize(c, c->x, c->y, nw, nh, true); |
| 1311 | break; | 1313 | break; |
| 1312 | } | 1314 | } |
| 1313 | } while(ev.type != ButtonRelease); | 1315 | } while(ev.type != ButtonRelease); |
| @@ -1385,7 +1387,7 @@ void | |||
| 1385 | sendmon(Client *c, Monitor *m) { | 1387 | sendmon(Client *c, Monitor *m) { |
| 1386 | if(c->mon == m) | 1388 | if(c->mon == m) |
| 1387 | return; | 1389 | return; |
| 1388 | unfocus(c, True); | 1390 | unfocus(c, true); |
| 1389 | detach(c); | 1391 | detach(c); |
| 1390 | detachstack(c); | 1392 | detachstack(c); |
| 1391 | c->mon = m; | 1393 | c->mon = m; |
| @@ -1404,11 +1406,11 @@ setclientstate(Client *c, long state) { | |||
| 1404 | PropModeReplace, (unsigned char *)data, 2); | 1406 | PropModeReplace, (unsigned char *)data, 2); |
| 1405 | } | 1407 | } |
| 1406 | 1408 | ||
| 1407 | Bool | 1409 | bool |
| 1408 | sendevent(Client *c, Atom proto) { | 1410 | sendevent(Client *c, Atom proto) { |
| 1409 | int n; | 1411 | int n; |
| 1410 | Atom *protocols; | 1412 | Atom *protocols; |
| 1411 | Bool exists = False; | 1413 | bool exists = false; |
| 1412 | XEvent ev; | 1414 | XEvent ev; |
| 1413 | 1415 | ||
| 1414 | if(XGetWMProtocols(dpy, c->win, &protocols, &n)) { | 1416 | if(XGetWMProtocols(dpy, c->win, &protocols, &n)) { |
| @@ -1440,22 +1442,22 @@ setfocus(Client *c) { | |||
| 1440 | } | 1442 | } |
| 1441 | 1443 | ||
| 1442 | void | 1444 | void |
| 1443 | setfullscreen(Client *c, Bool fullscreen) { | 1445 | setfullscreen(Client *c, bool fullscreen) { |
| 1444 | if(fullscreen && !c->isfullscreen) { | 1446 | if(fullscreen && !c->isfullscreen) { |
| 1445 | XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, | 1447 | XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, |
| 1446 | PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1); | 1448 | PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1); |
| 1447 | c->isfullscreen = True; | 1449 | c->isfullscreen = true; |
| 1448 | c->oldstate = c->isfloating; | 1450 | c->oldstate = c->isfloating; |
| 1449 | c->oldbw = c->bw; | 1451 | c->oldbw = c->bw; |
| 1450 | c->bw = 0; | 1452 | c->bw = 0; |
| 1451 | c->isfloating = True; | 1453 | c->isfloating = true; |
| 1452 | resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh); | 1454 | resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh); |
| 1453 | XRaiseWindow(dpy, c->win); | 1455 | XRaiseWindow(dpy, c->win); |
| 1454 | } | 1456 | } |
| 1455 | else if(!fullscreen && c->isfullscreen){ | 1457 | else if(!fullscreen && c->isfullscreen){ |
| 1456 | XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, | 1458 | XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, |
| 1457 | PropModeReplace, (unsigned char*)0, 0); | 1459 | PropModeReplace, (unsigned char*)0, 0); |
| 1458 | c->isfullscreen = False; | 1460 | c->isfullscreen = false; |
| 1459 | c->isfloating = c->oldstate; | 1461 | c->isfloating = c->oldstate; |
| 1460 | c->bw = c->oldbw; | 1462 | c->bw = c->oldbw; |
| 1461 | c->x = c->oldx; | 1463 | c->x = c->oldx; |
| @@ -1560,7 +1562,7 @@ showhide(Client *c) { | |||
| 1560 | if(ISVISIBLE(c)) { /* show clients top down */ | 1562 | if(ISVISIBLE(c)) { /* show clients top down */ |
| 1561 | XMoveWindow(dpy, c->win, c->x, c->y); | 1563 | XMoveWindow(dpy, c->win, c->x, c->y); |
| 1562 | if((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen) | 1564 | if((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen) |
| 1563 | resize(c, c->x, c->y, c->w, c->h, False); | 1565 | resize(c, c->x, c->y, c->w, c->h, false); |
| 1564 | showhide(c->snext); | 1566 | showhide(c->snext); |
| 1565 | } | 1567 | } |
| 1566 | else { /* hide clients bottom up */ | 1568 | else { /* hide clients bottom up */ |
| @@ -1623,12 +1625,12 @@ tile(Monitor *m) { | |||
| 1623 | for(i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) | 1625 | for(i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) |
| 1624 | if(i < m->nmaster) { | 1626 | if(i < m->nmaster) { |
| 1625 | h = (m->wh - my) / (MIN(n, m->nmaster) - i); | 1627 | h = (m->wh - my) / (MIN(n, m->nmaster) - i); |
| 1626 | resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False); | 1628 | resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), false); |
| 1627 | my += HEIGHT(c); | 1629 | my += HEIGHT(c); |
| 1628 | } | 1630 | } |
| 1629 | else { | 1631 | else { |
| 1630 | h = (m->wh - ty) / (n - i); | 1632 | h = (m->wh - ty) / (n - i); |
| 1631 | resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), False); | 1633 | resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), false); |
| 1632 | ty += HEIGHT(c); | 1634 | ty += HEIGHT(c); |
| 1633 | } | 1635 | } |
| 1634 | } | 1636 | } |
| @@ -1650,7 +1652,7 @@ togglefloating(const Arg *arg) { | |||
| 1650 | selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; | 1652 | selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; |
| 1651 | if(selmon->sel->isfloating) | 1653 | if(selmon->sel->isfloating) |
| 1652 | resize(selmon->sel, selmon->sel->x, selmon->sel->y, | 1654 | resize(selmon->sel, selmon->sel->x, selmon->sel->y, |
| 1653 | selmon->sel->w, selmon->sel->h, False); | 1655 | selmon->sel->w, selmon->sel->h, false); |
| 1654 | arrange(selmon); | 1656 | arrange(selmon); |
| 1655 | } | 1657 | } |
| 1656 | 1658 | ||
| @@ -1680,10 +1682,10 @@ toggleview(const Arg *arg) { | |||
| 1680 | } | 1682 | } |
| 1681 | 1683 | ||
| 1682 | void | 1684 | void |
| 1683 | unfocus(Client *c, Bool setfocus) { | 1685 | unfocus(Client *c, bool setfocus) { |
| 1684 | if(!c) | 1686 | if(!c) |
| 1685 | return; | 1687 | return; |
| 1686 | grabbuttons(c, False); | 1688 | grabbuttons(c, false); |
| 1687 | XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].border->pix); | 1689 | XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].border->pix); |
| 1688 | if(setfocus) { | 1690 | if(setfocus) { |
| 1689 | XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); | 1691 | XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
| @@ -1692,7 +1694,7 @@ unfocus(Client *c, Bool setfocus) { | |||
| 1692 | } | 1694 | } |
| 1693 | 1695 | ||
| 1694 | void | 1696 | void |
| 1695 | unmanage(Client *c, Bool destroyed) { | 1697 | unmanage(Client *c, bool destroyed) { |
| 1696 | Monitor *m = c->mon; | 1698 | Monitor *m = c->mon; |
| 1697 | XWindowChanges wc; | 1699 | XWindowChanges wc; |
| 1698 | 1700 | ||
| @@ -1725,7 +1727,7 @@ unmapnotify(XEvent *e) { | |||
| 1725 | if(ev->send_event) | 1727 | if(ev->send_event) |
| 1726 | setclientstate(c, WithdrawnState); | 1728 | setclientstate(c, WithdrawnState); |
| 1727 | else | 1729 | else |
| 1728 | unmanage(c, False); | 1730 | unmanage(c, false); |
| 1729 | } | 1731 | } |
| 1730 | } | 1732 | } |
| 1731 | 1733 | ||
| @@ -1774,9 +1776,9 @@ updateclientlist() { | |||
| 1774 | (unsigned char *) &(c->win), 1); | 1776 | (unsigned char *) &(c->win), 1); |
| 1775 | } | 1777 | } |
| 1776 | 1778 | ||
| 1777 | Bool | 1779 | bool |
| 1778 | updategeom(void) { | 1780 | updategeom(void) { |
| 1779 | Bool dirty = False; | 1781 | bool dirty = false; |
| 1780 | 1782 | ||
| 1781 | #ifdef XINERAMA | 1783 | #ifdef XINERAMA |
| 1782 | if(XineramaIsActive(dpy)) { | 1784 | if(XineramaIsActive(dpy)) { |
| @@ -1807,7 +1809,7 @@ updategeom(void) { | |||
| 1807 | || (unique[i].x_org != m->mx || unique[i].y_org != m->my | 1809 | || (unique[i].x_org != m->mx || unique[i].y_org != m->my |
| 1808 | || unique[i].width != m->mw || unique[i].height != m->mh)) | 1810 | || unique[i].width != m->mw || unique[i].height != m->mh)) |
| 1809 | { | 1811 | { |
| 1810 | dirty = True; | 1812 | dirty = true; |
| 1811 | m->num = i; | 1813 | m->num = i; |
| 1812 | m->mx = m->wx = unique[i].x_org; | 1814 | m->mx = m->wx = unique[i].x_org; |
| 1813 | m->my = m->wy = unique[i].y_org; | 1815 | m->my = m->wy = unique[i].y_org; |
| @@ -1820,7 +1822,7 @@ updategeom(void) { | |||
| 1820 | for(i = nn; i < n; i++) { | 1822 | for(i = nn; i < n; i++) { |
| 1821 | for(m = mons; m && m->next; m = m->next); | 1823 | for(m = mons; m && m->next; m = m->next); |
| 1822 | while(m->clients) { | 1824 | while(m->clients) { |
| 1823 | dirty = True; | 1825 | dirty = true; |
| 1824 | c = m->clients; | 1826 | c = m->clients; |
| 1825 | m->clients = c->next; | 1827 | m->clients = c->next; |
| 1826 | detachstack(c); | 1828 | detachstack(c); |
| @@ -1842,7 +1844,7 @@ updategeom(void) { | |||
| 1842 | if(!mons) | 1844 | if(!mons) |
| 1843 | mons = createmon(); | 1845 | mons = createmon(); |
| 1844 | if(mons->mw != sw || mons->mh != sh) { | 1846 | if(mons->mw != sw || mons->mh != sh) { |
| 1845 | dirty = True; | 1847 | dirty = true; |
| 1846 | mons->mw = mons->ww = sw; | 1848 | mons->mw = mons->ww = sw; |
| 1847 | mons->mh = mons->wh = sh; | 1849 | mons->mh = mons->wh = sh; |
| 1848 | updatebarpos(mons); | 1850 | updatebarpos(mons); |
| @@ -1941,9 +1943,9 @@ updatewindowtype(Client *c) { | |||
| 1941 | Atom wtype = getatomprop(c, netatom[NetWMWindowType]); | 1943 | Atom wtype = getatomprop(c, netatom[NetWMWindowType]); |
| 1942 | 1944 | ||
| 1943 | if(state == netatom[NetWMFullscreen]) | 1945 | if(state == netatom[NetWMFullscreen]) |
| 1944 | setfullscreen(c, True); | 1946 | setfullscreen(c, true); |
| 1945 | if(wtype == netatom[NetWMWindowTypeDialog]) | 1947 | if(wtype == netatom[NetWMWindowTypeDialog]) |
| 1946 | c->isfloating = True; | 1948 | c->isfloating = true; |
| 1947 | } | 1949 | } |
| 1948 | 1950 | ||
| 1949 | void | 1951 | void |
| @@ -1956,11 +1958,11 @@ updatewmhints(Client *c) { | |||
| 1956 | XSetWMHints(dpy, c->win, wmh); | 1958 | XSetWMHints(dpy, c->win, wmh); |
| 1957 | } | 1959 | } |
| 1958 | else | 1960 | else |
| 1959 | c->isurgent = (wmh->flags & XUrgencyHint) ? True : False; | 1961 | c->isurgent = (wmh->flags & XUrgencyHint) ? true : false; |
| 1960 | if(wmh->flags & InputHint) | 1962 | if(wmh->flags & InputHint) |
| 1961 | c->neverfocus = !wmh->input; | 1963 | c->neverfocus = !wmh->input; |
| 1962 | else | 1964 | else |
| 1963 | c->neverfocus = False; | 1965 | c->neverfocus = false; |
| 1964 | XFree(wmh); | 1966 | XFree(wmh); |
| 1965 | } | 1967 | } |
| 1966 | } | 1968 | } |
