- `shift left|right|up|down` — Exchange the current window with the given neighbor.
-- `swap` — Swap the focused window the last focused window.
+- `swap [--swap-focus|--keep-focus]` — Swap the focused window the last focused window.
- `push left|right|up|down` — Push the fence located in the given direction.
.BI shift " left|right|up|down"
Exchange the current window with the given neighbor.
.TP
-.BI swap
+.BI swap " [--swap-focus|--keep-focus]"
Swap the focused window with the last focused window.
.TP
.BI push " left|right|up|down"
remove_rule_by_uid(uid);
return;
} else if (strcmp(cmd, "swap") == 0) {
- swap_nodes(mon->desk->focus, history_get(mon->desk->history, 1));
+ 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)
+ focus_node(mon, mon->desk, last_focus);
} else if (strcmp(cmd, "alternate") == 0) {
focus_node(mon, mon->desk, history_get(mon->desk->history, 1));
return;
return false;
}
+bool parse_swap_option(char *s, swap_option_t *o)
+{
+ if (s == NULL || strcmp(s, "--swap-focus") == 0) {
+ *o = SWAP_OPTION_SWAP_FOCUS;
+ return true;
+ } else if (strcmp(s, "--keep-focus") == 0) {
+ *o = SWAP_OPTION_KEEP_FOCUS;
+ return true;
+ }
+ return false;
+}
+
bool parse_rotate(char *s, rotate_t *r)
{
if (strcmp(s, "clockwise") == 0) {
bool parse_circulate_direction(char *, circulate_dir_t *);
bool parse_list_option(char *, list_option_t *);
bool parse_send_option(char *, send_option_t *);
+bool parse_swap_option(char *, swap_option_t *);
bool parse_skip_client(char *, skip_client_t *);
bool parse_skip_desktop(char *, skip_desktop_t *);
bool parse_rotate(char *, rotate_t *);