} else if (strcmp(cmd, "list_windows") == 0) {
list_windows(rsp);
return;
+ } else if (strcmp(cmd, "list_history") == 0) {
+ list_history(rsp);
+ return;
} else if (strcmp(cmd, "list_rules") == 0) {
list_rules(rsp);
return;
char *deg = strtok(NULL, TOK_SEP);
if (deg != NULL) {
rotate_t r;
- if (parse_rotate(deg, &r)) {
+ if (parse_rotate(deg, &r))
rotate_tree(mon->desk->root, r);
- }
}
+ } else if (strcmp(cmd, "flip") == 0) {
+ char *flp = strtok(NULL, TOK_SEP);
+ if (flp != NULL) {
+ flip_t f;
+ if (parse_flip(flp, &f))
+ flip_tree(mon->desk->root, f);
+ }
+ } else if (strcmp(cmd, "balance") == 0) {
+ balance_tree(mon->desk->root);
} else if (strcmp(cmd, "grab_pointer") == 0) {
char *pac = strtok(NULL, TOK_SEP);
if (pac != NULL) {
char *dir = strtok(NULL, TOK_SEP);
if (dir != NULL) {
direction_t d;
- if (parse_direction(dir, &d)) {
- swap_nodes(mon->desk->focus, find_neighbor(mon->desk->focus, 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));
}
} else if (strcmp(cmd, "toggle_fullscreen") == 0) {
if (mon->desk->focus != NULL)
char *opt = strtok(NULL, TOK_SEP);
send_option_t o;
if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW)
- select_monitor(m);
+ focus_node(m, m->desk, m->desk->focus);
}
}
} else if (strcmp(cmd, "send_to_monitor") == 0) {
char *opt = strtok(NULL, TOK_SEP);
send_option_t o;
if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW)
- select_monitor(m);
+ focus_node(m, m->desk, m->desk->focus);
}
- }
+ }
} else if (strcmp(cmd, "drop_to") == 0) {
char *dir = strtok(NULL, TOK_SEP);
if (dir != NULL) {
char *opt = strtok(NULL, TOK_SEP);
send_option_t o;
if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW)
- select_desktop(d);
+ focus_node(mon, d, d->focus);
}
}
} else if (strcmp(cmd, "send_to") == 0) {
arrange(loc.monitor, loc.desktop);
char *opt = strtok(NULL, TOK_SEP);
send_option_t o;
- if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW) {
- select_monitor(loc.monitor);
- select_desktop(loc.desktop);
- }
+ if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW)
+ focus_node(loc.monitor, loc.desktop, loc.desktop->focus);
}
}
} else if (strcmp(cmd, "rename_monitor") == 0) {
char *name = strtok(NULL, TOK_SEP);
if (name != NULL) {
monitor_t *m = find_monitor(name);
- if (m != NULL)
- select_monitor(m);
+ if (m != NULL) {
+ if (auto_alternate && m == mon && last_mon != NULL)
+ focus_node(last_mon, last_mon->desk, last_mon->desk->focus);
+ else
+ focus_node(m, m->desk, m->desk->focus);
+ }
}
} else if (strcmp(cmd, "use") == 0) {
char *name = strtok(NULL, TOK_SEP);
if (name != NULL) {
desktop_location_t loc;
if (locate_desktop(name, &loc)) {
- select_monitor(loc.monitor);
- select_desktop(loc.desktop);
+ if (auto_alternate && loc.desktop == mon->desk && mon->last_desk != NULL)
+ focus_node(mon, mon->last_desk, mon->last_desk->focus);
+ else
+ focus_node(loc.monitor, loc.desktop, loc.desktop->focus);
}
}
} else if (strcmp(cmd, "cycle_monitor") == 0) {
}
}
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)))
while (arg != NULL) {
if (strcmp(arg, "floating") == 0) {
rule->effect.floating = true;
+ } else if (strcmp(arg, "follow") == 0) {
+ rule->effect.follow = true;
} else {
desktop_location_t loc;
if (locate_desktop(arg, &loc)) {
remove_rule_by_uid(uid);
return;
} else if (strcmp(cmd, "swap") == 0) {
- swap_nodes(mon->desk->focus, mon->desk->last_focus);
+ 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, mon->desk->last_focus, true);
+ focus_node(mon, mon->desk, history_get(mon->desk->history, 1));
return;
} else if (strcmp(cmd, "alternate_desktop") == 0) {
- select_desktop(mon->last_desk);
+ if (mon->last_desk != NULL)
+ focus_node(mon, mon->last_desk, mon->last_desk->focus);
} else if (strcmp(cmd, "alternate_monitor") == 0) {
- select_monitor(last_mon);
+ if (last_mon != NULL)
+ focus_node(last_mon, last_mon->desk, last_mon->desk->focus);
} else if (strcmp(cmd, "add_in") == 0) {
char *name = strtok(NULL, TOK_SEP);
if (name != NULL) {
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)
+ if (mon->desk->focus == NULL || mon->desk->focus->client->fullscreen)
return;
char *dir = strtok(NULL, TOK_SEP);
if (dir != NULL) {
direction_t d;
if (parse_direction(dir, &d)) {
- node_t *n = find_neighbor(mon->desk->focus, d);
- focus_node(mon, mon->desk, n, true);
+ node_t *n;
+ if (focus_by_distance)
+ n = nearest_neighbor(mon->desk, mon->desk->focus, d);
+ else
+ n = find_neighbor(mon->desk->focus, d);
+ focus_node(mon, mon->desk, n);
}
}
- if (mon->desk->layout == LAYOUT_TILED)
- return;
+ return;
+ } else if (strcmp(cmd, "put_status") == 0) {
+ put_status();
+ return;
} else if (strcmp(cmd, "adopt_orphans") == 0) {
adopt_orphans();
- } else if (strcmp(cmd, "reload_autostart") == 0) {
- run_autostart();
- } else if (strcmp(cmd, "reload_settings") == 0) {
- load_settings();
- } else if (strcmp(cmd, "restore") == 0) {
+ return;
+ } else if (strcmp(cmd, "restore_layout") == 0) {
char *arg = strtok(NULL, TOK_SEP);
- restore(arg);
+ restore_layout(arg);
+ return;
+ } else if (strcmp(cmd, "restore_history") == 0) {
+ char *arg = strtok(NULL, TOK_SEP);
+ restore_history(arg);
+ return;
} else if (strcmp(cmd, "quit") == 0) {
char *arg = strtok(NULL, TOK_SEP);
if (arg != NULL)
if (name == NULL || value == NULL)
return;
- if (strcmp(name, "inner_border_width") == 0) {
- sscanf(value, "%u", &inner_border_width);
- border_width = inner_border_width + main_border_width + outer_border_width;
- } else if (strcmp(name, "main_border_width") == 0) {
- sscanf(value, "%u", &main_border_width);
- border_width = inner_border_width + main_border_width + outer_border_width;
- } else if (strcmp(name, "outer_border_width") == 0) {
- sscanf(value, "%u", &outer_border_width);
- border_width = inner_border_width + main_border_width + outer_border_width;
+ if (strcmp(name, "border_width") == 0) {
+ sscanf(value, "%u", &border_width);
} else if (strcmp(name, "window_gap") == 0) {
sscanf(value, "%i", &window_gap);
+ } else if (strcmp(name, "split_ratio") == 0) {
+ sscanf(value, "%lf", &split_ratio);
} else if (strcmp(name, "left_padding") == 0) {
sscanf(value, "%i", &mon->left_padding);
} else if (strcmp(name, "right_padding") == 0) {
} else if (strcmp(name, "normal_border_color") == 0) {
strncpy(normal_border_color, value, sizeof(normal_border_color));
normal_border_color_pxl = get_color(normal_border_color);
- } else if (strcmp(name, "inner_border_color") == 0) {
- strncpy(inner_border_color, value, sizeof(inner_border_color));
- inner_border_color_pxl = get_color(inner_border_color);
- } else if (strcmp(name, "outer_border_color") == 0) {
- strncpy(outer_border_color, value, sizeof(outer_border_color));
- outer_border_color_pxl = get_color(outer_border_color);
} else if (strcmp(name, "presel_border_color") == 0) {
strncpy(presel_border_color, value, sizeof(presel_border_color));
presel_border_color_pxl = get_color(presel_border_color);
gapless_monocle = b;
} else if (strcmp(name, "focus_follows_pointer") == 0) {
bool b;
- if (parse_bool(value, &b)) {
- if (b != focus_follows_pointer) {
- uint32_t values[] = {(focus_follows_pointer ? CLIENT_EVENT_MASK : CLIENT_EVENT_MASK_FFP)};
- for (monitor_t *m = mon_head; m != NULL; m = m->next)
- for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
- for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n))
- xcb_change_window_attributes(dpy, n->client->window, XCB_CW_EVENT_MASK, values);
-
- }
+ if (parse_bool(value, &b) && b != focus_follows_pointer) {
+ uint32_t values[] = {(focus_follows_pointer ? CLIENT_EVENT_MASK : CLIENT_EVENT_MASK_FFP)};
+ for (monitor_t *m = mon_head; m != NULL; m = m->next)
+ for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
+ for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root))
+ xcb_change_window_attributes(dpy, n->client->window, XCB_CW_EVENT_MASK, values);
+ if (focus_follows_pointer)
+ disable_motion_recorder();
+ else
+ enable_motion_recorder();
focus_follows_pointer = b;
}
+ return;
} else if (strcmp(name, "adaptative_raise") == 0) {
bool b;
if (parse_bool(value, &b))
adaptative_raise = b;
+ return;
+ } else if (strcmp(name, "apply_shadow_property") == 0) {
+ bool b;
+ if (parse_bool(value, &b))
+ apply_shadow_property = b;
+ return;
+ } else if (strcmp(name, "auto_alternate") == 0) {
+ bool b;
+ if (parse_bool(value, &b))
+ auto_alternate = b;
+ return;
+ } else if (strcmp(name, "focus_by_distance") == 0) {
+ bool b;
+ if (parse_bool(value, &b))
+ focus_by_distance = b;
+ return;
} else if (strcmp(name, "wm_name") == 0) {
strncpy(wm_name, value, sizeof(wm_name));
ewmh_update_wm_name();
if (name == NULL)
return;
- if (strcmp(name, "inner_border_width") == 0)
- snprintf(rsp, BUFSIZ, "%u", inner_border_width);
- else if (strcmp(name, "main_border_width") == 0)
- snprintf(rsp, BUFSIZ, "%u", main_border_width);
- else if (strcmp(name, "outer_border_width") == 0)
- snprintf(rsp, BUFSIZ, "%u", outer_border_width);
- else if (strcmp(name, "border_width") == 0)
+ if (strcmp(name, "border_width") == 0)
snprintf(rsp, BUFSIZ, "%u", border_width);
else if (strcmp(name, "window_gap") == 0)
snprintf(rsp, BUFSIZ, "%i", window_gap);
+ else if (strcmp(name, "split_ratio") == 0)
+ snprintf(rsp, BUFSIZ, "%lf", split_ratio);
else if (strcmp(name, "left_padding") == 0)
snprintf(rsp, BUFSIZ, "%i", mon->left_padding);
else if (strcmp(name, "right_padding") == 0)
snprintf(rsp, BUFSIZ, "%s (%06X)", active_border_color, active_border_color_pxl);
else if (strcmp(name, "normal_border_color") == 0)
snprintf(rsp, BUFSIZ, "%s (%06X)", normal_border_color, normal_border_color_pxl);
- else if (strcmp(name, "inner_border_color") == 0)
- snprintf(rsp, BUFSIZ, "%s (%06X)", inner_border_color, inner_border_color_pxl);
- else if (strcmp(name, "outer_border_color") == 0)
- snprintf(rsp, BUFSIZ, "%s (%06X)", outer_border_color, outer_border_color_pxl);
else if (strcmp(name, "presel_border_color") == 0)
snprintf(rsp, BUFSIZ, "%s (%06X)", presel_border_color, presel_border_color_pxl);
else if (strcmp(name, "focused_locked_border_color") == 0)
snprintf(rsp, BUFSIZ, "%s", BOOLSTR(focus_follows_pointer));
else if (strcmp(name, "adaptative_raise") == 0)
snprintf(rsp, BUFSIZ, "%s", BOOLSTR(adaptative_raise));
+ else if (strcmp(name, "apply_shadow_property") == 0)
+ snprintf(rsp, BUFSIZ, "%s", BOOLSTR(apply_shadow_property));
+ else if (strcmp(name, "auto_alternate") == 0)
+ 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, "wm_name") == 0)
snprintf(rsp, BUFSIZ, "%s", wm_name);
else
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) {
return false;
}
+bool parse_flip(char *s, flip_t *f)
+{
+ if (strcmp(s, "horizontal") == 0) {
+ *f = FLIP_HORIZONTAL;
+ return true;
+ } else if (strcmp(s, "vertical") == 0) {
+ *f = FLIP_VERTICAL;
+ return true;
+ }
+ return false;
+}
+
bool parse_fence_move(char *s, fence_move_t *m)
{
if (strcmp(s, "push") == 0) {
if (strcmp(s, "move") == 0) {
*a = ACTION_MOVE;
return true;
+ } else if (strcmp(s, "resize_corner") == 0) {
+ *a = ACTION_RESIZE_CORNER;
+ return true;
+ } else if (strcmp(s, "resize_side") == 0) {
+ *a = ACTION_RESIZE_SIDE;
+ return true;
} else if (strcmp(s, "focus") == 0) {
*a = ACTION_FOCUS;
return true;
- } else if (strcmp(s, "resize") == 0) {
- *a = ACTION_RESIZE;
- return true;
}
return false;
}