twtf: util.c refactoring - wmutils - X windows manipulation utilities
 (HTM) git clone git://z3bra.org/wmutils
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 6fd164309f97e2b976bdb6b65856579dc75e5197
 (DIR) parent 3374aaf887fb6c21e80ae23048e34c14c14fbbb7
 (HTM) Author: z3bra <willy@mailoo.org>
       Date:   Tue,  9 Dec 2014 12:40:18 +0100
       
       wtf: util.c refactoring
       
       Diffstat:
         M wtf.c                               |      15 ++++-----------
       
       1 file changed, 4 insertions(+), 11 deletions(-)
       ---
 (DIR) diff --git a/wtf.c b/wtf.c
       t@@ -19,20 +19,14 @@
        #include <stdio.h>
        #include <err.h>
        
       +#include "util.h"
       +
        static xcb_connection_t   *conn;
        
       -static void cleanup        (void);
        static void usage          (char *name);
        static void center_pointer (xcb_window_t);
        
        static void
       -cleanup (void)
       -{
       -        if (conn)
       -                xcb_disconnect(conn);
       -}
       -
       -static void
        usage (char *name)
        {
                fprintf(stderr, "usage: %s <wid>\n", name);
       t@@ -61,13 +55,11 @@ main (int argc, char **argv)
        {
                xcb_window_t win;
        
       -        atexit(cleanup);
        
                if (argc != 2)
                        usage(argv[0]);
        
       -        if (xcb_connection_has_error(conn = xcb_connect(NULL, NULL)))
       -                errx(1, "error connecting to X");
       +        init_xcb(&conn);
        
                win = strtoul(argv[1], NULL, 16);
                if (!win)
       t@@ -76,5 +68,6 @@ main (int argc, char **argv)
                center_pointer(win);
                xcb_flush(conn);
        
       +        kill_xcb(&conn);
                return 0;
        }