]> git.lizzy.rs Git - bspwm.git/blobdiff - messages.c
Simply history removal
[bspwm.git] / messages.c
index 73ee982cf29325828547d16f9041d21f5d4eb47e..11f4a1ca9f6a2c616a44d3ec8889eedb21ff933e 100644 (file)
@@ -54,6 +54,16 @@ void process_message(char *msg, char *rsp)
     } else if (strcmp(cmd, "list_windows") == 0) {
         list_windows(rsp);
         return;
+    } else if (strcmp(cmd, "list_history") == 0) {
+        char *name = strtok(NULL, TOK_SEP);
+        if (name != NULL) {
+            desktop_location_t loc;
+            if (locate_desktop(name, &loc))
+                list_history(loc.desktop, rsp);
+        } else {
+            list_history(mon->desk, rsp);
+        }
+        return;
     } else if (strcmp(cmd, "list_rules") == 0) {
         list_rules(rsp);
         return;
@@ -126,9 +136,8 @@ void process_message(char *msg, char *rsp)
         char *dir = strtok(NULL, TOK_SEP);
         if (dir != NULL) {
             direction_t d;
-            if (parse_direction(dir, &d)) {
-                swap_nodes(mon->desk, mon->desk->focus, mon->desk, find_neighbor(mon->desk->focus, d));
-            }
+            if (parse_direction(dir, &d))
+                swap_nodes(mon->desk->focus, find_neighbor(mon->desk->focus, d));
         }
     } else if (strcmp(cmd, "toggle_fullscreen") == 0) {
         if (mon->desk->focus != NULL)
@@ -294,7 +303,7 @@ void process_message(char *msg, char *rsp)
         if (name != NULL) {
             desktop_location_t loc;
             if (locate_desktop(name, &loc)) {
-                if (loc.desktop == mon->desk) {
+                if (auto_alternate && loc.desktop == mon->desk) {
                     select_desktop(mon->last_desk);
                 } else {
                     select_monitor(loc.monitor);
@@ -389,9 +398,18 @@ void process_message(char *msg, char *rsp)
                 remove_rule_by_uid(uid);
         return;
     } else if (strcmp(cmd, "swap") == 0) {
-        swap_nodes(mon->desk, mon->desk->focus, mon->desk, mon->desk->last_focus);
+        char *arg;
+        swap_arg_t a;
+        if ((arg = strtok(NULL, TOK_SEP)) != NULL) {
+            if (parse_swap_argument(arg, &a)) {
+                node_t *n = find_by_area(mon->desk, a);
+                swap_nodes(mon->desk->focus, n);
+            }
+        } else {
+            swap_nodes(mon->desk->focus, history_get(mon->desk->history, 1));
+        }
     } else if (strcmp(cmd, "alternate") == 0) {
-        focus_node(mon, mon->desk, mon->desk->last_focus, true);
+        focus_node(mon, mon->desk, history_get(mon->desk->history, 1), true);
         return;
     } else if (strcmp(cmd, "alternate_desktop") == 0) {
         select_desktop(mon->last_desk);
@@ -423,6 +441,8 @@ void process_message(char *msg, char *rsp)
         }
         if (mon->desk->layout == LAYOUT_TILED)
             return;
+    } else if (strcmp(cmd, "put_status") == 0) {
+        put_status();
     } else if (strcmp(cmd, "adopt_orphans") == 0) {
         adopt_orphans();
     } else if (strcmp(cmd, "restore") == 0) {
@@ -451,6 +471,8 @@ void set_setting(char *name, char *value, char *rsp)
         sscanf(value, "%u", &border_width);
     } else if (strcmp(name, "window_gap") == 0) {
         sscanf(value, "%i", &window_gap);
+    } else if (strcmp(name, "split_ratio") == 0) {
+        sscanf(value, "%lf", &split_ratio);
     } else if (strcmp(name, "left_padding") == 0) {
         sscanf(value, "%i", &mon->left_padding);
     } else if (strcmp(name, "right_padding") == 0) {
@@ -513,6 +535,10 @@ void set_setting(char *name, char *value, char *rsp)
         bool b;
         if (parse_bool(value, &b))
             apply_shadow_property = b;
+    } else if (strcmp(name, "auto_alternate") == 0) {
+        bool b;
+        if (parse_bool(value, &b))
+            auto_alternate = b;
     } else if (strcmp(name, "wm_name") == 0) {
         strncpy(wm_name, value, sizeof(wm_name));
         ewmh_update_wm_name();
@@ -534,6 +560,8 @@ void get_setting(char *name, char* rsp)
         snprintf(rsp, BUFSIZ, "%u", border_width);
     else if (strcmp(name, "window_gap") == 0)
         snprintf(rsp, BUFSIZ, "%i", window_gap);
+    else if (strcmp(name, "split_ratio") == 0)
+        snprintf(rsp, BUFSIZ, "%lf", split_ratio);
     else if (strcmp(name, "left_padding") == 0)
         snprintf(rsp, BUFSIZ, "%i", mon->left_padding);
     else if (strcmp(name, "right_padding") == 0)
@@ -568,6 +596,8 @@ void get_setting(char *name, char* rsp)
         snprintf(rsp, BUFSIZ, "%s", BOOLSTR(adaptative_raise));
     else if (strcmp(name, "apply_shadow_property") == 0)
         snprintf(rsp, BUFSIZ, "%s", BOOLSTR(apply_shadow_property));
+    else if (strcmp(name, "auto_alternate") == 0)
+        snprintf(rsp, BUFSIZ, "%s", BOOLSTR(auto_alternate));
     else if (strcmp(name, "wm_name") == 0)
         snprintf(rsp, BUFSIZ, "%s", wm_name);
     else
@@ -628,6 +658,18 @@ bool parse_nearest_argument(char *s, nearest_arg_t *a)
     return false;
 }
 
+bool parse_swap_argument(char *s, swap_arg_t *a)
+{
+    if (strcmp(s, "biggest") == 0) {
+        *a = SWAP_BIGGEST;
+        return true;
+    } else if (strcmp(s, "smallest") == 0) {
+        *a = SWAP_SMALLEST;
+        return true;
+    }
+    return false;
+}
+
 bool parse_cycle_direction(char *s, cycle_dir_t *d)
 {
     if (strcmp(s, "prev") == 0) {