tnew tool: wrs - wmutils - X windows manipulation utilities
(HTM) git clone git://z3bra.org/wmutils
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 33b7a68f0f596011aa632403afb06a8d69123d71
(DIR) parent b7fa22b01b124c64c099f4c2e6315da0393ceb66
(HTM) Author: z3bra <willy@mailoo.org>
Date: Fri, 28 Nov 2014 13:49:17 +0100
new tool: wrs
Diffstat:
M Makefile | 3 ++-
A wrs.c | 86 ++++++++++++++++++++++++++++++
2 files changed, 88 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/Makefile b/Makefile
t@@ -16,7 +16,8 @@ SRC = \
wtp.c \
wmv.c \
chwso.c \
- wtf.c
+ wtf.c \
+ wrs.c
OBJ = $(SRC:.c=.o)
BIN = $(SRC:.c=)
(DIR) diff --git a/wrs.c b/wrs.c
t@@ -0,0 +1,86 @@
+/**
+* Copyright (c) 2014, Broseph <dcat (at) iotek (dot) org>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*
+* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+**/
+
+#include <xcb/xcb.h>
+#include <stdlib.h>
+#include <err.h>
+
+static xcb_connection_t *conn;
+
+static void cleanup(void);
+static void resize(xcb_window_t, int, int);
+
+static void
+xcbinit(void)
+{
+ conn = xcb_connect(NULL, NULL);
+ if (xcb_connection_has_error(conn))
+ errx(1, "unable to connect to the X server");
+}
+
+static void
+cleanup(void)
+{
+ if (conn)
+ xcb_disconnect(conn);
+}
+
+static void
+resize(xcb_window_t w, int x, int y)
+{
+ uint32_t val[3];
+ uint32_t mask = XCB_CONFIG_WINDOW_WIDTH
+ | XCB_CONFIG_WINDOW_HEIGHT
+ | XCB_CONFIG_WINDOW_STACK_MODE;
+ xcb_get_geometry_cookie_t c;
+ xcb_get_geometry_reply_t *r;
+
+ c = xcb_get_geometry(conn, w);
+ r = xcb_get_geometry_reply(conn, c, NULL);
+
+ if (r == NULL)
+ return;
+
+ val[0] = r->width + x;
+ val[1] = r->height + y;
+ val[2] = XCB_STACK_MODE_ABOVE;
+
+ xcb_configure_window(conn, w, mask, val);
+
+ xcb_warp_pointer(conn, XCB_NONE, w, 0, 0, 0, 0, r->width + x,
+ r->height + y);
+
+ free(r);
+}
+
+int
+main(int argc, char **argv)
+{
+ int i;
+
+ if (argc < 4)
+ errx(1, "usage: %s <x> <y> <wid> [wid..]", argv[0]);
+
+ atexit(cleanup);
+ xcbinit();
+
+ for (i=3; i<argc; i++)
+ resize(strtoul(argv[i], NULL, 16), atoi(argv[1]), atoi(argv[2]));
+
+ xcb_flush(conn);
+
+ return 0;
+}