summaryrefslogtreecommitdiff
path: root/etc/hostname
blob: 6cf505d3a9283aa7d92abd5ec1abc9bee664a275 (plain)
1
xyzinsp
Bool isprotodel(Client *c) { int i, n; Atom *protocols; Bool ret = False; if(XGetWMProtocols(dpy, c->win, &protocols, &n)) { for(i = 0; !ret && i < n; i++) if(protocols[i] == wmatom[WMDelete]) ret = True; XFree(protocols); } return ret; } Bool isvisible(Client *c, Monitor *m) { unsigned int i; for(i = 0; i < LENGTH(tags); i++) if(c->tags[i] && monitors[c->monitor].seltags[i] && m->id == c->monitor) return True; return False; } void keypress(XEvent *e) { unsigned int i; KeySym keysym; XKeyEvent *ev; ev = &e->xkey; keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); for(i = 0; i < LENGTH(keys); i++) if(keysym == keys[i].keysym && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)) { if(keys[i].func) keys[i].func(keys[i].arg); } } void killclient(const char *arg) { XEvent ev; if(!sel) return; if(isprotodel(sel)) { ev.type = ClientMessage; ev.xclient.window = sel->win; ev.xclient.message_type = wmatom[WMProtocols]; ev.xclient.format = 32; ev.xclient.data.l[0] = wmatom[WMDelete]; ev.xclient.data.l[1] = CurrentTime; XSendEvent(dpy, sel->win, False, NoEventMask, &ev); } else XKillClient(dpy, sel->win); } void leavenotify(XEvent *e) { XCrossingEvent *ev = &e->xcrossing; if((ev->window == root) && !ev->same_screen) { selmonitor = False; focus(NULL); } } void manage(Window w, XWindowAttributes *wa) { Client *c, *t = NULL; Window trans; Status rettrans; XWindowChanges wc; c = emallocz(sizeof(Client)); c->tags = emallocz(sizeof seltags); c->win = w; applyrules(c); Monitor *m = &monitors[c->monitor]; c->x = wa->x+m->sx; c->y = wa->y+m->sy; c->w = wa->width; c->h = wa->height; c->oldborder = wa->border_width; if (monitorat(c->x, c->y) != c->monitor) { c->x = m->sx; c->y = m->sy; } if(c->w == m->sw && c->h == m->sh) { c->x = m->sx; c->y = m->sy; c->border = wa->border_width; } else { if(c->x + c->w + 2 * c->border > m->wax + m->waw) c->x = m->wax + m->waw - c->w - 2 * c->border; if(c->y + c->h + 2 * c->border > m->way + m->wah) c->y = m->way + m->wah - c->h - 2 * c->border; if(c->x < m->wax) c->x = m->wax; if(c->y < m->way) c->y = m->way; c->border = BORDERPX; } wc.border_width = c->border; XConfigureWindow(dpy, w, CWBorderWidth, &wc); XSetWindowBorder(dpy, w, m->dc.norm[ColBorder]); configure(c); /* propagates border_width, if size doesn't change */ updatesizehints(c); XSelectInput(dpy, w, EnterWindowMask | FocusChangeMask | PropertyChangeMask | StructureNotifyMask); grabbuttons(c, False); updatetitle(c); if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success)) for(t = clients; t && t->win != trans; t = t->next); if(t) memcpy(c->tags, t->tags, sizeof seltags); if(!c->isfloating) c->isfloating = (rettrans == Success) || c->isfixed; attach(c); attachstack(c); XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */ ban(c); XMapWindow(dpy, c->win); setclientstate(c, NormalState); arrange(); } void mappingnotify(XEvent *e) { XMappingEvent *ev = &e->xmapping; XRefreshKeyboardMapping(ev); if(ev->request == MappingKeyboard) grabkeys(); } void maprequest(XEvent *e) { static XWindowAttributes wa; XMapRequestEvent *ev = &e->xmaprequest; if(!XGetWindowAttributes(dpy, ev->window, &wa)) return; if(wa.override_redirect) return; if(!getclient(ev->window)) manage(ev->window, &wa); } void maximize(const char *arg) { /* if(!sel || (!sel->isfloating && layout->arrange != floating)) return; resize(sel, wax, way, waw - 2 * sel->border, wah - 2 * sel->border, True); */ } void movemouse(Client *c) { int x1, y1, ocx, ocy, di, nx, ny; unsigned int dui; Window dummy; XEvent ev; ocx = nx = c->x; ocy = ny = c->y; if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, None, cursor[CurMove], CurrentTime) != GrabSuccess) return; XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); for(;;) { XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev); switch (ev.type) { case ButtonRelease: XUngrabPointer(dpy, CurrentTime); return; case ConfigureRequest: case Expose: case MapRequest: handler[ev.type](&ev); break;