tkillw: util.c refactoring - wmutils - X windows manipulation utilities
HTML git clone git://z3bra.org/wmutils
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 4d8d7118beb336f0bf9e18cdbcb415a49e249b7a
DIR parent 822d777153479786803356b6f34bec3d447b45ea
HTML Author: z3bra <willy@mailoo.org>
Date: Tue, 9 Dec 2014 12:22:58 +0100
killw: util.c refactoring
Diffstat:
M killw.c | 25 +++++--------------------
1 file changed, 5 insertions(+), 20 deletions(-)
---
DIR diff --git a/killw.c b/killw.c
t@@ -3,31 +3,14 @@
#include <err.h>
#include <xcb/xcb.h>
-static xcb_connection_t *conn;
-
-static void xcbinit(void);
-static void cleanup(void);
-
-static void
-xcbinit(void)
-{
- conn = xcb_connect(NULL, NULL);
- if (xcb_connection_has_error(conn))
- errx(1, "xcb_connect");
-}
+#include "util.h"
-static void
-cleanup(void)
-{
- if (conn != NULL)
- xcb_disconnect(conn);
-}
+static xcb_connection_t *conn;
int
main(int argc, char **argv)
{
- atexit(cleanup);
- xcbinit();
+ init_xcb(&conn);
/* assume remaining arguments are windows */
while (*argv)
t@@ -35,5 +18,7 @@ main(int argc, char **argv)
xcb_flush(conn);
+ kill_xcb(&conn);
+
return 0;
}