]> git.lizzy.rs Git - bspwm.git/blobdiff - messages.c
Rename textwidth to txtw
[bspwm.git] / messages.c
index c22431047f99389fb83bc1af63dff78f3152e25d..0c7c25d8f2a4c63a5090ad663afd33b54245dd1b 100644 (file)
@@ -115,13 +115,18 @@ void process_message(char *msg, char *rsp)
         else
             change_layout(mon, mon->desk, LAYOUT_MONOCLE);
     } else if (strcmp(cmd, "shift") == 0) {
+        node_t *f = mon->desk->focus;
+        if (f == NULL)
+            return;
         char *dir = strtok(NULL, TOK_SEP);
         if (dir != NULL) {
             direction_t d;
-            if (parse_direction(dir, &d))
-                swap_nodes(mon->desk->focus, focus_by_distance ? nearest_neighbor(mon->desk, mon->desk->focus, d) : find_neighbor(mon->desk->focus, d));
+            if (parse_direction(dir, &d)) {
+                node_t *n = nearest_neighbor(mon->desk, f, d);
+                swap_nodes(f, n);
+                arrange(mon, mon->desk);
+            }
         }
-        arrange(mon, mon->desk);
     } else if (strcmp(cmd, "toggle_fullscreen") == 0) {
         toggle_fullscreen(mon->desk, mon->desk->focus);
         arrange(mon, mon->desk);
@@ -445,17 +450,14 @@ void process_message(char *msg, char *rsp)
             }
         }
     } else if (strcmp(cmd, "focus") == 0) {
-        if (mon->desk->focus == NULL || mon->desk->focus->client->fullscreen)
+        node_t *f = mon->desk->focus;
+        if (f == NULL || f->client->fullscreen)
             return;
         char *dir = strtok(NULL, TOK_SEP);
         if (dir != NULL) {
             direction_t d;
             if (parse_direction(dir, &d)) {
-                node_t *n;
-                if (focus_by_distance)
-                    n = nearest_neighbor(mon->desk, mon->desk->focus, d);
-                else
-                    n = find_neighbor(mon->desk->focus, d);
+                node_t *n = nearest_neighbor(mon->desk, f, d);
                 focus_node(mon, mon->desk, n);
             }
         }
@@ -570,6 +572,11 @@ void set_setting(char *name, char *value, char *rsp)
         if (parse_bool(value, &b))
             focus_by_distance = b;
         return;
+    } else if (strcmp(name, "history_aware_focus") == 0) {
+        bool b;
+        if (parse_bool(value, &b))
+            history_aware_focus = b;
+        return;
     } else if (strcmp(name, "wm_name") == 0) {
         strncpy(wm_name, value, sizeof(wm_name));
         ewmh_update_wm_name();
@@ -635,6 +642,8 @@ void get_setting(char *name, char* rsp)
         snprintf(rsp, BUFSIZ, "%s", BOOLSTR(auto_alternate));
     else if (strcmp(name, "focus_by_distance") == 0)
         snprintf(rsp, BUFSIZ, "%s", BOOLSTR(focus_by_distance));
+    else if (strcmp(name, "history_aware_focus") == 0)
+        snprintf(rsp, BUFSIZ, "%s", BOOLSTR(history_aware_focus));
     else if (strcmp(name, "wm_name") == 0)
         snprintf(rsp, BUFSIZ, "%s", wm_name);
     else