diff options
Diffstat (limited to '')
| -rw-r--r-- | dwm.c | 46 |
1 files changed, 26 insertions, 20 deletions
| @@ -11,9 +11,9 @@ | |||
| 11 | * in O(1) time. | 11 | * in O(1) time. |
| 12 | * | 12 | * |
| 13 | * Each child of the root window is called a client, except windows which have | 13 | * Each child of the root window is called a client, except windows which have |
| 14 | * set the override_redirect flag. Clients are organized in a global | 14 | * set the override_redirect flag. Clients are organized in a linked client |
| 15 | * linked client list, the focus history is remembered through a global | 15 | * list on each monitor, the focus history is remembered through a stack list |
| 16 | * stack list. Each client contains a bit array to indicate the tags of a | 16 | * on each monitor. Each client contains a bit array to indicate the tags of a |
| 17 | * client. | 17 | * client. |
| 18 | * | 18 | * |
| 19 | * Keys and tagging rules are organized as arrays and defined in config.h. | 19 | * Keys and tagging rules are organized as arrays and defined in config.h. |
| @@ -164,6 +164,7 @@ static void destroynotify(XEvent *e); | |||
| 164 | static void detach(Client *c); | 164 | static void detach(Client *c); |
| 165 | static void detachstack(Client *c); | 165 | static void detachstack(Client *c); |
| 166 | static void die(const char *errstr, ...); | 166 | static void die(const char *errstr, ...); |
| 167 | static Monitor *dirtomon(int dir); | ||
| 167 | static void drawbar(Monitor *m); | 168 | static void drawbar(Monitor *m); |
| 168 | static void drawbars(void); | 169 | static void drawbars(void); |
| 169 | static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]); | 170 | static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]); |
| @@ -180,7 +181,6 @@ static long getstate(Window w); | |||
| 180 | static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); | 181 | static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); |
| 181 | static void grabbuttons(Client *c, Bool focused); | 182 | static void grabbuttons(Client *c, Bool focused); |
| 182 | static void grabkeys(void); | 183 | static void grabkeys(void); |
| 183 | static Monitor *idxtomon(unsigned int n); | ||
| 184 | static void initfont(const char *fontstr); | 184 | static void initfont(const char *fontstr); |
| 185 | static Bool isprotodel(Client *c); | 185 | static Bool isprotodel(Client *c); |
| 186 | static void keypress(XEvent *e); | 186 | static void keypress(XEvent *e); |
| @@ -621,6 +621,22 @@ die(const char *errstr, ...) { | |||
| 621 | exit(EXIT_FAILURE); | 621 | exit(EXIT_FAILURE); |
| 622 | } | 622 | } |
| 623 | 623 | ||
| 624 | Monitor * | ||
| 625 | dirtomon(int dir) { | ||
| 626 | Monitor *m = NULL; | ||
| 627 | |||
| 628 | if(dir > 0) | ||
| 629 | if(!(m = selmon->next)) | ||
| 630 | m = mons; | ||
| 631 | else { | ||
| 632 | if(selmon == mons) | ||
| 633 | for(m = mons; m->next; m = m->next); | ||
| 634 | else | ||
| 635 | for(m = mons; m->next != selmon; m = m->next); | ||
| 636 | } | ||
| 637 | return m; | ||
| 638 | } | ||
| 639 | |||
| 624 | void | 640 | void |
| 625 | drawbar(Monitor *m) { | 641 | drawbar(Monitor *m) { |
| 626 | int x; | 642 | int x; |
| @@ -797,10 +813,11 @@ focusin(XEvent *e) { /* there are some broken focus acquiring clients */ | |||
| 797 | 813 | ||
| 798 | void | 814 | void |
| 799 | focusmon(const Arg *arg) { | 815 | focusmon(const Arg *arg) { |
| 800 | Monitor *m; | 816 | Monitor *m = NULL; |
| 801 | 817 | ||
| 802 | if(!(m = idxtomon(arg->ui)) || m == selmon) | 818 | if(!mons->next) |
| 803 | return; | 819 | return; |
| 820 | m = dirtomon(arg->i); | ||
| 804 | unfocus(selmon->sel); | 821 | unfocus(selmon->sel); |
| 805 | selmon = m; | 822 | selmon = m; |
| 806 | focus(NULL); | 823 | focus(NULL); |
| @@ -934,15 +951,6 @@ grabkeys(void) { | |||
| 934 | } | 951 | } |
| 935 | } | 952 | } |
| 936 | 953 | ||
| 937 | Monitor * | ||
| 938 | idxtomon(unsigned int n) { | ||
| 939 | unsigned int i; | ||
| 940 | Monitor *m; | ||
| 941 | |||
| 942 | for(m = mons, i = 0; m && i != n; m = m->next, i++); | ||
| 943 | return m; | ||
| 944 | } | ||
| 945 | |||
| 946 | void | 954 | void |
| 947 | initfont(const char *fontstr) { | 955 | initfont(const char *fontstr) { |
| 948 | char *def, **missing; | 956 | char *def, **missing; |
| @@ -1512,11 +1520,9 @@ tag(const Arg *arg) { | |||
| 1512 | 1520 | ||
| 1513 | void | 1521 | void |
| 1514 | tagmon(const Arg *arg) { | 1522 | tagmon(const Arg *arg) { |
| 1515 | Monitor *m; | 1523 | if(!selmon->sel || !mons->next) |
| 1516 | 1524 | return | |
| 1517 | if(!selmon->sel || !(m = idxtomon(arg->ui))) | 1525 | sendmon(selmon->sel, dirtomon(arg->i)); |
| 1518 | return; | ||
| 1519 | sendmon(selmon->sel, m); | ||
| 1520 | } | 1526 | } |
| 1521 | 1527 | ||
| 1522 | int | 1528 | int |
