twmv: 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 9fa6cf9b059d4ccf52fea91c044915ec062d2aaf
(DIR) parent 4e0d9bccd3a68c2f4d5008073850d096cfc6d6e9
(HTM) Author: z3bra <willy@mailoo.org>
Date: Tue, 9 Dec 2014 12:35:18 +0100
wmv: util.c refactoring
Diffstat:
M wmv.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
---
(DIR) diff --git a/wmv.c b/wmv.c
t@@ -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];
t@@ -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;
t@@ -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;
}