This patch adds any windows that are completely obscured by other windows to the menu of currently hidden windows. I've found this very useful. When I lose track of a window it doesn't matter to me whether I intentionally hid it or it just became obscured, I just want to bring it back easily with the mouse.
Index: calmwm.h =================================================================== RCS file: /cvs/xenocara/app/cwm/calmwm.h,v retrieving revision 1.292 diff -u -p -r1.292 calmwm.h --- calmwm.h 9 Jun 2015 13:02:15 -0000 1.292 +++ calmwm.h 19 Jun 2015 11:52:25 -0000 @@ -187,6 +187,7 @@ struct client_ctx { #define CLIENT_FULLSCREEN 0x0800 #define CLIENT_STICKY 0x1000 #define CLIENT_ACTIVE 0x2000 +#define CLIENT_OBSCURED 0x4000 #define CLIENT_HIGHLIGHT (CLIENT_GROUP | CLIENT_UNGROUP) #define CLIENT_MAXFLAGS (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED) Index: client.c =================================================================== RCS file: /cvs/xenocara/app/cwm/client.c,v retrieving revision 1.193 diff -u -p -r1.193 client.c --- client.c 8 Jun 2015 15:11:29 -0000 1.193 +++ client.c 19 Jun 2015 11:52:25 -0000 @@ -115,7 +115,7 @@ client_init(Window win, struct screen_ct } XSelectInput(X_Dpy, cc->win, ColormapChangeMask | EnterWindowMask | - PropertyChangeMask | KeyReleaseMask); + PropertyChangeMask | KeyReleaseMask | VisibilityChangeMask); XAddToSaveSet(X_Dpy, cc->win); Index: mousefunc.c =================================================================== RCS file: /cvs/xenocara/app/cwm/mousefunc.c,v retrieving revision 1.91 diff -u -p -r1.91 mousefunc.c --- mousefunc.c 8 Jun 2015 15:41:27 -0000 1.91 +++ mousefunc.c 19 Jun 2015 11:52:25 -0000 @@ -209,7 +209,7 @@ mousefunc_menu_unhide(struct client_ctx TAILQ_INIT(&menuq); TAILQ_FOREACH(cc, &sc->clientq, entry) { - if (cc->flags & CLIENT_HIDDEN) { + if (cc->flags & (CLIENT_HIDDEN|CLIENT_OBSCURED)) { menuq_add(&menuq, cc, NULL); } } Index: xevents.c =================================================================== RCS file: /cvs/xenocara/app/cwm/xevents.c,v retrieving revision 1.116 diff -u -p -r1.116 xevents.c --- xevents.c 19 Jan 2015 14:54:16 -0000 1.116 +++ xevents.c 19 Jun 2015 11:52:25 -0000 @@ -51,6 +51,7 @@ static void xev_handle_clientmessage(XE static void xev_handle_randr(XEvent *); static void xev_handle_mappingnotify(XEvent *); static void xev_handle_expose(XEvent *); +static void xev_handle_visibilitynotify(XEvent *); void (*xev_handlers[LASTEvent])(XEvent *) = { [MapRequest] = xev_handle_maprequest, @@ -66,6 +67,7 @@ void (*xev_handlers[LASTEvent])(XEvent [ClientMessage] = xev_handle_clientmessage, [MappingNotify] = xev_handle_mappingnotify, [Expose] = xev_handle_expose, + [VisibilityNotify] = xev_handle_visibilitynotify, }; static KeySym modkeys[] = { XK_Alt_L, XK_Alt_R, XK_Super_L, XK_Super_R, @@ -404,6 +406,20 @@ xev_handle_expose(XEvent *ee) if ((cc = client_find(e->window)) != NULL && e->count == 0) client_draw_border(cc); +} + +static void +xev_handle_visibilitynotify(XEvent *ee) +{ + XVisibilityEvent *e = &ee->xvisibility; + struct client_ctx *cc; + + if ((cc = client_find(e->window)) != NULL) { + if (e->state == VisibilityFullyObscured) + cc->flags |= CLIENT_OBSCURED; + else if (cc->flags & CLIENT_OBSCURED) + cc->flags &= ~CLIENT_OBSCURED; + } } void