tMerge pull request #48 from agloo/border_adjust - wmutils - X windows manipulation utilities
(HTM) git clone git://z3bra.org/wmutils
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit c1bd0210073d72210beaf4c218754d612bdd4b74
(DIR) parent ddbbc513377e0e5173ae19bcc8619ef0c19d8672
(HTM) Author: zebra v3.1 <z3bratabs@users.noreply.github.com>
Date: Tue, 2 Aug 2016 08:10:12 +0200
Merge pull request #48 from agloo/border_adjust
chwb: keep window static when updating border size
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]);