]> git.lizzy.rs Git - bspwm.git/commitdiff
New message: "pad"
authorBastien Dejean <nihilhill@gmail.com>
Sun, 9 Dec 2012 11:01:45 +0000 (12:01 +0100)
committerBastien Dejean <nihilhill@gmail.com>
Sun, 9 Dec 2012 11:01:45 +0000 (12:01 +0100)
README.md
bspwm.1
messages.c
settings.c
settings.h
tree.c
types.c
types.h

index 05dda6c39de4f5dddc93593d89e3b9d0f13a1733..75d328a382259129a513af8a14513a5fa832fd14 100644 (file)
--- a/README.md
+++ b/README.md
@@ -98,6 +98,9 @@ The following messages are handled:
     ratio VALUE
         Set the splitting ratio of the focused window.
 
+    pad MONITOR_NAME [TOP_PADDING [RIGHT_PADDING [BOTTOM_PADDING [LEFT_PADDING]]]]
+        Set the padding of the given monitor.
+
     focus left|right|up|down
         Focus the neighbor window situated in the given direction.
 
@@ -242,11 +245,8 @@ Colors are either [X color names](http://en.wikipedia.org/wiki/X11_color_names)
     window_gap
         Value of the gap that separates windows.
 
-    top_padding
-    bottom_padding
-    left_padding
-    right_padding
-        Padding space added at the sides of the screen.
+    {top,right,bottom,left}_padding
+        Padding space added at the sides of the current monitor.
 
     wm_name
         The value that shall be used for the _NET_WM_NAME property of the root window.
diff --git a/bspwm.1 b/bspwm.1
index b26f1430876b56cf46c067f2c00e23ca7bf94c08..043f2d92625da13a5b1490da1a68ba986ff098eb 100644 (file)
--- a/bspwm.1
+++ b/bspwm.1
@@ -125,6 +125,9 @@ Switch to automatic mode.
 .BI ratio " VALUE"
 Set the splitting ratio of the focused window.
 .TP
+.BI pad " MONITOR_NAME [TOP_PADDING [RIGHT_PADDING [BOTTOM_PADDING [LEFT_PADDING]]]]"
+Set the padding of the given monitor.
+.TP
 .BI focus " left|right|up|down"
 Focus the neighbor window situated in the given direction.
 .TP
@@ -278,8 +281,8 @@ Width of the inner, main and outer borders.
 .I window_gap
 Value of the gap that separates windows.
 .TP
-.I {top,bottom,left,right}_padding
-Padding space added at the sides of the screen.
+.I {top,right,bottom,left}_padding
+Padding space added at the sides of the current monitor.
 .TP
 .I wm_name
 The value that shall be used for the
index ade55f7dc1df0032183c38313cd4fffb3f12cd31..12a650a0510d88815e783ace07b9048e6fb21c58 100644 (file)
@@ -104,6 +104,25 @@ void process_message(char *msg, char *rsp)
     } else if (strcmp(cmd, "toggle_locked") == 0) {
         if (mon->desk->focus != NULL)
             toggle_locked(mon->desk->focus->client);
+    } else if (strcmp(cmd, "pad") == 0) {
+        char *name = strtok(NULL, TOK_SEP);
+        if (name != NULL) {
+            monitor_t *m = find_monitor(name);
+            if (m != NULL) {
+                char args[BUFSIZ] = {0}, *s;
+                while ((s = strtok(NULL, TOK_SEP)) != NULL) {
+                    strncat(args, s, REMLEN(args));
+                    strncat(args, TOK_SEP, REMLEN(args));
+                }
+                if (strlen(args) > 0) {
+                    sscanf(args, "%i %i %i %i", &m->top_padding, &m->right_padding, &m->bottom_padding, &m->left_padding);
+                    arrange(m, m->desk);
+                } else {
+                    snprintf(rsp, BUFSIZ, "%i %i %i %i\n", m->top_padding, m->right_padding, m->bottom_padding, m->left_padding);
+                }
+            }
+        }
+        return;
     } else if (strcmp(cmd, "ratio") == 0) {
         char *value = strtok(NULL, TOK_SEP);
         if (value != NULL && mon->desk->focus != NULL)
@@ -340,13 +359,13 @@ void set_setting(char *name, char *value, char *rsp)
     } else if (strcmp(name, "window_gap") == 0) {
         sscanf(value, "%i", &window_gap);
     } else if (strcmp(name, "left_padding") == 0) {
-        sscanf(value, "%i", &left_padding);
+        sscanf(value, "%i", &mon->left_padding);
     } else if (strcmp(name, "right_padding") == 0) {
-        sscanf(value, "%i", &right_padding);
+        sscanf(value, "%i", &mon->right_padding);
     } else if (strcmp(name, "top_padding") == 0) {
-        sscanf(value, "%i", &top_padding);
+        sscanf(value, "%i", &mon->top_padding);
     } else if (strcmp(name, "bottom_padding") == 0) {
-        sscanf(value, "%i", &bottom_padding);
+        sscanf(value, "%i", &mon->bottom_padding);
     } else if (strcmp(name, "focused_border_color") == 0) {
         strncpy(focused_border_color, value, sizeof(focused_border_color));
         focused_border_color_pxl = get_color(focused_border_color);
@@ -441,13 +460,13 @@ void get_setting(char *name, char* rsp)
     else if (strcmp(name, "window_gap") == 0)
         snprintf(rsp, BUFSIZ, "%i", window_gap);
     else if (strcmp(name, "left_padding") == 0)
-        snprintf(rsp, BUFSIZ, "%i", left_padding);
+        snprintf(rsp, BUFSIZ, "%i", mon->left_padding);
     else if (strcmp(name, "right_padding") == 0)
-        snprintf(rsp, BUFSIZ, "%i", right_padding);
+        snprintf(rsp, BUFSIZ, "%i", mon->right_padding);
     else if (strcmp(name, "top_padding") == 0)
-        snprintf(rsp, BUFSIZ, "%i", top_padding);
+        snprintf(rsp, BUFSIZ, "%i", mon->top_padding);
     else if (strcmp(name, "bottom_padding") == 0)
-        snprintf(rsp, BUFSIZ, "%i", bottom_padding);
+        snprintf(rsp, BUFSIZ, "%i", mon->bottom_padding);
     else if (strcmp(name, "focused_border_color") == 0)
         snprintf(rsp, BUFSIZ, "%s (%06X)", focused_border_color, focused_border_color_pxl);
     else if (strcmp(name, "active_border_color") == 0)
index 6c4d062f84582df7a5105d035a22a975ad4143e5..0bfaa9caf2b29568795679b8b6a88a0c47e176dc 100644 (file)
@@ -64,12 +64,7 @@ void load_settings(void)
     outer_border_width = OUTER_BORDER_WIDTH;
 
     border_width = inner_border_width + main_border_width + outer_border_width;
-
     window_gap = WINDOW_GAP;
-    left_padding = LEFT_PADDING;
-    right_padding = RIGHT_PADDING;
-    top_padding = TOP_PADDING;
-    bottom_padding = BOTTOM_PADDING;
 
     borderless_monocle = BORDERLESS_MONOCLE;
     gapless_monocle = GAPLESS_MONOCLE;
index fbd0df5851eeaa34bef9fabd5a4ea7d87ca2d131..391659d28db25677f3c556675cb55338f2434436 100644 (file)
 #define INNER_BORDER_WIDTH  3
 #define MAIN_BORDER_WIDTH   1
 #define OUTER_BORDER_WIDTH  3
-#define SPLIT_RATIO         0.5
 
 #define WINDOW_GAP          6
-#define TOP_PADDING         0
-#define BOTTOM_PADDING      0
-#define LEFT_PADDING        0
-#define RIGHT_PADDING       0
+#define SPLIT_RATIO         0.5
 
 #define BORDERLESS_MONOCLE   false
 #define GAPLESS_MONOCLE      false
@@ -63,10 +59,6 @@ unsigned int outer_border_width;
 unsigned int border_width;
 
 int window_gap;
-int top_padding;
-int bottom_padding;
-int left_padding;
-int right_padding;
 
 bool borderless_monocle;
 bool gapless_monocle;
diff --git a/tree.c b/tree.c
index 007484de957f6fcd946cc1076446777fb51f55d5..fa03869624c23ff9dec8fffca8e6bcba66de557e 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -239,10 +239,10 @@ void arrange(monitor_t *m, desktop_t *d)
 
     xcb_rectangle_t rect = m->rectangle;
     int wg = (gapless_monocle && d->layout == LAYOUT_MONOCLE ? 0 : window_gap);
-    rect.x += left_padding + wg;
-    rect.y += top_padding + wg;
-    rect.width -= left_padding + right_padding + wg;
-    rect.height -= top_padding + bottom_padding + wg;
+    rect.x += m->left_padding + wg;
+    rect.y += m->top_padding + wg;
+    rect.width -= m->left_padding + m->right_padding + wg;
+    rect.height -= m->top_padding + m->bottom_padding + wg;
     if (focus_follows_mouse)
         get_pointer_position(&pointer_position);
     apply_layout(m, d, d->root, rect, rect);
diff --git a/types.c b/types.c
index 659c1bbeeed1baa99b79347dcb3f1f0c84457f40..7e5df6786ae6e98cdfefabd47ea3588194ffe30c 100644 (file)
--- a/types.c
+++ b/types.c
@@ -27,6 +27,7 @@ monitor_t *make_monitor(xcb_rectangle_t *rect)
         m->rectangle = *rect;
     else
         warn("no rectangle was given for monitor '%s'\n", m->name);
+    m->top_padding = m->right_padding = m->bottom_padding = m->left_padding = 0;
     return m;
 }
 
diff --git a/types.h b/types.h
index 9458b7738020067606b89598f11454372b40c657..b50c438a8fd539d5c8d89bee84eb00371505fddc 100644 (file)
--- a/types.h
+++ b/types.h
@@ -132,6 +132,10 @@ typedef struct monitor_t monitor_t;
 struct monitor_t {
     char name[MAXLEN];
     xcb_rectangle_t rectangle;
+    int top_padding;
+    int right_padding;
+    int bottom_padding;
+    int left_padding;
     desktop_t *desk;
     desktop_t *last_desk;
     desktop_t *desk_head;