some cleanup handling for index based mon search
029655bb
1 file(s) · +18 −19
| 177 | 177 | static Client *getclient(Window w); |
|
| 178 | 178 | static unsigned long getcolor(const char *colstr); |
|
| 179 | 179 | static Monitor *getmon(Window w); |
|
| 180 | + | static Monitor *getmonn(unsigned int n); |
|
| 180 | 181 | static Monitor *getmonxy(int x, int y); |
|
| 181 | 182 | static Bool getrootpointer(int *x, int *y); |
|
| 182 | 183 | static long getstate(Window w); |
|
| 800 | 801 | #ifdef XINERAMA |
|
| 801 | 802 | void |
|
| 802 | 803 | focusmon(const Arg *arg) { |
|
| 803 | - | unsigned int i; |
|
| 804 | - | Monitor *m; |
|
| 804 | + | Monitor *m; |
|
| 805 | 805 | ||
| 806 | - | for(i = 0, m = mons; m; m = m->next, i++) |
|
| 807 | - | if(i == arg->ui) { |
|
| 808 | - | if(m == selmon) |
|
| 809 | - | return; |
|
| 810 | - | unfocus(selmon->sel); |
|
| 811 | - | selmon = m; |
|
| 812 | - | focus(NULL); |
|
| 813 | - | break; |
|
| 814 | - | } |
|
| 806 | + | if(!(m = getmonn(arg->ui)) || m == selmon) |
|
| 807 | + | return; |
|
| 808 | + | unfocus(selmon->sel); |
|
| 809 | + | selmon = m; |
|
| 810 | + | focus(NULL); |
|
| 815 | 811 | } |
|
| 816 | 812 | #endif /* XINERAMA */ |
|
| 817 | 813 | ||
| 880 | 876 | } |
|
| 881 | 877 | ||
| 882 | 878 | Monitor * |
|
| 879 | + | getmonn(unsigned int n) { |
|
| 880 | + | unsigned int i; |
|
| 881 | + | Monitor *m; |
|
| 882 | + | ||
| 883 | + | for(m = mons, i = 0; m && i != n; m = m->next, i++); |
|
| 884 | + | return m; |
|
| 885 | + | } |
|
| 886 | + | ||
| 887 | + | Monitor * |
|
| 883 | 888 | getmonxy(int x, int y) { |
|
| 884 | 889 | Monitor *m; |
|
| 885 | 890 | ||
| 1542 | 1547 | #ifdef XINERAMA |
|
| 1543 | 1548 | void |
|
| 1544 | 1549 | tagmon(const Arg *arg) { |
|
| 1545 | - | unsigned int i; |
|
| 1546 | - | Client *c; |
|
| 1547 | 1550 | Monitor *m; |
|
| 1548 | 1551 | ||
| 1549 | - | if(!(c = selmon->sel)) |
|
| 1552 | + | if(!selmon->sel || !(m = getmonn(arg->ui))) |
|
| 1550 | 1553 | return; |
|
| 1551 | - | for(i = 0, m = mons; m; m = m->next, i++) |
|
| 1552 | - | if(i == arg->ui) { |
|
| 1553 | - | sendmon(c, m); |
|
| 1554 | - | break; |
|
| 1555 | - | } |
|
| 1554 | + | sendmon(selmon->sel, m); |
|
| 1556 | 1555 | } |
|
| 1557 | 1556 | #endif /* XINERAMA */ |
|
| 1558 | 1557 | ||