URI:
       tlsw: added -i switch to list ignored window - wmutils - X windows manipulation utilities
  HTML git clone git://z3bra.org/wmutils
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 9afcb679c3109677fe0406b49148cbcac7eb9a02
   DIR parent 4747b2ad6e2de015c915c1590dd6338170729ebd
  HTML Author: z3bra <willy@mailoo.org>
       Date:   Wed,  3 Dec 2014 22:52:43 +0100
       
       lsw: added -i switch to list ignored window
       
       Diffstat:
         M lsw.c                               |      37 ++++++++++++++++++++++---------
       
       1 file changed, 27 insertions(+), 10 deletions(-)
       ---
   DIR diff --git a/lsw.c b/lsw.c
       t@@ -14,6 +14,12 @@ static void xcbinit(void);
        static void cleanup(void);
        static int mapped(xcb_window_t);
        static int ignored(xcb_window_t);
       +static int shouldlist(xcb_window_t, int);
       +
       +enum {
       +        LIST_HIDDEN = 1 << 0,
       +        LIST_IGNORE = 1 << 1
       +};
        
        static void
        usage(void)
       t@@ -58,7 +64,7 @@ mapped(xcb_window_t w)
                ms = r->map_state;
        
                free(r);
       -        return ms;
       +        return ms == XCB_MAP_STATE_VIEWABLE;
        }
        
        static int
       t@@ -80,8 +86,20 @@ ignored(xcb_window_t w)
                return or;
        }
        
       +static int
       +shouldlist(xcb_window_t w, int mask)
       +{
       +        if (ignored(w) && !(mask & LIST_IGNORE))
       +                return 0;
       +
       +        if (!mapped(w) && !(mask & LIST_HIDDEN))
       +                 return 0;
       +
       +        return 1;
       +}
       +
        static void
       -listwindows(xcb_window_t w, int listhidden)
       +listwindows(xcb_window_t w, int listmask)
        {
                int i;
                xcb_window_t *wc;
       t@@ -98,10 +116,8 @@ listwindows(xcb_window_t w, int listhidden)
                        errx(1, "0x%08x: unable to retrieve children", w);
        
                for (i=0; i<r->children_len; i++) {
       -                if (!ignored(wc[i])) {
       -                        if (mapped(wc[i]) || listhidden)
       -                                printf("0x%08x\n", wc[i]);
       -                }
       +                if (shouldlist(wc[i], listmask))
       +                        printf("0x%08x\n", wc[i]);
                }
        
                free(r);
       t@@ -110,10 +126,11 @@ listwindows(xcb_window_t w, int listhidden)
        int
        main(int argc, char **argv)
        {
       -        int hiddenflag = 0, rootflag = 0;
       +        int listmask = 0, rootflag = 0;
        
                ARGBEGIN {
       -                case 'a': hiddenflag = 1; break;
       +                case 'a': listmask |= LIST_HIDDEN; break;
       +                case 'i': listmask |= LIST_IGNORE; break;
                        case 'r': rootflag = 1; break;
                        default : usage();
                } ARGEND;
       t@@ -127,10 +144,10 @@ main(int argc, char **argv)
                }
        
                if (argc == 0)
       -                listwindows(scrn->root, hiddenflag);
       +                listwindows(scrn->root, listmask);
        
                while (*argv)
       -                listwindows(strtoul(*argv++, NULL, 16), hiddenflag);
       +                listwindows(strtoul(*argv++, NULL, 16), listmask);
        
                return 0;
        }