From 7afe9cc78b4d22dfd5a0c5866382a0e001ea38b6 Mon Sep 17 00:00:00 2001
From: Tony Crisci <tony@dubstepdish.com>
Date: Fri, 27 Jun 2014 21:20:12 -0400
Subject: [PATCH] Explicitly set current border width when BS_PIXEL

When a window becomes managed, if the config specifies a pixel border
style, explicitly set the current border width so it does not change
when the container changes from tiling to floating.

fixes #1266
---
 src/manage.c                    | 6 ++++++
 testcases/t/174-border-config.t | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/manage.c b/src/manage.c
index 9eee3578..a7002bf3 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -450,6 +450,12 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
         }
     }
 
+    if (nc->border_style == BS_PIXEL) {
+        /* if the border style is BS_PIXEL, explicitly set the border width of
+         * the new container */
+        nc->current_border_width = (want_floating ? config.default_floating_border_width : config.default_border_width);
+    }
+
     /* to avoid getting an UnmapNotify event due to reparenting, we temporarily
      * declare no interest in any state change event of this window */
     values[0] = XCB_NONE;
diff --git a/testcases/t/174-border-config.t b/testcases/t/174-border-config.t
index 56ad865a..3a8285c4 100644
--- a/testcases/t/174-border-config.t
+++ b/testcases/t/174-border-config.t
@@ -66,7 +66,7 @@ $first = open_window;
 @content = @{get_ws_content($tmp)};
 ok(@content == 1, 'one container opened');
 is($content[0]->{border}, 'pixel', 'border pixel by default');
-is($content[0]->{current_border_width}, -1, 'border width pixels -1 (default)');
+is($content[0]->{current_border_width}, 1, 'border width pixels 1 (default)');
 
 exit_gracefully($pid);