}
}
return;
+ } else if (strcmp(cmd, "biggest") == 0) {
+ node_t *n = find_biggest(mon->desk);
+ if (n != NULL)
+ snprintf(rsp, BUFSIZ, "0x%X", n->client->window);
+ return;
} else if (strcmp(cmd, "circulate") == 0) {
if (mon->desk->layout == LAYOUT_MONOCLE
|| (mon->desk->focus != NULL && !is_tiled(mon->desk->focus->client)))
remove_rule_by_uid(uid);
return;
} else if (strcmp(cmd, "swap") == 0) {
- 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));
- }
+ 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;
monitor_t *m = find_monitor(name);
if (m != NULL)
for (name = strtok(NULL, TOK_SEP); name != NULL; name = strtok(NULL, TOK_SEP))
- add_desktop(m, name);
+ add_desktop(m, make_desktop(name));
}
return;
} else if (strcmp(cmd, "add") == 0) {
for (char *name = strtok(NULL, TOK_SEP); name != NULL; name = strtok(NULL, TOK_SEP))
- add_desktop(mon, name);
+ add_desktop(mon, make_desktop(name));
+ return;
+ } else if (strcmp(cmd, "remove_desktop") == 0) {
+ for (char *name = strtok(NULL, TOK_SEP); name != NULL; name = strtok(NULL, TOK_SEP)) {
+ desktop_location_t loc;
+ if (locate_desktop(name, &loc)) {
+ if (loc.desktop->root == NULL && loc.monitor->desk_head != loc.monitor->desk_tail)
+ remove_desktop(loc.monitor, loc.desktop);
+ }
+ }
+ desktop_show(mon->desk);
+ update_current();
return;
} else if (strcmp(cmd, "focus") == 0) {
if (mon->desk->focus == NULL || mon->desk->focus->client->fullscreen)
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) {
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) {