]> git.lizzy.rs Git - bspwm.git/blobdiff - messages.c
Merge branch 'master' into status
[bspwm.git] / messages.c
index c16cfa6eac0b9a9eb34078cc9434015be90614c0..44da37c4fc1a20bdbbee7a8f076f178cb232a631 100644 (file)
@@ -82,11 +82,13 @@ void process_message(char *msg, char *rsp)
                 }
             }
         }
+        put_status();
     } else if (strcmp(cmd, "cycle_layout") == 0) {
         if (mon->desk->layout == LAYOUT_MONOCLE)
             mon->desk->layout = LAYOUT_TILED;
         else
             mon->desk->layout = LAYOUT_MONOCLE;
+        put_status();
     } else if (strcmp(cmd, "shift") == 0) {
         char *dir = strtok(NULL, TOK_SEP);
         if (dir != NULL) {
@@ -104,6 +106,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)
@@ -161,6 +182,7 @@ void process_message(char *msg, char *rsp)
                 char *new_name = strtok(NULL, TOK_SEP);
                 if (new_name != NULL) {
                     strncpy(m->name, new_name, sizeof(m->name));
+                    put_status();
                 }
             }
         }
@@ -173,6 +195,7 @@ void process_message(char *msg, char *rsp)
                 if (new_name != NULL) {
                     strncpy(loc.desktop->name, new_name, sizeof(loc.desktop->name));
                     ewmh_update_desktop_names();
+                    put_status();
                 }
             }
         }
@@ -340,13 +363,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);
@@ -389,6 +412,14 @@ void set_setting(char *name, char *value, char *rsp)
         bool b;
         if (parse_bool(value, &b))
             focus_follows_mouse = b;
+    } else if (strcmp(name, "adaptative_raise") == 0) {
+        bool b;
+        if (parse_bool(value, &b))
+            adaptative_raise = b;
+    } else if (strcmp(name, "status_stdout") == 0) {
+        bool b;
+        if (parse_bool(value, &b))
+            status_stdout = b;
     } else if (strcmp(name, "wm_name") == 0) {
         strncpy(wm_name, value, sizeof(wm_name));
         ewmh_update_wm_name();
@@ -401,6 +432,22 @@ void set_setting(char *name, char *value, char *rsp)
             grab_buttons();
         }
         return;
+    } else if (strcmp(name, "numlock_modifier") == 0) {
+        unsigned int m;
+        if (parse_modifier_mask(value, &m)) {
+            ungrab_buttons();
+            numlock_modifier = m;
+            grab_buttons();
+        }
+        return;
+    } else if (strcmp(name, "capslock_modifier") == 0) {
+        unsigned int m;
+        if (parse_modifier_mask(value, &m)) {
+            ungrab_buttons();
+            capslock_modifier = m;
+            grab_buttons();
+        }
+        return;
     } else {
         snprintf(rsp, BUFSIZ, "unknown setting: %s", name);
         return;
@@ -425,13 +472,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)
@@ -458,10 +505,18 @@ void get_setting(char *name, char* rsp)
         snprintf(rsp, BUFSIZ, "%s", BOOLSTR(gapless_monocle));
     else if (strcmp(name, "focus_follows_mouse") == 0)
         snprintf(rsp, BUFSIZ, "%s", BOOLSTR(focus_follows_mouse));
+    else if (strcmp(name, "adaptative_raise") == 0)
+        snprintf(rsp, BUFSIZ, "%s", BOOLSTR(adaptative_raise));
+    else if (strcmp(name, "status_stdout") == 0)
+        snprintf(rsp, BUFSIZ, "%s", BOOLSTR(status_stdout));
     else if (strcmp(name, "wm_name") == 0)
         snprintf(rsp, BUFSIZ, "%s", wm_name);
     else if (strcmp(name, "button_modifier") == 0)
         print_modifier_mask(rsp, button_modifier);
+    else if (strcmp(name, "numlock_modifier") == 0)
+        print_modifier_mask(rsp, numlock_modifier);
+    else if (strcmp(name, "capslock_modifier") == 0)
+        print_modifier_mask(rsp, capslock_modifier);
     else
         snprintf(rsp, BUFSIZ, "unknown setting: %s", name);
 }
@@ -621,7 +676,16 @@ bool parse_fence_move(char *s, fence_move_t *m)
 
 bool parse_modifier_mask(char *s, unsigned int *m)
 {
-    if (strcmp(s, "mod1") == 0) {
+    if (strcmp(s, "shift") == 0) {
+        *m = XCB_MOD_MASK_SHIFT;
+        return true;
+    } else if (strcmp(s, "control") == 0) {
+        *m = XCB_MOD_MASK_CONTROL;
+        return true;
+    } else if (strcmp(s, "lock") == 0) {
+        *m = XCB_MOD_MASK_LOCK;
+        return true;
+    } else if (strcmp(s, "mod1") == 0) {
         *m = XCB_MOD_MASK_1;
         return true;
     } else if (strcmp(s, "mod2") == 0) {
@@ -643,6 +707,15 @@ bool parse_modifier_mask(char *s, unsigned int *m)
 void print_modifier_mask(char *s, unsigned int m)
 {
     switch(m) {
+        case XCB_MOD_MASK_SHIFT:
+            snprintf(s, BUFSIZ, "shift");
+            break;
+        case XCB_MOD_MASK_CONTROL:
+            snprintf(s, BUFSIZ, "control");
+            break;
+        case XCB_MOD_MASK_LOCK:
+            snprintf(s, BUFSIZ, "lock");
+            break;
         case XCB_MOD_MASK_1:
             snprintf(s, BUFSIZ, "mod1");
             break;