wmutils

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

commit 4e0d9bccd3a68c2f4d5008073850d096cfc6d6e9
parent e9e56d9de943d950f87987da9896386ea051d36d
Author: z3bra <willy@mailoo.org>
Date:   Tue Dec  9 12:32:27 2014

pfw: util.c refactoring

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

diff --git a/pfw.c b/pfw.c @@ -5,27 +5,12 @@ #include <stdlib.h> #include <xcb/xcb.h> +#include "util.c" + static xcb_connection_t *conn; -static void xcbinit(void); -static void cleanup(void); static xcb_window_t focuswindow(void); -static void -xcbinit(void) -{ - conn = xcb_connect(NULL, NULL); - if (xcb_connection_has_error(conn)) - errx(1, "xcb_connect"); -} - -static void -cleanup(void) -{ - if (conn != NULL) - xcb_disconnect(conn); -} - static xcb_window_t focuswindow(void) { @@ -46,9 +31,10 @@ focuswindow(void) int main(int argc, char **argv) { - atexit(cleanup); - xcbinit(); + init_xcb(&conn); printf("0x%08x\n", focuswindow()); + + kill_xcb(&conn); return 0; }