aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R Garbe <anselm@garbe.us>2009-06-27 18:50:50 +0100
committerAnselm R Garbe <anselm@garbe.us>2009-06-27 18:50:50 +0100
commit029655bb2271a18d3a191f22502cbd9b713a9189 (patch)
treece6bc8068cc81ab706186b374ab042ca8eebd4fc
parent27db9d44489fea54275de9d25a9eff7118ebb3ea (diff)
downloaddwm-029655bb2271a18d3a191f22502cbd9b713a9189.tar.gz
some cleanup handling for index based mon search
-rw-r--r--dwm.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/dwm.c b/dwm.c
index 5934a6c..04fcc90 100644
--- a/dwm.c
+++ b/dwm.c
@@ -177,6 +177,7 @@ static void focusstack(const Arg *arg);
static Client *getclient(Window w);
static unsigned long getcolor(const char *colstr);
static Monitor *getmon(Window w);
+static Monitor *getmonn(unsigned int n);
static Monitor *getmonxy(int x, int y);
static Bool getrootpointer(int *x, int *y);
static long getstate(Window w);
@@ -800,18 +801,13 @@ focusin(XEvent *e) { /* there are some broken focus acquiring clients */
#ifdef XINERAMA
void
focusmon(const Arg *arg) {
- unsigned int i;
- Monitor *m;
-
- for(i = 0, m = mons; m; m = m->next, i++)
- if(i == arg->ui) {
- if(m == selmon)
- return;
- unfocus(selmon->sel);
- selmon = m;
- focus(NULL);
- break;
- }
+ Monitor *m;
+
+ if(!(m = getmonn(arg->ui)) || m == selmon)
+ return;
+ unfocus(selmon->sel);
+ selmon = m;
+ focus(NULL);
}
#endif /* XINERAMA */
@@ -880,6 +876,15 @@ getmon(Window w) {
}
Monitor *
+getmonn(unsigned int n) {
+ unsigned int i;
+ Monitor *m;
+
+ for(m = mons, i = 0; m && i != n; m = m->next, i++);
+ return m;
+}
+
+Monitor *
getmonxy(int x, int y) {
Monitor *m;
@@ -1542,17 +1547,11 @@ tag(const Arg *arg) {
#ifdef XINERAMA
void
tagmon(const Arg *arg) {
- unsigned int i;
- Client *c;
Monitor *m;
- if(!(c = selmon->sel))
+ if(!selmon->sel || !(m = getmonn(arg->ui)))
return;
- for(i = 0, m = mons; m; m = m->next, i++)
- if(i == arg->ui) {
- sendmon(c, m);
- break;
- }
+ sendmon(selmon->sel, m);
}
#endif /* XINERAMA */