174 static void focus(Client *c); |
174 static void focus(Client *c); |
175 static void focusin(XEvent *e); |
175 static void focusin(XEvent *e); |
176 static void focusstack(const Arg *arg); |
176 static void focusstack(const Arg *arg); |
177 static Client *getclient(Window w); |
177 static Client *getclient(Window w); |
178 static unsigned long getcolor(const char *colstr); |
178 static unsigned long getcolor(const char *colstr); |
179 static Monitor *getmonitor(Window w); |
179 static Monitor *getmon(Window w); |
180 static Monitor *getmonitorxy(int x, int y); |
180 static Monitor *getmonxy(int x, int y); |
181 static Bool getrootpointer(int *x, int *y); |
181 static Bool getrootpointer(int *x, int *y); |
182 static long getstate(Window w); |
182 static long getstate(Window w); |
183 static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); |
183 static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); |
184 static void grabbuttons(Client *c, Bool focused); |
184 static void grabbuttons(Client *c, Bool focused); |
185 static void grabkeys(void); |
185 static void grabkeys(void); |
399 Monitor *m; |
399 Monitor *m; |
400 XButtonPressedEvent *ev = &e->xbutton; |
400 XButtonPressedEvent *ev = &e->xbutton; |
401 |
401 |
402 click = ClkRootWin; |
402 click = ClkRootWin; |
403 /* focus monitor if necessary */ |
403 /* focus monitor if necessary */ |
404 if((m = getmonitor(ev->window)) && m != selmon) { |
404 if((m = getmon(ev->window)) && m != selmon) { |
405 unfocus(selmon->sel); |
405 unfocus(selmon->sel); |
406 selmon = m; |
406 selmon = m; |
407 focus(NULL); |
407 focus(NULL); |
408 } |
408 } |
409 if(ev->window == selmon->barwin && ev->x >= selmon->btx) { |
409 if(ev->window == selmon->barwin && ev->x >= selmon->btx) { |
745 Monitor *m; |
745 Monitor *m; |
746 XCrossingEvent *ev = &e->xcrossing; |
746 XCrossingEvent *ev = &e->xcrossing; |
747 |
747 |
748 if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root) |
748 if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root) |
749 return; |
749 return; |
750 if((m = getmonitor(ev->window)) && m != selmon) { |
750 if((m = getmon(ev->window)) && m != selmon) { |
751 unfocus(selmon->sel); |
751 unfocus(selmon->sel); |
752 selmon = m; |
752 selmon = m; |
753 } |
753 } |
754 if((c = getclient(ev->window))) |
754 if((c = getclient(ev->window))) |
755 focus(c); |
755 focus(c); |
862 die("error, cannot allocate color '%s'\n", colstr); |
862 die("error, cannot allocate color '%s'\n", colstr); |
863 return color.pixel; |
863 return color.pixel; |
864 } |
864 } |
865 |
865 |
866 Monitor * |
866 Monitor * |
867 getmonitor(Window w) { |
867 getmon(Window w) { |
868 int x, y; |
868 int x, y; |
869 Client *c; |
869 Client *c; |
870 Monitor *m; |
870 Monitor *m; |
871 |
871 |
872 if(w == root && getrootpointer(&x, &y)) |
872 if(w == root && getrootpointer(&x, &y)) |
873 return getmonitorxy(x, y); |
873 return getmonxy(x, y); |
874 for(m = mons; m; m = m->next) |
874 for(m = mons; m; m = m->next) |
875 if(w == m->barwin) |
875 if(w == m->barwin) |
876 return m; |
876 return m; |
877 if((c = getclient(w))) |
877 if((c = getclient(w))) |
878 return c->mon; |
878 return c->mon; |
879 return NULL; |
879 return NULL; |
880 } |
880 } |
881 |
881 |
882 Monitor * |
882 Monitor * |
883 getmonitorxy(int x, int y) { |
883 getmonxy(int x, int y) { |
884 Monitor *m; |
884 Monitor *m; |
885 |
885 |
886 for(m = mons; m; m = m->next) |
886 for(m = mons; m; m = m->next) |
887 if(INRECT(x, y, m->wx, m->wy, m->ww, m->wh)) |
887 if(INRECT(x, y, m->wx, m->wy, m->ww, m->wh)) |
888 return m; |
888 return m; |
1312 } |
1312 } |
1313 while(ev.type != ButtonRelease); |
1313 while(ev.type != ButtonRelease); |
1314 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); |
1314 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); |
1315 XUngrabPointer(dpy, CurrentTime); |
1315 XUngrabPointer(dpy, CurrentTime); |
1316 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); |
1316 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); |
1317 if((m = getmonitorxy(c->x + c->w / 2, c->y + c->h / 2)) != selmon) |
1317 if((m = getmonxy(c->x + c->w / 2, c->y + c->h / 2)) != selmon) |
1318 sendmon(c, m); |
1318 sendmon(c, m); |
1319 } |
1319 } |
1320 |
1320 |
1321 void |
1321 void |
1322 restack(Monitor *m) { |
1322 restack(Monitor *m) { |