} else if (strcmp(cmd, "layout") == 0) {
char *lyt = strtok(NULL, TOK_SEP);
if (lyt != NULL) {
- layout_t y;
- if (parse_layout(lyt, &y)) {
+ layout_t l;
+ if (parse_layout(lyt, &l)) {
char *name = strtok(NULL, TOK_SEP);
if (name == NULL) {
- mon->desk->layout = y;
+ change_layout(mon, mon->desk, l);
} else {
desktop_location_t loc;
do {
if (locate_desktop(name, &loc))
- loc.desktop->layout = y;
+ change_layout(loc.monitor, loc.desktop, l);
} while ((name = strtok(NULL, TOK_SEP)) != NULL);
}
}
}
- put_status();
- arrange(mon, mon->desk);
} else if (strcmp(cmd, "cycle_layout") == 0) {
if (mon->desk->layout == LAYOUT_MONOCLE)
- mon->desk->layout = LAYOUT_TILED;
+ change_layout(mon, mon->desk, LAYOUT_TILED);
else
- mon->desk->layout = LAYOUT_MONOCLE;
- put_status();
- arrange(mon, mon->desk);
+ 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) {
- if (mon->desk->focus != NULL)
- toggle_fullscreen(mon, mon->desk, mon->desk->focus);
+ toggle_fullscreen(mon->desk, mon->desk->focus);
+ arrange(mon, mon->desk);
} else if (strcmp(cmd, "toggle_floating") == 0) {
toggle_floating(mon->desk, mon->desk->focus);
+ arrange(mon, mon->desk);
} else if (strcmp(cmd, "toggle_locked") == 0) {
- if (mon->desk->focus != NULL)
- toggle_locked(mon, mon->desk, mon->desk->focus);
+ toggle_locked(mon, mon->desk, mon->desk->focus);
} else if (strcmp(cmd, "toggle_visibility") == 0) {
toggle_visibility();
} else if (strcmp(cmd, "pad") == 0) {
if (dir != NULL) {
fence_move_t m;
direction_t d;
- if (parse_fence_move(cmd, &m) && parse_direction(dir, &d))
+ if (parse_fence_move(cmd, &m) && parse_direction(dir, &d)) {
move_fence(mon->desk->focus, d, m);
+ arrange(mon, mon->desk);
+ }
+ }
+ } else if (strcmp(cmd, "fence_ratio") == 0) {
+ char *dir = strtok(NULL, TOK_SEP);
+ if (dir != NULL) {
+ direction_t d;
+ node_t *n;
+ if (parse_direction(dir, &d) && (n = find_fence(mon->desk->focus, d)) != NULL) {
+ char *value = strtok(NULL, TOK_SEP);
+ if (sscanf(value, "%lf", &n->split_ratio) == 1)
+ arrange(mon, mon->desk);
+ }
}
- arrange(mon, mon->desk);
} else if (strcmp(cmd, "drop_to_monitor") == 0) {
char *dir = strtok(NULL, TOK_SEP);
if (dir != NULL) {
if (sscanf(arg, "%X", &uid) > 0)
remove_rule_by_uid(uid);
} else if (strcmp(cmd, "swap") == 0) {
- node_t *last_focus = history_get(mon->desk->history, 1);
- swap_nodes(mon->desk->focus, last_focus);
char *opt = strtok(NULL, TOK_SEP);
swap_option_t o;
- if (parse_swap_option(opt, &o) && o == SWAP_OPTION_SWAP_FOCUS)
+ if (!parse_swap_option(opt, &o))
+ return;
+ node_t *last_focus = history_get(mon->desk->history, 1);
+ swap_nodes(mon->desk->focus, last_focus);
+ arrange(mon, mon->desk);
+ if (o == SWAP_OPTION_SWAP_FOCUS)
focus_node(mon, mon->desk, last_focus);
} else if (strcmp(cmd, "alternate") == 0) {
focus_node(mon, mon->desk, history_get(mon->desk->history, 1));
}
}
} 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);
}
}
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();
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