170 static void drawtext(const char *text, unsigned long col[ColLast], Bool invert); |
170 static void drawtext(const char *text, unsigned long col[ColLast], Bool invert); |
171 static void enternotify(XEvent *e); |
171 static void enternotify(XEvent *e); |
172 static void expose(XEvent *e); |
172 static void expose(XEvent *e); |
173 static void focus(Client *c); |
173 static void focus(Client *c); |
174 static void focusin(XEvent *e); |
174 static void focusin(XEvent *e); |
|
175 static void focusmon(const Arg *arg); |
175 static void focusstack(const Arg *arg); |
176 static void focusstack(const Arg *arg); |
176 static unsigned long getcolor(const char *colstr); |
177 static unsigned long getcolor(const char *colstr); |
177 static Bool getrootpointer(int *x, int *y); |
178 static Bool getrootpointer(int *x, int *y); |
178 static long getstate(Window w); |
179 static long getstate(Window w); |
179 static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); |
180 static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); |
180 static void grabbuttons(Client *c, Bool focused); |
181 static void grabbuttons(Client *c, Bool focused); |
181 static void grabkeys(void); |
182 static void grabkeys(void); |
|
183 static Monitor *idxtomon(unsigned int n); |
182 static void initfont(const char *fontstr); |
184 static void initfont(const char *fontstr); |
183 static Bool isprotodel(Client *c); |
185 static Bool isprotodel(Client *c); |
184 static void keypress(XEvent *e); |
186 static void keypress(XEvent *e); |
185 static void killclient(const Arg *arg); |
187 static void killclient(const Arg *arg); |
186 static void manage(Window w, XWindowAttributes *wa); |
188 static void manage(Window w, XWindowAttributes *wa); |
204 static void setup(void); |
206 static void setup(void); |
205 static void showhide(Client *c); |
207 static void showhide(Client *c); |
206 static void sigchld(int signal); |
208 static void sigchld(int signal); |
207 static void spawn(const Arg *arg); |
209 static void spawn(const Arg *arg); |
208 static void tag(const Arg *arg); |
210 static void tag(const Arg *arg); |
|
211 static void tagmon(const Arg *arg); |
209 static int textnw(const char *text, unsigned int len); |
212 static int textnw(const char *text, unsigned int len); |
210 static void tile(Monitor *); |
213 static void tile(Monitor *); |
211 static void togglebar(const Arg *arg); |
214 static void togglebar(const Arg *arg); |
212 static void togglefloating(const Arg *arg); |
215 static void togglefloating(const Arg *arg); |
213 static void toggletag(const Arg *arg); |
216 static void toggletag(const Arg *arg); |
228 static Monitor *wintomon(Window w); |
231 static Monitor *wintomon(Window w); |
229 static int xerror(Display *dpy, XErrorEvent *ee); |
232 static int xerror(Display *dpy, XErrorEvent *ee); |
230 static int xerrordummy(Display *dpy, XErrorEvent *ee); |
233 static int xerrordummy(Display *dpy, XErrorEvent *ee); |
231 static int xerrorstart(Display *dpy, XErrorEvent *ee); |
234 static int xerrorstart(Display *dpy, XErrorEvent *ee); |
232 static void zoom(const Arg *arg); |
235 static void zoom(const Arg *arg); |
233 #ifdef XINERAMA |
|
234 static void focusmon(const Arg *arg); |
|
235 static Monitor *idxtomon(unsigned int n); |
|
236 static void tagmon(const Arg *arg); |
|
237 #endif /* XINERAMA */ |
|
238 |
236 |
239 /* variables */ |
237 /* variables */ |
240 static char stext[256]; |
238 static char stext[256]; |
241 static int screen; |
239 static int screen; |
242 static int sw, sh; /* X display screen geometry x, y, width, height */ |
240 static int sw, sh; /* X display screen geometry x, y, width, height */ |
307 /* set minimum possible */ |
305 /* set minimum possible */ |
308 *w = MAX(1, *w); |
306 *w = MAX(1, *w); |
309 *h = MAX(1, *h); |
307 *h = MAX(1, *h); |
310 |
308 |
311 if(*x > m->mx + m->mw) |
309 if(*x > m->mx + m->mw) |
312 *x = m->mw - WIDTH(c); |
310 *x = m->mx + m->mw - WIDTH(c); |
313 if(*y > m->my + m->mh) |
311 if(*y > m->my + m->mh) |
314 *y = m->mh - HEIGHT(c); |
312 *y = m->my + m->mh - HEIGHT(c); |
315 if(*x + *w + 2 * c->bw < m->mx) |
313 if(*x + *w + 2 * c->bw < m->mx) |
316 *x = m->mx; |
314 *x = m->mx; |
317 if(*y + *h + 2 * c->bw < m->my) |
315 if(*y + *h + 2 * c->bw < m->my) |
318 *y = m->my; |
316 *y = m->my; |
319 if(*h < bh) |
317 if(*h < bh) |
634 if(c->isurgent) |
632 if(c->isurgent) |
635 urg |= c->tags; |
633 urg |= c->tags; |
636 } |
634 } |
637 |
635 |
638 dc.x = 0; |
636 dc.x = 0; |
639 #ifdef XINERAMA |
|
640 if(mons->next) { /* more than a single monitor */ |
637 if(mons->next) { /* more than a single monitor */ |
641 char buf[2]; |
638 char buf[2]; |
642 buf[0] = m->screen_number + '0'; |
639 buf[0] = m->screen_number + '0'; |
643 buf[1] = '\0'; |
640 buf[1] = '\0'; |
644 dc.w = TEXTW(buf); |
641 dc.w = TEXTW(buf); |
645 drawtext(buf, selmon == m ? dc.sel : dc.norm, True); |
642 drawtext(buf, selmon == m ? dc.sel : dc.norm, True); |
646 dc.x += dc.w; |
643 dc.x += dc.w; |
647 } |
644 } |
648 #endif /* XINERAMA */ |
|
649 m->btx = dc.x; |
645 m->btx = dc.x; |
650 for(i = 0; i < LENGTH(tags); i++) { |
646 for(i = 0; i < LENGTH(tags); i++) { |
651 dc.w = TEXTW(tags[i]); |
647 dc.w = TEXTW(tags[i]); |
652 col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm; |
648 col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm; |
653 drawtext(tags[i], col, urg & 1 << i); |
649 drawtext(tags[i], col, urg & 1 << i); |
801 |
797 |
802 if(selmon->sel && ev->window != selmon->sel->win) |
798 if(selmon->sel && ev->window != selmon->sel->win) |
803 XSetInputFocus(dpy, selmon->sel->win, RevertToPointerRoot, CurrentTime); |
799 XSetInputFocus(dpy, selmon->sel->win, RevertToPointerRoot, CurrentTime); |
804 } |
800 } |
805 |
801 |
806 #ifdef XINERAMA |
|
807 void |
802 void |
808 focusmon(const Arg *arg) { |
803 focusmon(const Arg *arg) { |
809 Monitor *m; |
804 Monitor *m; |
810 |
805 |
811 if(!(m = idxtomon(arg->ui)) || m == selmon) |
806 if(!(m = idxtomon(arg->ui)) || m == selmon) |
812 return; |
807 return; |
813 unfocus(selmon->sel); |
808 unfocus(selmon->sel); |
814 selmon = m; |
809 selmon = m; |
815 focus(NULL); |
810 focus(NULL); |
816 } |
811 } |
817 #endif /* XINERAMA */ |
|
818 |
812 |
819 void |
813 void |
820 focusstack(const Arg *arg) { |
814 focusstack(const Arg *arg) { |
821 Client *c = NULL, *i; |
815 Client *c = NULL, *i; |
822 |
816 |
941 True, GrabModeAsync, GrabModeAsync); |
935 True, GrabModeAsync, GrabModeAsync); |
942 } |
936 } |
943 } |
937 } |
944 } |
938 } |
945 |
939 |
946 #ifdef XINERAMA |
|
947 Monitor * |
940 Monitor * |
948 idxtomon(unsigned int n) { |
941 idxtomon(unsigned int n) { |
949 unsigned int i; |
942 unsigned int i; |
950 Monitor *m; |
943 Monitor *m; |
951 |
944 |
952 for(m = mons, i = 0; m && i != n; m = m->next, i++); |
945 for(m = mons, i = 0; m && i != n; m = m->next, i++); |
953 return m; |
946 return m; |
954 } |
947 } |
955 #endif /* XINERAMA */ |
|
956 |
948 |
957 void |
949 void |
958 initfont(const char *fontstr) { |
950 initfont(const char *fontstr) { |
959 char *def, **missing; |
951 char *def, **missing; |
960 int i, n; |
952 int i, n; |
1529 selmon->sel->tags = arg->ui & TAGMASK; |
1522 selmon->sel->tags = arg->ui & TAGMASK; |
1530 arrange(); |
1523 arrange(); |
1531 } |
1524 } |
1532 } |
1525 } |
1533 |
1526 |
1534 #ifdef XINERAMA |
|
1535 void |
1527 void |
1536 tagmon(const Arg *arg) { |
1528 tagmon(const Arg *arg) { |
1537 Monitor *m; |
1529 Monitor *m; |
1538 |
1530 |
1539 if(!selmon->sel || !(m = idxtomon(arg->ui))) |
1531 if(!selmon->sel || !(m = idxtomon(arg->ui))) |
1540 return; |
1532 return; |
1541 sendmon(selmon->sel, m); |
1533 sendmon(selmon->sel, m); |
1542 } |
1534 } |
1543 #endif /* XINERAMA */ |
|
1544 |
1535 |
1545 int |
1536 int |
1546 textnw(const char *text, unsigned int len) { |
1537 textnw(const char *text, unsigned int len) { |
1547 XRectangle r; |
1538 XRectangle r; |
1548 |
1539 |