wmutils

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

commit acb1b1d9c78a46bb57f9ccb2699fdcabbcd00a7e
parent 9552b0d32a7b47e59dcf263c10794dbb11e1f2c5
Author: z3bra <willy@mailoo.org>
Date:   Tue Dec  9 12:29:01 2014

ignw: util.c refactoring

Diffstat:
 ignw.c | 24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/ignw.c b/ignw.c @@ -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 @@ -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; @@ -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; }