void button(XButtonEvent * e) { int n, shift; Client *c; Window dw; ScreenInfo *s; curtime = e->time; s = getscreen(e->root); if (s == 0) return; c = getclient(e->window, 0); if (c) { e->x += c->x - BORDER + 1; e->y += c->y - BORDER + 1; } else if (e->window != e->root) XTranslateCoordinates(dpy, e->window, s->root, e->x, e->y, &e->x, &e->y, &dw); switch (e->button) { case Button1: if (c) { XMapRaised(dpy, c->parent); top(c); active(c); } return; case Button2: if ((e->state & (ShiftMask | ControlMask)) == (ShiftMask | ControlMask)) { menuhit(e, &egg); } else { spawn(s, "9wm-mm"); } return; default: return; case Button3: break; } if (current && current->screen == s) cmapnofocus(s); switch (n = menuhit(e, &b3menu)) { case 0: /* New */ spawn(s, termprog); break; case 1: /* Reshape */ reshape(selectwin(1, 0, s)); break; case 2: /* Move */ move(selectwin(0, 0, s)); break; case 3: /* Delete */ shift = 0; c = selectwin(1, &shift, s); delete(c, shift); break; case 4: /* Hide */ hide(selectwin(1, 0, s)); break; default: /* unhide window */ unhide(n - B3FIXED, 1); break; case -1: /* nothing */ break; } if (current && current->screen == s) cmapfocus(current); }
void button(XButtonEvent *e) { int n, shift; Client *c; Window dw; ScreenInfo *s; curtime = e->time; s = getscreen(e->root); if(s == 0) return; c = getclient(e->window, 0); if(c) { if(debug) fprintf(stderr, "but: e x=%d y=%d c x=%d y=%d dx=%d dy=%d BORDR %d\n", e->x, e->y, c->x, c->y, c->dx, c->dy, BORDER); if(borderorient(c, e->x, e->y) != BorderUnknown) { switch (e->button) { case Button1: case Button2: reshape(c, e->button, pull, e); return; case Button3: move(c, Button3); return; default: return; } } e->x += c->x - BORDER; e->y += c->y - BORDER; } else if(e->window != e->root) { if(debug) fprintf(stderr, "but no client: e x=%d y=%d\n", e->x, e->y); XTranslateCoordinates(dpy, e->window, s->root, e->x, e->y, &e->x, &e->y, &dw); } switch (e->button) { case Button1: if(c) { XMapRaised(dpy, c->parent); top(c); active(c); } return; case Button2: if(c) { XMapRaised(dpy, c->parent); active(c); XAllowEvents (dpy, ReplayPointer, curtime); } else if((e->state&(ShiftMask|ControlMask))==(ShiftMask|ControlMask)) { menuhit(e, &egg); } else if(numvirtuals > 1 && (n = menuhit(e, &b2menu)) > -1) button2(n); return; case Button3: break; case Button4: /* scroll up changes to previous virtual screen */ if(!c && e->type == ButtonPress) if(numvirtuals > 1 && virt > 0) switch_to(virt - 1); return; case Button5: /* scroll down changes to next virtual screen */ if(!c && e->type == ButtonPress) if(numvirtuals > 1 && virt < numvirtuals - 1) switch_to(virt + 1); return; default: return; } if(current && current->screen == s) cmapnofocus(s); switch (n = menuhit(e, &b3menu)) { case New: spawn(s, termFn); break; case Acme: spawn(s, editorFn); break; case Launcher: spawn(s, launcherFn); break; case Reshape: reshape(selectwin(1, 0, s), Button3, sweep, 0); break; case Move: move(selectwin(0, 0, s), Button3); break; case Delete: shift = 0; c = selectwin(1, &shift, s); delete(c, shift); break; case Hide: hide(selectwin(1, 0, s)); break; default: /* unhide window */ unhide(n - B3FIXED, 1); break; case -1: /* nothing */ break; } if(current && current->screen == s) cmapfocus(current); }