wmutils

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

commit 9552b0d32a7b47e59dcf263c10794dbb11e1f2c5
parent 86d98bdd2df7ae4f0fc2166cd98668e102ef2920
Author: z3bra <willy@mailoo.org>
Date:   Tue Dec  9 12:27:23 2014

chwso: util.c refactoring

Diffstat:
 chwso.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/chwso.c b/chwso.c @@ -20,10 +20,10 @@ #include <err.h> #include "arg.h" +#include "util.h" static xcb_connection_t *conn; -static void cleanup (void); static void usage (char *); static void stack (xcb_window_t, uint32_t[1]); @@ -35,13 +35,6 @@ usage (char *name) } static void -cleanup (void) -{ - if (conn) - xcb_disconnect(conn); -} - -static void stack (xcb_window_t win, uint32_t values[1]) { xcb_configure_window(conn, win, XCB_CONFIG_WINDOW_STACK_MODE, values); @@ -57,10 +50,7 @@ main (int argc, char **argv) if (argc != 3) usage(argv[0]); - atexit(cleanup); - if (xcb_connection_has_error(conn = xcb_connect(NULL, NULL))) - errx(1, "error connecting to X"); - + init_xcb(&conn); win = strtoul(argv[2], NULL, 16); if (!win) @@ -76,6 +66,7 @@ main (int argc, char **argv) stack(win, values); xcb_flush(conn); + kill_xcb(&conn); + return 0; } -