summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorAnselm R Garbe <anselm@garbe.us>2009-07-02 20:37:26 +0100
committerAnselm R Garbe <anselm@garbe.us>2009-07-02 20:37:26 +0100
commita9e145fe6d8af4848e6706131ac41e99003cd997 (patch)
tree22406d3f4e1032f93817228436fc6ba8a06a8f6b /dwm.c
parentremoved some empty lines (diff)
downloaddwm-a9e145fe6d8af4848e6706131ac41e99003cd997.tar.gz
dwm-a9e145fe6d8af4848e6706131ac41e99003cd997.zip
changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.
Diffstat (limited to '')
-rw-r--r--dwm.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/dwm.c b/dwm.c
index d47da3f..613a029 100644
--- a/dwm.c
+++ b/dwm.c
@@ -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);
164static void detach(Client *c); 164static void detach(Client *c);
165static void detachstack(Client *c); 165static void detachstack(Client *c);
166static void die(const char *errstr, ...); 166static void die(const char *errstr, ...);
167static Monitor *dirtomon(int dir);
167static void drawbar(Monitor *m); 168static void drawbar(Monitor *m);
168static void drawbars(void); 169static void drawbars(void);
169static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]); 170static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
@@ -180,7 +181,6 @@ static long getstate(Window w);
180static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); 181static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
181static void grabbuttons(Client *c, Bool focused); 182static void grabbuttons(Client *c, Bool focused);
182static void grabkeys(void); 183static void grabkeys(void);
183static Monitor *idxtomon(unsigned int n);
184static void initfont(const char *fontstr); 184static void initfont(const char *fontstr);
185static Bool isprotodel(Client *c); 185static Bool isprotodel(Client *c);
186static void keypress(XEvent *e); 186static void keypress(XEvent *e);
@@ -621,6 +621,22 @@ die(const char *errstr, ...) {
621 exit(EXIT_FAILURE); 621 exit(EXIT_FAILURE);
622} 622}
623 623
624Monitor *
625dirtomon(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
624void 640void
625drawbar(Monitor *m) { 641drawbar(Monitor *m) {
626 int x; 642 int x;
@@ -797,10 +813,11 @@ focusin(XEvent *e) { /* there are some broken focus acquiring clients */
797 813
798void 814void
799focusmon(const Arg *arg) { 815focusmon(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
937Monitor *
938idxtomon(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
946void 954void
947initfont(const char *fontstr) { 955initfont(const char *fontstr) {
948 char *def, **missing; 956 char *def, **missing;
@@ -1512,11 +1520,9 @@ tag(const Arg *arg) {
1512 1520
1513void 1521void
1514tagmon(const Arg *arg) { 1522tagmon(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
1522int 1528int