wmutils

X windows manipulation utilities
git clone git://z3bra.org/wmutils
Log | Files | Refs | LICENSE

commit 6fd164309f97e2b976bdb6b65856579dc75e5197
parent 3374aaf887fb6c21e80ae23048e34c14c14fbbb7
Author: z3bra <willy@mailoo.org>
Date:   Tue Dec  9 12:40:18 2014

wtf: util.c refactoring

Diffstat:
 wtf.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/wtf.c b/wtf.c @@ -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); @@ -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) @@ -76,5 +68,6 @@ main (int argc, char **argv) center_pointer(win); xcb_flush(conn); + kill_xcb(&conn); return 0; }