bar_wintitleactions.c (1910B)
1 void 2 hide(Client *c) { 3 4 Client *n; 5 if (!c || HIDDEN(c)) 6 return; 7 8 Window w = c->win; 9 static XWindowAttributes ra, ca; 10 11 // more or less taken directly from blackbox's hide() function 12 XGrabServer(dpy); 13 XGetWindowAttributes(dpy, root, &ra); 14 XGetWindowAttributes(dpy, w, &ca); 15 // prevent UnmapNotify events 16 XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask); 17 XSelectInput(dpy, w, ca.your_event_mask & ~StructureNotifyMask); 18 XUnmapWindow(dpy, w); 19 setclientstate(c, IconicState); 20 XSelectInput(dpy, root, ra.your_event_mask); 21 XSelectInput(dpy, w, ca.your_event_mask); 22 XUngrabServer(dpy); 23 24 if (c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) { 25 for (n = c->snext; n && (!ISVISIBLE(n) || HIDDEN(n)); n = n->snext); 26 if (!n) 27 for (n = c->mon->stack; n && (!ISVISIBLE(n) || HIDDEN(n)); n = n->snext); 28 } else { 29 n = nexttiled(c); 30 if (!n) 31 n = prevtiled(c); 32 } 33 focus(n); 34 arrange(c->mon); 35 } 36 37 void 38 show(Client *c) 39 { 40 if (!c || !HIDDEN(c)) 41 return; 42 43 XMapWindow(dpy, c->win); 44 setclientstate(c, NormalState); 45 arrange(c->mon); 46 } 47 48 void 49 togglewin(const Arg *arg) 50 { 51 Client *c = (Client*)arg->v; 52 if (!c) 53 return; 54 if (!HIDDEN(c) && c == selmon->sel) 55 hide(c); 56 else { 57 if (HIDDEN(c)) 58 show(c); 59 focus(c); 60 restack(c->mon); 61 } 62 } 63 64 Client * 65 prevtiled(Client *c) 66 { 67 Client *p, *i; 68 for (p = NULL, i = c->mon->clients; c && i != c; i = i->next) 69 if (ISVISIBLE(i) && !HIDDEN(i)) 70 p = i; 71 return p; 72 } 73 74 void 75 showhideclient(const Arg *arg) 76 { 77 Client *c = (Client*)arg->v; 78 if (!c) 79 c = selmon->sel; 80 if (!c) 81 return; 82 83 #if WARP_PATCH 84 force_warp = 1; 85 #endif // WARP_PATCH 86 if (HIDDEN(c)) { 87 show(c); 88 focus(c); 89 restack(c->mon); 90 } else { 91 hide(c); 92 } 93 } 94 95 void 96 unhideall(const Arg *arg) 97 { 98 Client *c = NULL; 99 for (c = selmon->clients; c; c = c->next) { 100 if (ISVISIBLE(c)) { 101 XMapWindow(dpy, c->win); 102 setclientstate(c, NormalState); 103 } 104 } 105 arrange(selmon); 106 }