twtp: 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 c76d1f6fa5c8fd13eab4b6c7a909426b3c52e446
(DIR) parent 6fd164309f97e2b976bdb6b65856579dc75e5197
(HTM) Author: z3bra <willy@mailoo.org>
Date: Tue, 9 Dec 2014 12:42:59 +0100
wtp: util.c refactoring
Diffstat:
M wtp.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
---
(DIR) diff --git a/wtp.c b/wtp.c
t@@ -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)
{
t@@ -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)
t@@ -99,5 +91,7 @@ main (int argc, char **argv)
atoi(argv[3]), atoi(argv[4]));
xcb_flush(conn);
+ kill_xcb(&conn);
+
return 0;
}