]> git.lizzy.rs Git - bspwm.git/blobdiff - messages.c
Simply history removal
[bspwm.git] / messages.c
index 0cded9e5f2df202763b249bd6cd49f3c5cd36fef..11f4a1ca9f6a2c616a44d3ec8889eedb21ff933e 100644 (file)
@@ -55,7 +55,15 @@ void process_message(char *msg, char *rsp)
         list_windows(rsp);
         return;
     } else if (strcmp(cmd, "list_history") == 0) {
-        list_history(mon->desk, rsp);
+        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;
@@ -78,6 +86,8 @@ void process_message(char *msg, char *rsp)
             if (parse_flip(flp, &f))
                 flip_tree(mon->desk->root, f);
         }
+    } else if (strcmp(cmd, "balance") == 0) {
+        balance_tree(mon->desk->root);
     } else if (strcmp(cmd, "grab_pointer") == 0) {
         char *pac = strtok(NULL, TOK_SEP);
         if (pac != NULL) {
@@ -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)) {
+            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)
@@ -223,7 +232,7 @@ void process_message(char *msg, char *rsp)
                 if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW)
                     select_monitor(m);
             }
-        } 
+        }
     } else if (strcmp(cmd, "drop_to") == 0) {
         char *dir = strtok(NULL, TOK_SEP);
         if (dir != 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);
@@ -367,6 +376,8 @@ void process_message(char *msg, char *rsp)
             while (arg != NULL) {
                 if (strcmp(arg, "floating") == 0) {
                     rule->effect.floating = true;
+                } else if (strcmp(arg, "follow") == 0) {
+                    rule->effect.follow = true;
                 } else {
                     desktop_location_t loc;
                     if (locate_desktop(arg, &loc)) {
@@ -387,11 +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->focus, 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) {
-        node_list_t *a = mon->desk->focus_history->head->prev;
-        if (a != NULL)
-            focus_node(mon, mon->desk, a->node, 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,12 +441,10 @@ 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, "reload_autostart") == 0) {
-        run_autostart();
-    } else if (strcmp(cmd, "reload_settings") == 0) {
-        load_settings();
     } else if (strcmp(cmd, "restore") == 0) {
         char *arg = strtok(NULL, TOK_SEP);
         restore(arg);
@@ -455,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) {
@@ -497,15 +515,16 @@ void set_setting(char *name, char *value, char *rsp)
             gapless_monocle = b;
     } else if (strcmp(name, "focus_follows_pointer") == 0) {
         bool b;
-        if (parse_bool(value, &b)) {
-            if (b != focus_follows_pointer) {
-                uint32_t values[] = {(focus_follows_pointer ? CLIENT_EVENT_MASK : CLIENT_EVENT_MASK_FFP)};
-                for (monitor_t *m = mon_head; m != NULL; m = m->next)
-                    for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
-                        for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n))
-                            xcb_change_window_attributes(dpy, n->client->window, XCB_CW_EVENT_MASK, values);
-
-            }
+        if (parse_bool(value, &b) && b != focus_follows_pointer) {
+            uint32_t values[] = {(focus_follows_pointer ? CLIENT_EVENT_MASK : CLIENT_EVENT_MASK_FFP)};
+            for (monitor_t *m = mon_head; m != NULL; m = m->next)
+                for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
+                    for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n))
+                        xcb_change_window_attributes(dpy, n->client->window, XCB_CW_EVENT_MASK, values);
+            if (focus_follows_pointer)
+                disable_motion_recorder();
+            else
+                enable_motion_recorder();
             focus_follows_pointer = b;
         }
     } else if (strcmp(name, "adaptative_raise") == 0) {
@@ -516,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();
@@ -537,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)
@@ -571,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
@@ -631,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) {