wmutils

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

commit c76d1f6fa5c8fd13eab4b6c7a909426b3c52e446
parent 6fd164309f97e2b976bdb6b65856579dc75e5197
Author: z3bra <willy@mailoo.org>
Date:   Tue Dec  9 12:42:59 2014

wtp: util.c refactoring

Diffstat:
 wtp.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/wtp.c b/wtp.c @@ -19,26 +19,21 @@ #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 teleport (xcb_window_t, int, int, int, int); static int get_border (xcb_window_t win); -static void usage(char *name) +static void +usage(char *name) { fprintf(stderr, "usage: %s <x> <y> <w> <h> <wid>\n", name); exit(1); } -static void -cleanup (void) -{ - if (conn) - xcb_disconnect(conn); -} - static int get_border (xcb_window_t win) { @@ -83,13 +78,10 @@ main (int argc, char **argv) { xcb_window_t win; - atexit(cleanup); - if (argc != 6) 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[5], NULL, 16); if (!win) @@ -99,5 +91,7 @@ main (int argc, char **argv) atoi(argv[3]), atoi(argv[4])); xcb_flush(conn); + kill_xcb(&conn); + return 0; }