[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] New Settings: frame_border_inner_{width,color}



Hi,

I've implemented inner border related settings for frames: fortunately,
I did not have to apply many modifications to layout.c.

Greetings,
-- 
 b.d
(| |)
 ^ ^
>From 2fd5cf4a3be1cc0c272c6255a6e59247f2ff05e2 Mon Sep 17 00:00:00 2001
From: Bastien Dejean <nihilhill _at_ gmail _dot_ com>
Date: Tue, 24 Jul 2012 14:57:26 +0200
Subject: [PATCH] New settings: frame_border_inner_{width,color}

---
 NEWS                 |  1 +
 doc/herbstluftwm.txt |  6 ++++++
 src/layout.c         | 16 ++++++++++++++--
 src/layout.h         |  1 +
 src/settings.c       |  2 ++
 5 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 06f26c2..642f2e7 100644
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,7 @@ Changes:
       binary now is put in the main directory.
     * new settings: smart_frame_surroundings and smart_window_surroundings
     * new settings: window_border_inner_color and window_border_inner_width
+    * new settings: frame_border_inner_color and frame_border_inner_width
     * new option --skip-invisible for cycle_all
 
 Release 0.3 on 2012-04-12
diff --git a/doc/herbstluftwm.txt b/doc/herbstluftwm.txt
index c82279d..884e813 100644
--- a/doc/herbstluftwm.txt
+++ b/doc/herbstluftwm.txt
@@ -556,6 +556,9 @@ frame_border_active_color (String/Color)::
 frame_border_normal_color (String/Color)::
     The border color of an unfocused frame
 
+frame_border_inner_color (String/Color)::
+    The color of the inner border of a frame.
+
 frame_bg_active_color (String/Color)::
     The fill color of a focused frame
 
@@ -569,6 +572,9 @@ frame_bg_transparent (Integer)::
 frame_border_width (Integer)::
     Border width of a frame
 
+frame_border_inner_width (Integer)::
+    The width of the inner border of a frame.
+
 raise_on_focus (Integer)::
     If set, a window is raised if it is focused. The value of this setting is
     only noticed in floating mode.
diff --git a/src/layout.c b/src/layout.c
index 5082824..deeb6fa 100644
--- a/src/layout.c
+++ b/src/layout.c
@@ -28,6 +28,7 @@
 #include <X11/Xatom.h>
 
 int* g_frame_border_width;
+int* g_frame_border_inner_width;
 int* g_always_show_frame;
 int* g_default_frame_layout;
 int* g_focus_follows_shift;
@@ -38,6 +39,7 @@ int* g_smart_frame_surroundings;
 int* g_smart_window_surroundings;
 unsigned long g_frame_border_active_color;
 unsigned long g_frame_border_normal_color;
+unsigned long g_frame_border_inner_color;
 unsigned long g_frame_bg_active_color;
 unsigned long g_frame_bg_normal_color;
 unsigned long g_frame_active_opacity;
@@ -63,6 +65,7 @@ static void fetch_frame_colors() {
     g_window_gap = &(settings_find("window_gap")->value.i);
     g_focus_follows_shift = &(settings_find("focus_follows_shift")->value.i);
     g_frame_border_width = &(settings_find("frame_border_width")->value.i);
+    g_frame_border_inner_width = &(settings_find("frame_border_inner_width")->value.i);
     g_always_show_frame = &(settings_find("always_show_frame")->value.i);
     g_frame_bg_transparent = &(settings_find("frame_bg_transparent")->value.i);
     g_default_frame_layout = &(settings_find("default_frame_layout")->value.i);
@@ -75,6 +78,8 @@ static void fetch_frame_colors() {
     g_frame_border_normal_color = getcolor(str);
     str = settings_find("frame_border_active_color")->value.s;
     g_frame_border_active_color = getcolor(str);
+    str = settings_find("frame_border_inner_color")->value.s;
+    g_frame_border_inner_color = getcolor(str);
     // background color
     str = settings_find("frame_bg_normal_color")->value.s;
     g_frame_bg_normal_color = getcolor(str);
@@ -765,8 +770,6 @@ void frame_apply_layout(HSFrame* frame, XRectangle rect) {
         }
         if (!*g_smart_frame_surroundings || frame->parent) {
             XSetWindowBorderWidth(g_display, frame->window, *g_frame_border_width);
-            // set indicator frame
-            XSetWindowBorder(g_display, frame->window, border_color);
             XMoveResizeWindow(g_display, frame->window,
                               rect.x - *g_frame_border_width,
                               rect.y - *g_frame_border_width,
@@ -776,6 +779,8 @@ void frame_apply_layout(HSFrame* frame, XRectangle rect) {
             XMoveResizeWindow(g_display, frame->window, rect.x, rect.y, rect.width, rect.height);
         }
 
+        frame_update_border(frame->window, border_color);
+
         if (*g_frame_bg_transparent) {
             XSetWindowBackgroundPixmap(g_display, frame->window, ParentRelative);
         } else {
@@ -1651,3 +1656,10 @@ int frame_foreach_client(HSFrame* frame, ClientAction action, void* data) {
 }
 
 
+void frame_update_border(Window window, unsigned long color) {
+    if (*g_frame_border_inner_width > 0 && *g_frame_border_inner_width < *g_frame_border_width) {
+        set_window_double_border(g_display, window, *g_frame_border_inner_width, g_frame_border_inner_color, color);
+    } else {
+        XSetWindowBorder(g_display, window, color);
+    }
+}
diff --git a/src/layout.h b/src/layout.h
index a63407f..68f48ca 100644
--- a/src/layout.h
+++ b/src/layout.h
@@ -161,6 +161,7 @@ int frame_move_window_command(int argc, char** argv);
 int frame_remove_command(int argc, char** argv);
 int close_or_remove_command(int argc, char** argv);
 void frame_set_visible(HSFrame* frame, bool visible);
+void frame_update_border(Window window, unsigned long color);
 
 #endif
 
diff --git a/src/settings.c b/src/settings.c
index 5d50b29..ac27288 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -42,10 +42,12 @@ SettingsPair g_settings[] = {
     SET_INT(    "snap_gap",                        5,           NULL        ),
     SET_STRING( "frame_border_active_color",       "red",       FR_COLORS   ),
     SET_STRING( "frame_border_normal_color",       "blue",      FR_COLORS   ),
+    SET_STRING( "frame_border_inner_color",        "black",     FR_COLORS   ),
     SET_STRING( "frame_bg_normal_color",           "black",     FR_COLORS   ),
     SET_STRING( "frame_bg_active_color",           "black",     FR_COLORS   ),
     SET_INT(    "frame_bg_transparent",            0,           FR_COLORS   ),
     SET_INT(    "frame_border_width",              2,           FR_COLORS   ),
+    SET_INT(    "frame_border_inner_width",        0,           FR_COLORS   ),
     SET_INT(    "frame_active_opacity",            100,         FR_COLORS   ),
     SET_INT(    "frame_normal_opacity",            100,         FR_COLORS   ),
     SET_INT(    "window_border_width",             2,           CL_COLORS   ),
-- 
1.7.11.3

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/