tignw: 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 acb1b1d9c78a46bb57f9ccb2699fdcabbcd00a7e
(DIR) parent 9552b0d32a7b47e59dcf263c10794dbb11e1f2c5
(HTM) Author: z3bra <willy@mailoo.org>
Date: Tue, 9 Dec 2014 12:29:01 +0100
ignw: util.c refactoring
Diffstat:
M ignw.c | 24 +++++-------------------
1 file changed, 5 insertions(+), 19 deletions(-)
---
(DIR) diff --git a/ignw.c b/ignw.c
t@@ -4,13 +4,12 @@
#include <xcb/xcb.h>
#include "arg.h"
+#include "util.h"
char *argv0;
static xcb_connection_t *conn;
static void usage(void);
-static void xcbinit(void);
-static void cleanup(void);
static void setoverride(xcb_window_t, int);
static void
t@@ -21,21 +20,6 @@ usage(void)
}
static void
-xcbinit(void)
-{
- conn = xcb_connect(NULL, NULL);
- if (xcb_connection_has_error(conn))
- errx(1, "unable connect to the X server");
-}
-
-static void
-cleanup(void)
-{
- if (conn != NULL)
- xcb_disconnect(conn);
-}
-
-static void
setoverride(xcb_window_t w, int or)
{
uint32_t mask = XCB_CW_OVERRIDE_REDIRECT;
t@@ -54,13 +38,15 @@ main(int argc, char **argv)
case 'r': setflag = 0; break;
default: usage();
} ARGEND;
- atexit(cleanup);
- xcbinit();
+
+ init_xcb(&conn);
while (*argv)
setoverride(strtoul(*argv++, NULL, 16), setflag);
xcb_flush(conn);
+ kill_xcb(&conn);
+
return 0;
}