tlsw: reworked flags, watch out ! - wmutils - X windows manipulation utilities
 (HTM) git clone git://z3bra.org/wmutils
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit b1f94e8bd0f93482920c3dca451e257dcf21dc7a
 (DIR) parent 6a63a25361a02879b3eb6d3f6f8dec4ad140ef69
 (HTM) Author: z3bra <willy@mailoo.org>
       Date:   Wed, 10 Dec 2014 21:51:28 +0100
       
       lsw: reworked flags, watch out !
       
       Diffstat:
         M lsw.c                               |      24 ++++++++++++++----------
       
       1 file changed, 14 insertions(+), 10 deletions(-)
       ---
 (DIR) diff --git a/lsw.c b/lsw.c
       t@@ -16,26 +16,29 @@ static void list_windows(xcb_window_t, int);
        
        enum {
                LIST_HIDDEN = 1 << 0,
       -        LIST_IGNORE = 1 << 1
       +        LIST_IGNORE = 1 << 1,
       +        LIST_ALL    = 1 << 2
        };
        
        static void
        usage(void)
        {
       -        fprintf(stderr, "usage: %s [-hiar] [wid...]\n", argv0);
       +        fprintf(stderr, "usage: %s [-houra] [wid...]\n", argv0);
                exit(1);
        }
        
        static int
        should_list(xcb_window_t w, int mask)
        {
       -        if (ignore(conn, w) && !(mask & LIST_IGNORE))
       -                return 0;
       -
       -        if (!mapped(conn, w) && !(mask & LIST_HIDDEN))
       -                 return 0;
       +        if ((mask & LIST_ALL)
       +                || (!mapped(conn, w) && mask & LIST_HIDDEN)
       +                || (ignore(conn, w) && mask & LIST_IGNORE)
       +                || (mapped(conn, w)
       +                        && !ignore(conn, w)
       +                        && mask == 0))
       +                return 1;
        
       -        return 1;
       +        return 0;
        }
        
        static void
       t@@ -69,8 +72,9 @@ main(int argc, char **argv)
                int listmask = 0, rootflag = 0;
        
                ARGBEGIN {
       -                case 'a': listmask |= LIST_HIDDEN; break;
       -                case 'i': listmask |= LIST_IGNORE; break;
       +                case 'a': listmask |= LIST_ALL; break;
       +                case 'u': listmask |= LIST_HIDDEN; break;
       +                case 'o': listmask |= LIST_IGNORE; break;
                        case 'r': rootflag = 1; break;
                        default : usage();
                } ARGEND;