} else if (strcmp(cmd, "close") == 0) {
window_close(mon->desk->focus);
} else if (strcmp(cmd, "kill") == 0) {
- window_kill(mon->desk, mon->desk->focus);
+ window_kill(mon, mon->desk, mon->desk->focus);
} else if (strcmp(cmd, "rotate") == 0) {
char *deg = strtok(NULL, TOK_SEP);
if (deg != NULL) {
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, mon->desk->focus, d);
+ if (n != NULL) {
+ swap_nodes(mon->desk->focus, n);
+ arrange(mon, mon->desk);
+ } else if (monitor_focus_fallback) {
+ monitor_t *m = nearest_monitor(d);
+ if (m != NULL)
+ transfer_node(mon, mon->desk, m, m->desk, mon->desk->focus);
+ }
+ }
}
- arrange(mon, mon->desk);
} else if (strcmp(cmd, "toggle_fullscreen") == 0) {
toggle_fullscreen(mon->desk, mon->desk->focus);
arrange(mon, mon->desk);
sscanf(value, "%lf", &mon->desk->focus->split_ratio) == 1)
window_draw_border(mon->desk->focus, true, true);
} else if (strcmp(cmd, "cancel") == 0) {
- split_mode = MODE_AUTOMATIC;
- window_draw_border(mon->desk->focus, true, true);
+ if (mon->desk->focus == NULL)
+ return;
+ char *opt = strtok(NULL, TOK_SEP);
+ cancel_option_t o;
+ if (parse_cancel_option(opt, &o))
+ reset_mode(mon->desk, mon->desk->focus, o);
} else if (strcmp(cmd, "presel") == 0) {
if (mon->desk->focus == NULL || !is_tiled(mon->desk->focus->client) || mon->desk->layout != LAYOUT_TILED)
return;
if (dir != NULL) {
direction_t d;
if (parse_direction(dir, &d)) {
- split_mode = MODE_MANUAL;
- split_dir = d;
+ mon->desk->focus->split_mode = MODE_MANUAL;
+ mon->desk->focus->split_dir = d;
char *rat = strtok(NULL, TOK_SEP);
if (rat != NULL)
sscanf(rat, "%lf", &mon->desk->focus->split_ratio);
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)
+ if (value != NULL && sscanf(value, "%lf", &n->split_ratio) == 1)
arrange(mon, mon->desk);
}
}
focus_node(m, m->desk, m->desk->focus);
}
}
+ } else if (strcmp(cmd, "focus_monitor") == 0) {
+ char *dir = strtok(NULL, TOK_SEP);
+ if (dir != NULL) {
+ direction_t d;
+ if (parse_direction(dir, &d)) {
+ monitor_t *m = nearest_monitor(d);
+ if (m != NULL)
+ focus_node(m, m->desk, m->desk->focus);
+ }
+ }
} else if (strcmp(cmd, "use") == 0) {
char *name = strtok(NULL, TOK_SEP);
if (name != NULL) {
}
}
} else if (strcmp(cmd, "focus") == 0) {
- 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 = NULL;
- if (history_aware_focus)
- n = nearest_from_history(mon->desk->history, f, d);
- if (n == NULL) {
- if (focus_by_distance) {
- n = nearest_neighbor(mon->desk, f, d);
- } else {
- n = find_neighbor(f, d);
- }
+ node_t *n = nearest_neighbor(mon->desk, mon->desk->focus, d);
+ if (n != NULL) {
+ focus_node(mon, mon->desk, n);
+ } else if (monitor_focus_fallback) {
+ monitor_t *m = nearest_monitor(d);
+ if (m != NULL)
+ focus_node(m, m->desk, m->desk->focus);
}
- focus_node(mon, mon->desk, n);
}
}
} else if (strcmp(cmd, "put_status") == 0) {
if (parse_bool(value, &b))
pointer_follows_monitor = b;
return;
+ } else if (strcmp(name, "monitor_focus_fallback") == 0) {
+ bool b;
+ if (parse_bool(value, &b))
+ monitor_focus_fallback = b;
+ return;
} else if (strcmp(name, "adaptative_raise") == 0) {
bool b;
if (parse_bool(value, &b))
snprintf(rsp, BUFSIZ, "%s", BOOLSTR(focus_follows_pointer));
else if (strcmp(name, "pointer_follows_monitor") == 0)
snprintf(rsp, BUFSIZ, "%s", BOOLSTR(pointer_follows_monitor));
+ else if (strcmp(name, "monitor_focus_fallback") == 0)
+ snprintf(rsp, BUFSIZ, "%s", BOOLSTR(monitor_focus_fallback));
else if (strcmp(name, "adaptative_raise") == 0)
snprintf(rsp, BUFSIZ, "%s", BOOLSTR(adaptative_raise));
else if (strcmp(name, "apply_shadow_property") == 0)
return false;
}
+bool parse_cancel_option(char *s, cancel_option_t *o)
+{
+ if (s == NULL) {
+ *o = CANCEL_OPTION_FOCUSED;
+ return true;
+ } else if (strcmp(s, "--all") == 0) {
+ *o = CANCEL_OPTION_ALL;
+ return true;
+ }
+ return false;
+}
+
bool parse_rotate(char *s, rotate_t *r)
{
if (strcmp(s, "clockwise") == 0) {