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

Re: [PATCH] New setting: smart_window_surroundings



Thorsten WiÃmann:

> there are two points to be fixed in your patch

The fixed patch is attached.

Cheers,
-- 
 b.d
(| |)
 ^ ^
>From 5caa5be58bf884c761c80dc395d5b710b0f13f85 Mon Sep 17 00:00:00 2001
From: Bastien Dejean <nihilhill _at_ gmail _dot_ com>
Date: Wed, 18 Jul 2012 14:39:55 +0200
Subject: [PATCH] New setting: smart_window_surroundings

---
 NEWS                 |  2 +-
 doc/herbstluftwm.txt |  6 +++---
 src/clientlist.c     | 16 ++++++++++------
 src/layout.c         | 20 +++++++++++++-------
 src/settings.c       |  2 +-
 5 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/NEWS b/NEWS
index ca2662c..b3f003e 100644
--- a/NEWS
+++ b/NEWS
@@ -26,7 +26,7 @@ Changes:
     * new setting: auto_detect_monitors
     * only one Makefile for herbstluftwm and herbstclient. The herbstclient
       binary now is put in the main directory.
-    * new settings: smart_frame_surroundings and smart_window_borders
+    * new settings: smart_frame_surroundings and smart_window_surroundings
     * 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 79e3dc2..d7da1fb 100644
--- a/doc/herbstluftwm.txt
+++ b/doc/herbstluftwm.txt
@@ -623,9 +623,9 @@ smart_frame_surroundings (Integer)::
     If set, frame borders and gaps will be removed when there's no ambiguity
     regarding the focused frame.
 
-smart_window_borders (Integer)::
-    If set, window borders will be removed when there's no ambiguity regarding
-    the focused window.
+smart_window_surroundings (Integer)::
+    If set, window borders and gaps will be removed when there's no ambiguity
+    regarding the focused window.
 
 focus_follows_shift (Integer)::
     If set, focus stays in the window, if window is shifted to another frame.
diff --git a/src/clientlist.c b/src/clientlist.c
index daf55ed..b67be6f 100644
--- a/src/clientlist.c
+++ b/src/clientlist.c
@@ -33,7 +33,7 @@ int g_monitor_float_treshold = 24;
 int* g_window_border_width;
 int* g_raise_on_focus;
 int* g_snap_gap;
-int* g_smart_window_borders;
+int* g_smart_window_surroundings;
 unsigned long g_window_border_active_color;
 unsigned long g_window_border_urgent_color;
 unsigned long g_window_border_normal_color;
@@ -60,7 +60,7 @@ static void fetch_colors() {
     g_window_border_width = &(settings_find("window_border_width")->value.i);
     g_window_gap = &(settings_find("window_gap")->value.i);
     g_snap_gap = &(settings_find("snap_gap")->value.i);
-    g_smart_window_borders = &(settings_find("smart_window_borders")->value.i);
+    g_smart_window_surroundings = &(settings_find("smart_window_surroundings")->value.i);
     g_raise_on_focus = &(settings_find("raise_on_focus")->value.i);
     char* str = settings_find("window_border_normal_color")->value.s;
     g_window_border_normal_color = getcolor(str);
@@ -328,7 +328,7 @@ void client_resize(HSClient* client, XRectangle rect, HSFrame* frame) {
         rect.height = size.height;
     }
     int border_width = *g_window_border_width;
-    if (*g_smart_window_borders && !client->pseudotile
+    if (*g_smart_window_surroundings && !client->pseudotile
         && (frame->content.clients.count == 1
             || frame->content.clients.layout == LAYOUT_MAX)) {
         border_width = 0;
@@ -343,9 +343,13 @@ void client_resize(HSClient* client, XRectangle rect, HSFrame* frame) {
     // apply border width
     rect.width -= border_width * 2;
     rect.height -= border_width * 2;
-    // apply window gap
-    rect.width -= *g_window_gap;
-    rect.height -= *g_window_gap;
+    if (!*g_smart_window_surroundings
+        || (frame->content.clients.count != 1
+            && frame->content.clients.layout != LAYOUT_MAX)) {
+        // apply window gap
+        rect.width -= *g_window_gap;
+        rect.height -= *g_window_gap;
+    }
 
     XSetWindowBorderWidth(g_display, win, border_width);
     XMoveResizeWindow(g_display, win, rect.x, rect.y, rect.width, rect.height);
diff --git a/src/layout.c b/src/layout.c
index baf3558..271961e 100644
--- a/src/layout.c
+++ b/src/layout.c
@@ -35,6 +35,7 @@ int* g_frame_bg_transparent;
 int* g_direction_external_only;
 int* g_gapless_grid;
 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_bg_active_color;
@@ -68,6 +69,7 @@ static void fetch_frame_colors() {
     g_direction_external_only = &(settings_find("default_direction_external_only")->value.i);
     g_gapless_grid = &(settings_find("gapless_grid")->value.i);
     g_smart_frame_surroundings = &(settings_find("smart_frame_surroundings")->value.i);
+    g_smart_window_surroundings = &(settings_find("smart_window_surroundings")->value.i);
     *g_default_frame_layout = CLAMP(*g_default_frame_layout, 0, LAYOUT_COUNT - 1);
     char* str = settings_find("frame_border_normal_color")->value.s;
     g_frame_border_normal_color = getcolor(str);
@@ -741,10 +743,10 @@ void frame_apply_layout(HSFrame* frame, XRectangle rect) {
     if (frame->type == TYPE_CLIENTS) {
         size_t count = frame->content.clients.count;
         if (!*g_smart_frame_surroundings || frame->parent) {
-            // frame only -> apply frame_gap
+            // apply frame gap
             rect.height -= *g_frame_gap;
             rect.width -= *g_frame_gap;
-            // apply frame width
+            // apply frame border
             rect.x += *g_frame_border_width;
             rect.y += *g_frame_border_width;
             rect.height -= *g_frame_border_width * 2;
@@ -793,11 +795,15 @@ void frame_apply_layout(HSFrame* frame, XRectangle rect) {
             return;
         }
 
-        // apply window gap
-        rect.x += *g_window_gap;
-        rect.y += *g_window_gap;
-        rect.width -= *g_window_gap;
-        rect.height -= *g_window_gap;
+        if (!*g_smart_window_surroundings
+            || (frame->content.clients.count != 1
+                && frame->content.clients.layout != LAYOUT_MAX)) {
+            // apply window gap
+            rect.x += *g_window_gap;
+            rect.y += *g_window_gap;
+            rect.width -= *g_window_gap;
+            rect.height -= *g_window_gap;
+        }
 
         if (frame->content.clients.layout == LAYOUT_MAX) {
             frame_apply_client_layout_max(frame, rect);
diff --git a/src/settings.c b/src/settings.c
index 602320c..c036a0b 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -62,7 +62,7 @@ SettingsPair g_settings[] = {
     SET_INT(    "raise_on_focus",                  0,           NULL        ),
     SET_INT(    "raise_on_click",                  1,           NULL        ),
     SET_INT(    "gapless_grid",                    1,           RELAYOUT    ),
-    SET_INT(    "smart_window_borders",            0,           RELAYOUT    ),
+    SET_INT(    "smart_window_surroundings",       0,           RELAYOUT    ),
     SET_INT(    "smart_frame_surroundings",        0,           RELAYOUT    ),
     SET_INT(    "monitors_locked",                 0,           LOCK_CHANGED),
     SET_INT(    "auto_detect_monitors",            0,           NULL        ),
-- 
1.7.11.2

------------------------------------------------------------------------------
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/