tchwb: fix indentation and add comment. chwso: fix trailing whitespace. - wmutils - X windows manipulation utilities
(HTM) git clone git://z3bra.org/wmutils
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit d85df2c112b1c89467929b5ac011bfe97583976f
(DIR) parent ddbbc513377e0e5173ae19bcc8619ef0c19d8672
(HTM) Author: Anders Lewis <greagle3@gmail.com>
Date: Mon, 1 Aug 2016 19:26:08 -0700
chwb: fix indentation and add comment. chwso: fix trailing whitespace.
Diffstat:
M chwb.c | 21 ++++++++++++++++++---
M chwso.c | 2 +-
2 files changed, 19 insertions(+), 4 deletions(-)
---
(DIR) diff --git a/chwb.c b/chwb.c
t@@ -23,15 +23,30 @@ usage(char *name)
static void
set_border(int width, int color, xcb_window_t win)
{
- uint32_t values[1];
+ uint32_t values[3];
+ uint16_t curr_width;
int mask;
+ xcb_get_geometry_reply_t *geom;
if (width != -1) {
- values[0] = width;
- mask = XCB_CONFIG_WINDOW_BORDER_WIDTH;
+ geom = xcb_get_geometry_reply(conn, xcb_get_geometry(conn, win), NULL);
+ if (!geom)
+ return;
+
+ /* Windows track position based on the top left corner of the border.
+ * To make the border move instead of the window, we move the window up and left
+ * by the amount the border would have shifted it down and right.*/
+ curr_width = geom->border_width;
+ values[0] = geom->x + curr_width - width;
+ values[1] = geom->y + curr_width - width;
+ values[2] = width;
+
+ mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_BORDER_WIDTH ;
xcb_configure_window(conn, win, mask, values);
xcb_flush(conn);
+
+ free(geom);
}
if (color != -1) {
(DIR) diff --git a/chwso.c b/chwso.c
t@@ -32,7 +32,7 @@ main(int argc, char **argv)
xcb_window_t win;
uint32_t values[1];
char *argv0 = NULL;
-
+
if (argc != 3)
usage(argv[0]);