wmutils

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

commit 9fa6cf9b059d4ccf52fea91c044915ec062d2aaf
parent 4e0d9bccd3a68c2f4d5008073850d096cfc6d6e9
Author: z3bra <willy@mailoo.org>
Date:   Tue Dec  9 12:35:18 2014

wmv: util.c refactoring

Diffstat:
 wmv.c | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/wmv.c b/wmv.c @@ -18,14 +18,14 @@ #include <stdlib.h> #include <err.h> -static xcb_connection_t *conn; -static xcb_screen_t *scr; +#include "util.h" + +static xcb_connection_t *conn; +static xcb_screen_t *scr; -static void cleanup (void); static void move (xcb_window_t, int, int); static void center_pointer (xcb_window_t); - static void center_pointer (xcb_window_t win) { uint32_t values[1]; @@ -85,23 +85,14 @@ move (xcb_window_t win, int x, int y) { free(geom); } -static void -cleanup (void) { - if (conn) - xcb_disconnect(conn); -} - - -int main (int argc, char **argv) { +int +main (int argc, char **argv) { xcb_window_t win; - atexit(cleanup); - if (argc != 4) errx(1, "usage: %s <x> <y> <win>", argv[0]); - if (xcb_connection_has_error(conn = xcb_connect(NULL, NULL))) - errx(1, "error connecting to X"); + init_xcb(&conn); scr = xcb_setup_roots_iterator(xcb_get_setup(conn)).data; win = scr->root; @@ -113,5 +104,7 @@ int main (int argc, char **argv) { move(win, atoi(argv[1]), atoi(argv[2])); xcb_flush(conn); + kill_xcb(&conn); + return 0; }