dwm.c
changeset 1485 3cde8e2dc511
parent 1484 487ed0f2e51d
child 1486 fd99ee49c58e
equal deleted inserted replaced
1484:487ed0f2e51d 1485:3cde8e2dc511
   216 static void togglebar(const Arg *arg);
   216 static void togglebar(const Arg *arg);
   217 static void togglefloating(const Arg *arg);
   217 static void togglefloating(const Arg *arg);
   218 static void toggletag(const Arg *arg);
   218 static void toggletag(const Arg *arg);
   219 static void toggleview(const Arg *arg);
   219 static void toggleview(const Arg *arg);
   220 static void unfocus(Client *c);
   220 static void unfocus(Client *c);
   221 static void unmanage(Client *c);
   221 static void unmanage(Client *c, Bool isdestroyed);
   222 static void unmapnotify(XEvent *e);
   222 static void unmapnotify(XEvent *e);
   223 static void updategeom(void);
   223 static void updategeom(void);
   224 static void updatebarpos(Monitor *m);
   224 static void updatebarpos(Monitor *m);
   225 static void updatebars(void);
   225 static void updatebars(void);
   226 static void updatenumlockmask(void);
   226 static void updatenumlockmask(void);
   464 
   464 
   465 	view(&a);
   465 	view(&a);
   466 	selmon->lt[selmon->sellt] = &foo;
   466 	selmon->lt[selmon->sellt] = &foo;
   467 	for(m = mons; m; m = m->next)
   467 	for(m = mons; m; m = m->next)
   468 		while(m->stack)
   468 		while(m->stack)
   469 			unmanage(m->stack);
   469 			unmanage(m->stack, False);
   470 	if(dc.font.set)
   470 	if(dc.font.set)
   471 		XFreeFontSet(dpy, dc.font.set);
   471 		XFreeFontSet(dpy, dc.font.set);
   472 	else
   472 	else
   473 		XFreeFont(dpy, dc.font.xfont);
   473 		XFreeFont(dpy, dc.font.xfont);
   474 	XUngrabKey(dpy, AnyKey, AnyModifier, root);
   474 	XUngrabKey(dpy, AnyKey, AnyModifier, root);
   593 destroynotify(XEvent *e) {
   593 destroynotify(XEvent *e) {
   594 	Client *c;
   594 	Client *c;
   595 	XDestroyWindowEvent *ev = &e->xdestroywindow;
   595 	XDestroyWindowEvent *ev = &e->xdestroywindow;
   596 
   596 
   597 	if((c = wintoclient(ev->window)))
   597 	if((c = wintoclient(ev->window)))
   598 		unmanage(c);
   598 		unmanage(c, True);
   599 }
   599 }
   600 
   600 
   601 void
   601 void
   602 detach(Client *c) {
   602 detach(Client *c) {
   603 	Client **tc;
   603 	Client **tc;
  1624 	XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
  1624 	XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
  1625 	XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
  1625 	XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
  1626 }
  1626 }
  1627 
  1627 
  1628 void
  1628 void
  1629 unmanage(Client *c) {
  1629 unmanage(Client *c, Bool isdestroyed) {
  1630 	XWindowChanges wc;
  1630 	XWindowChanges wc;
  1631 
  1631 
  1632 	wc.border_width = c->oldbw;
       
  1633 	/* The server grab construct avoids race conditions. */
  1632 	/* The server grab construct avoids race conditions. */
  1634 	XGrabServer(dpy);
       
  1635 	XSetErrorHandler(xerrordummy);
       
  1636 	XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
       
  1637 	detach(c);
  1633 	detach(c);
  1638 	detachstack(c);
  1634 	detachstack(c);
  1639 	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
  1635 	if(!isdestroyed) {
  1640 	setclientstate(c, WithdrawnState);
  1636 		wc.border_width = c->oldbw;
       
  1637 		XGrabServer(dpy);
       
  1638 		XSetErrorHandler(xerrordummy);
       
  1639 		XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
       
  1640 		XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
       
  1641 		setclientstate(c, WithdrawnState);
       
  1642 		XSync(dpy, False);
       
  1643 		XSetErrorHandler(xerror);
       
  1644 		XUngrabServer(dpy);
       
  1645 	}
  1641 	free(c);
  1646 	free(c);
  1642 	XSync(dpy, False);
       
  1643 	XSetErrorHandler(xerror);
       
  1644 	XUngrabServer(dpy);
       
  1645 	focus(NULL);
  1647 	focus(NULL);
  1646 	arrange();
       
  1647 }
  1648 }
  1648 
  1649 
  1649 void
  1650 void
  1650 unmapnotify(XEvent *e) {
  1651 unmapnotify(XEvent *e) {
  1651 	Client *c;
  1652 	Client *c;
  1652 	XUnmapEvent *ev = &e->xunmap;
  1653 	XUnmapEvent *ev = &e->xunmap;
  1653 
  1654 
  1654 	if((c = wintoclient(ev->window)))
  1655 	if((c = wintoclient(ev->window)))
  1655 		unmanage(c);
  1656 		unmanage(c, False);
  1656 }
  1657 }
  1657 
  1658 
  1658 void
  1659 void
  1659 updatebars(void) {
  1660 updatebars(void) {
  1660 	Monitor *m;
  1661 	Monitor *m;