wmutils

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

commit 14021c2836c9795c4581ff29336961a9bdbf9ec4
parent 4f85d7191300146a2733a85673b214e49549d2a9
Author: z3bra <willy@mailoo.org>
Date:   Tue Dec 23 10:34:44 2014

All utils now pass the valgrind test, yay !

Diffstat:
 chwb.c  |  6 +++---
 lsw.c   |  2 ++
 mapw.c  |  2 ++
 util.c  |  1 +
 wattr.c | 13 ++++++++-----
 wmv.c   |  3 ++-
 wname.c |  2 ++
 wtf.c   | 14 +++++++-------
 8 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/chwb.c b/chwb.c @@ -49,8 +49,6 @@ main (int argc, char **argv) char *argv0; int color,bw; - init_xcb(&conn); - color = bw = -1; if (argc < 2) @@ -63,10 +61,12 @@ main (int argc, char **argv) case 'c': color = strtoul(EARGF(usage(argv0)), NULL, 16); break; - case 'h': + default: usage(argv0); } ARGEND + init_xcb(&conn); + /* assume remaining arguments are windows */ while (*argv) setborder(bw, color, strtoul(*argv++, NULL, 16)); diff --git a/lsw.c b/lsw.c @@ -58,6 +58,8 @@ list_windows(xcb_window_t w, int listmask) if (should_list(wc[i], listmask)) printf("0x%08x\n", wc[i]); } + + free(wc); } int diff --git a/mapw.c b/mapw.c @@ -65,5 +65,7 @@ main(int argc, char **argv) } xcb_flush(conn); + kill_xcb(&conn); + return 0; } diff --git a/util.c b/util.c @@ -40,6 +40,7 @@ exists(xcb_connection_t *con, xcb_window_t w) if (r == NULL) return 0; + free(r); return 1; } diff --git a/wattr.c b/wattr.c @@ -58,7 +58,7 @@ get_attribute(xcb_window_t w, int attr) int main(int argc, char **argv) { - int c; + int c, ret = 0; size_t i; xcb_window_t w = 0; @@ -70,7 +70,8 @@ main(int argc, char **argv) if (argc == 2) { w = strtoul(argv[1], NULL, 16); - exists(conn, w) ? exit(0) : exit(1); + ret = exists(conn, w) ? 0 : 1; + goto end; } for (c=2; argv[c]; c++) { @@ -90,15 +91,17 @@ main(int argc, char **argv) break; case 'w': printf("%d", get_attribute(w, ATTR_W)); break; - case 'o': ignore(conn, w) ? exit(0) : exit(1); - case 'm': mapped(conn, w) ? exit(0) : exit(1); + case 'o': ret = ignore(conn, w) ? 0 : 1; goto end; + case 'm': ret = mapped(conn, w) ? 0 : 1; goto end; + default: kill_xcb(&conn); usage(argv[0]); } /* add a space if more attribute come after */ putc(i+1 < strlen(argv[1]) ? ' ' : '\n',stdout); } } +end: kill_xcb(&conn); - return 0; + return ret; } diff --git a/wmv.c b/wmv.c @@ -37,6 +37,8 @@ center_pointer(xcb_window_t win) values[0] = XCB_STACK_MODE_ABOVE; xcb_configure_window(conn, win, XCB_CONFIG_WINDOW_STACK_MODE, values); + + free(geom); } static void @@ -77,7 +79,6 @@ move(xcb_window_t win, int x, int y) xcb_configure_window(conn, win, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, values); - center_pointer(win); free(geom); } diff --git a/wname.c b/wname.c @@ -34,8 +34,10 @@ get_title(xcb_window_t win) len = xcb_get_property_value_length(r); if (!len) return 1; + printf("%.*s\n", len, (char *) xcb_get_property_value(r)); + free(r); return 0; } diff --git a/wtf.c b/wtf.c @@ -3,6 +3,7 @@ #include <xcb/xcb.h> #include <stdlib.h> #include <stdio.h> +#include <string.h> #include <err.h> #include "util.h" @@ -23,20 +24,19 @@ main(int argc, char **argv) { xcb_window_t win; - - if (argc != 2) + if (argc != 2 || strncmp(argv[0], "-h", 2) == 0) usage(argv[0]); init_xcb(&conn); win = strtoul(argv[1], NULL, 16); - if (!win) - errx(1, "could not get focused window"); - xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, win, - XCB_CURRENT_TIME); + if (win) { + xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, win, + XCB_CURRENT_TIME); - xcb_flush(conn); + xcb_flush(conn); + } kill_xcb(&conn); return 0;