}
coordinates_t ref = {mon, mon->desk, mon->desk->focus};
- coordinates_t trg = ref;
if ((*args)[0] != OPT_CHR) {
int ret;
- if ((ret = node_from_desc(*args, &ref, &trg)) == SELECTOR_OK) {
+ coordinates_t tmp = ref;
+ if ((ret = node_from_desc(*args, &tmp, &ref)) == SELECTOR_OK) {
num--, args++;
} else {
handle_failure(ret, "node", *args, rsp);
while (num > 0) {
if (streq("-f", *args) || streq("--focus", *args)) {
- coordinates_t dst = trg;
+ coordinates_t dst = ref;
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
num--, args++;
int ret;
- if ((ret = node_from_desc(*args, &trg, &dst)) != SELECTOR_OK) {
+ if ((ret = node_from_desc(*args, &ref, &dst)) != SELECTOR_OK) {
handle_failure(ret, "node -f", *args, rsp);
break;
}
break;
}
} else if (streq("-a", *args) || streq("--activate", *args)) {
- coordinates_t dst = trg;
+ coordinates_t dst = ref;
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
num--, args++;
int ret;
- if ((ret = node_from_desc(*args, &trg, &dst)) != SELECTOR_OK) {
+ if ((ret = node_from_desc(*args, &ref, &dst)) != SELECTOR_OK) {
handle_failure(ret, "node -a", *args, rsp);
break;
}
}
coordinates_t dst;
int ret;
- if ((ret = desktop_from_desc(*args, &trg, &dst)) == SELECTOR_OK) {
- if (transfer_node(trg.monitor, trg.desktop, trg.node, dst.monitor, dst.desktop, dst.desktop->focus)) {
- trg.monitor = dst.monitor;
- trg.desktop = dst.desktop;
+ if ((ret = desktop_from_desc(*args, &ref, &dst)) == SELECTOR_OK) {
+ if (transfer_node(ref.monitor, ref.desktop, ref.node, dst.monitor, dst.desktop, dst.desktop->focus)) {
+ ref.monitor = dst.monitor;
+ ref.desktop = dst.desktop;
} else {
fail(rsp, "");
break;
}
coordinates_t dst;
int ret;
- if ((ret = monitor_from_desc(*args, &trg, &dst)) == SELECTOR_OK) {
- if (transfer_node(trg.monitor, trg.desktop, trg.node, dst.monitor, dst.monitor->desk, dst.monitor->desk->focus)) {
- trg.monitor = dst.monitor;
- trg.desktop = dst.monitor->desk;
+ if ((ret = monitor_from_desc(*args, &ref, &dst)) == SELECTOR_OK) {
+ if (transfer_node(ref.monitor, ref.desktop, ref.node, dst.monitor, dst.monitor->desk, dst.monitor->desk->focus)) {
+ ref.monitor = dst.monitor;
+ ref.desktop = dst.monitor->desk;
} else {
fail(rsp, "");
break;
}
coordinates_t dst;
int ret;
- if ((ret = node_from_desc(*args, &trg, &dst)) == SELECTOR_OK) {
- if (transfer_node(trg.monitor, trg.desktop, trg.node, dst.monitor, dst.desktop, dst.node)) {
- trg.monitor = dst.monitor;
- trg.desktop = dst.desktop;
+ if ((ret = node_from_desc(*args, &ref, &dst)) == SELECTOR_OK) {
+ if (transfer_node(ref.monitor, ref.desktop, ref.node, dst.monitor, dst.desktop, dst.node)) {
+ ref.monitor = dst.monitor;
+ ref.desktop = dst.desktop;
} else {
fail(rsp, "");
break;
}
coordinates_t dst;
int ret;
- if ((ret = node_from_desc(*args, &trg, &dst)) == SELECTOR_OK) {
- if (swap_nodes(trg.monitor, trg.desktop, trg.node, dst.monitor, dst.desktop, dst.node)) {
- trg.monitor = dst.monitor;
- trg.desktop = dst.desktop;
+ if ((ret = node_from_desc(*args, &ref, &dst)) == SELECTOR_OK) {
+ if (swap_nodes(ref.monitor, ref.desktop, ref.node, dst.monitor, dst.desktop, dst.node)) {
+ ref.monitor = dst.monitor;
+ ref.desktop = dst.desktop;
} else {
fail(rsp, "");
break;
}
stack_layer_t lyr;
if (parse_stack_layer(*args, &lyr)) {
- if (!set_layer(trg.monitor, trg.desktop, trg.node, lyr)) {
+ if (!set_layer(ref.monitor, ref.desktop, ref.node, lyr)) {
fail(rsp, "");
break;
}
(*args)++;
}
if (parse_client_state(*args, &cst)) {
- if (alternate && trg.node != NULL && trg.node->client != NULL &&
- trg.node->client->state == cst) {
- cst = trg.node->client->last_state;
+ if (alternate && ref.node != NULL && ref.node->client != NULL &&
+ ref.node->client->state == cst) {
+ cst = ref.node->client->last_state;
}
- if (!set_state(trg.monitor, trg.desktop, trg.node, cst)) {
+ if (!set_state(ref.monitor, ref.desktop, ref.node, cst)) {
fail(rsp, "");
break;
}
fail(rsp, "node %s: Not enough arguments.\n", *(args - 1));
break;
}
- if (trg.node == NULL) {
+ if (ref.node == NULL) {
fail(rsp, "");
break;
}
}
}
if (streq("hidden", key)) {
- set_hidden(trg.monitor, trg.desktop, trg.node, (a == ALTER_SET ? b : !trg.node->hidden));
+ set_hidden(ref.monitor, ref.desktop, ref.node, (a == ALTER_SET ? b : !ref.node->hidden));
changed = true;
} else if (streq("sticky", key)) {
- set_sticky(trg.monitor, trg.desktop, trg.node, (a == ALTER_SET ? b : !trg.node->sticky));
+ set_sticky(ref.monitor, ref.desktop, ref.node, (a == ALTER_SET ? b : !ref.node->sticky));
} else if (streq("private", key)) {
- set_private(trg.monitor, trg.desktop, trg.node, (a == ALTER_SET ? b : !trg.node->private));
+ set_private(ref.monitor, ref.desktop, ref.node, (a == ALTER_SET ? b : !ref.node->private));
} else if (streq("locked", key)) {
- set_locked(trg.monitor, trg.desktop, trg.node, (a == ALTER_SET ? b : !trg.node->locked));
+ set_locked(ref.monitor, ref.desktop, ref.node, (a == ALTER_SET ? b : !ref.node->locked));
} else {
fail(rsp, "node %s: Invalid key: '%s'.\n", *(args - 1), key);
break;
fail(rsp, "node %s: Not enough arguments.\n", *(args - 1));
break;
}
- if (trg.node == NULL || trg.node->vacant) {
+ if (ref.node == NULL || ref.node->vacant) {
fail(rsp, "");
break;
}
if (streq("cancel", *args)) {
- cancel_presel(trg.monitor, trg.desktop, trg.node);
+ cancel_presel(ref.monitor, ref.desktop, ref.node);
} else {
bool alternate = false;
if ((*args)[0] == '~') {
}
direction_t dir;
if (parse_direction(*args, &dir)) {
- if (alternate && trg.node->presel != NULL && trg.node->presel->split_dir == dir) {
- cancel_presel(trg.monitor, trg.desktop, trg.node);
+ if (alternate && ref.node->presel != NULL && ref.node->presel->split_dir == dir) {
+ cancel_presel(ref.monitor, ref.desktop, ref.node);
} else {
- presel_dir(trg.monitor, trg.desktop, trg.node, dir);
- if (!IS_RECEPTACLE(trg.node)) {
- draw_presel_feedback(trg.monitor, trg.desktop, trg.node);
+ presel_dir(ref.monitor, ref.desktop, ref.node, dir);
+ if (!IS_RECEPTACLE(ref.node)) {
+ draw_presel_feedback(ref.monitor, ref.desktop, ref.node);
}
}
} else {
fail(rsp, "node %s: Not enough arguments.\n", *(args - 1));
break;
}
- if (trg.node == NULL || trg.node->vacant) {
+ if (ref.node == NULL || ref.node->vacant) {
fail(rsp, "");
break;
}
fail(rsp, "node %s: Invalid argument: '%s'.\n", *(args - 1), *args);
break;
} else {
- presel_ratio(trg.monitor, trg.desktop, trg.node, rat);
- draw_presel_feedback(trg.monitor, trg.desktop, trg.node);
+ presel_ratio(ref.monitor, ref.desktop, ref.node, rat);
+ draw_presel_feedback(ref.monitor, ref.desktop, ref.node);
}
} else if (streq("-v", *args) || streq("--move", *args)) {
num--, args++;
if (sscanf(*args, "%i", &dx) == 1) {
num--, args++;
if (sscanf(*args, "%i", &dy) == 1) {
- if (!move_client(&trg, dx, dy)) {
+ if (!move_client(&ref, dx, dy)) {
fail(rsp, "");
break;
}
if (sscanf(*args, "%i", &dx) == 1) {
num--, args++;
if (sscanf(*args, "%i", &dy) == 1) {
- if (!resize_client(&trg, rh, dx, dy)) {
+ if (!resize_client(&ref, rh, dx, dy)) {
fail(rsp, "");
break;
}
fail(rsp, "node %s: Not enough arguments.\n", *(args - 1));
break;
}
- if (trg.node == NULL) {
+ if (ref.node == NULL) {
fail(rsp, "");
break;
}
if ((*args)[0] == '+' || (*args)[0] == '-') {
int pix;
if (sscanf(*args, "%i", &pix) == 1) {
- int max = (trg.node->split_type == TYPE_HORIZONTAL ? trg.node->rectangle.height : trg.node->rectangle.width);
- double rat = ((max * trg.node->split_ratio) + pix) / max;
+ int max = (ref.node->split_type == TYPE_HORIZONTAL ? ref.node->rectangle.height : ref.node->rectangle.width);
+ double rat = ((max * ref.node->split_ratio) + pix) / max;
if (rat > 0 && rat < 1) {
- set_ratio(trg.node, rat);
+ set_ratio(ref.node, rat);
} else {
fail(rsp, "");
break;
} else {
double rat;
if (sscanf(*args, "%lf", &rat) == 1 && rat > 0 && rat < 1) {
- set_ratio(trg.node, rat);
+ set_ratio(ref.node, rat);
} else {
fail(rsp, "node %s: Invalid argument: '%s'.\n", *(args - 1), *args);
break;
fail(rsp, "node %s: Not enough arguments.\n", *(args - 1));
break;
}
- if (trg.node == NULL) {
+ if (ref.node == NULL) {
fail(rsp, "");
break;
}
flip_t flp;
if (parse_flip(*args, &flp)) {
- flip_tree(trg.node, flp);
+ flip_tree(ref.node, flp);
changed = true;
} else {
fail(rsp, "");
fail(rsp, "node %s: Not enough arguments.\n", *(args - 1));
break;
}
- if (trg.node == NULL) {
+ if (ref.node == NULL) {
fail(rsp, "");
break;
}
int deg;
if (parse_degree(*args, °)) {
- rotate_tree(trg.node, deg);
+ rotate_tree(ref.node, deg);
changed = true;
} else {
fail(rsp, "node %s: Invalid argument: '%s'.\n", *(args - 1), *args);
break;
}
} else if (streq("-E", *args) || streq("--equalize", *args)) {
- if (trg.node == NULL) {
+ if (ref.node == NULL) {
fail(rsp, "");
break;
}
- equalize_tree(trg.node);
+ equalize_tree(ref.node);
changed = true;
} else if (streq("-B", *args) || streq("--balance", *args)) {
- if (trg.node == NULL) {
+ if (ref.node == NULL) {
fail(rsp, "");
break;
}
- balance_tree(trg.node);
+ balance_tree(ref.node);
changed = true;
} else if (streq("-C", *args) || streq("--circulate", *args)) {
num--, args++;
fail(rsp, "node %s: Not enough arguments.\n", *(args - 1));
break;
}
- if (trg.node == NULL) {
+ if (ref.node == NULL) {
fail(rsp, "");
break;
}
circulate_dir_t cir;
if (parse_circulate_direction(*args, &cir)) {
- circulate_leaves(trg.monitor, trg.desktop, trg.node, cir);
+ circulate_leaves(ref.monitor, ref.desktop, ref.node, cir);
changed = true;
} else {
fail(rsp, "node %s: Invalid argument: '%s'.\n", *(args - 1), *args);
break;
}
} else if (streq("-i", *args) || streq("--insert-receptacle", *args)) {
- insert_receptacle(trg.monitor, trg.desktop, trg.node);
+ insert_receptacle(ref.monitor, ref.desktop, ref.node);
changed = true;
} else if (streq("-c", *args) || streq("--close", *args)) {
if (num > 1) {
fail(rsp, "node %s: Trailing commands.\n", *args);
break;
}
- if (trg.node == NULL || locked_count(trg.node) > 0) {
+ if (ref.node == NULL || locked_count(ref.node) > 0) {
fail(rsp, "");
break;
}
- close_node(trg.node);
+ close_node(ref.node);
break;
} else if (streq("-k", *args) || streq("--kill", *args)) {
if (num > 1) {
fail(rsp, "node %s: Trailing commands.\n", *args);
break;
}
- if (trg.node == NULL) {
+ if (ref.node == NULL) {
fail(rsp, "");
break;
}
- kill_node(trg.monitor, trg.desktop, trg.node);
+ kill_node(ref.monitor, ref.desktop, ref.node);
changed = true;
break;
} else {
}
if (changed) {
- arrange(trg.monitor, trg.desktop);
+ arrange(ref.monitor, ref.desktop);
}
}
}
coordinates_t ref = {mon, mon->desk, NULL};
- coordinates_t trg = ref;
if ((*args)[0] != OPT_CHR) {
int ret;
- if ((ret = desktop_from_desc(*args, &ref, &trg)) == SELECTOR_OK) {
+ coordinates_t tmp = ref;
+ if ((ret = desktop_from_desc(*args, &tmp, &ref)) == SELECTOR_OK) {
num--, args++;
} else {
handle_failure(ret, "desktop", *args, rsp);
while (num > 0) {
if (streq("-f", *args) || streq("--focus", *args)) {
- coordinates_t dst = trg;
+ coordinates_t dst = ref;
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
num--, args++;
int ret;
- if ((ret = desktop_from_desc(*args, &trg, &dst)) != SELECTOR_OK) {
+ if ((ret = desktop_from_desc(*args, &ref, &dst)) != SELECTOR_OK) {
handle_failure(ret, "desktop -f", *args, rsp);
break;
}
}
focus_node(dst.monitor, dst.desktop, dst.desktop->focus);
} else if (streq("-a", *args) || streq("--activate", *args)) {
- coordinates_t dst = trg;
+ coordinates_t dst = ref;
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
num--, args++;
int ret;
- if ((ret = desktop_from_desc(*args, &trg, &dst)) != SELECTOR_OK) {
+ if ((ret = desktop_from_desc(*args, &ref, &dst)) != SELECTOR_OK) {
handle_failure(ret, "desktop -a", *args, rsp);
break;
}
fail(rsp, "desktop %s: Not enough arguments.\n", *(args - 1));
break;
}
- if (trg.monitor->desk_head == trg.monitor->desk_tail) {
+ if (ref.monitor->desk_head == ref.monitor->desk_tail) {
fail(rsp, "");
break;
}
coordinates_t dst;
int ret;
- if ((ret = monitor_from_desc(*args, &trg, &dst)) == SELECTOR_OK) {
- if (transfer_desktop(trg.monitor, dst.monitor, trg.desktop)) {
- trg.monitor = dst.monitor;
+ if ((ret = monitor_from_desc(*args, &ref, &dst)) == SELECTOR_OK) {
+ if (transfer_desktop(ref.monitor, dst.monitor, ref.desktop)) {
+ ref.monitor = dst.monitor;
} else {
fail(rsp, "");
break;
}
coordinates_t dst;
int ret;
- if ((ret = desktop_from_desc(*args, &trg, &dst)) == SELECTOR_OK) {
- if (swap_desktops(trg.monitor, trg.desktop, dst.monitor, dst.desktop)) {
- trg.monitor = dst.monitor;
+ if ((ret = desktop_from_desc(*args, &ref, &dst)) == SELECTOR_OK) {
+ if (swap_desktops(ref.monitor, ref.desktop, dst.monitor, dst.desktop)) {
+ ref.monitor = dst.monitor;
} else {
fail(rsp, "");
break;
}
cycle_dir_t cyc;
if (parse_cycle_direction(*args, &cyc)) {
- desktop_t *d = trg.desktop;
+ desktop_t *d = ref.desktop;
if (cyc == CYCLE_PREV) {
if (d->prev == NULL) {
while (d->next != NULL) {
- swap_desktops(trg.monitor, d, trg.monitor, d->next);
+ swap_desktops(ref.monitor, d, ref.monitor, d->next);
}
} else {
- swap_desktops(trg.monitor, d, trg.monitor, d->prev);
+ swap_desktops(ref.monitor, d, ref.monitor, d->prev);
}
} else {
if (d->next == NULL) {
while (d->prev != NULL) {
- swap_desktops(trg.monitor, d, trg.monitor, d->prev);
+ swap_desktops(ref.monitor, d, ref.monitor, d->prev);
}
} else {
- swap_desktops(trg.monitor, d, trg.monitor, d->next);
+ swap_desktops(ref.monitor, d, ref.monitor, d->next);
}
}
} else {
layout_t lyt;
cycle_dir_t cyc;
if (parse_cycle_direction(*args, &cyc)) {
- change_layout(trg.monitor, trg.desktop, (trg.desktop->layout + 1) % 2);
+ change_layout(ref.monitor, ref.desktop, (ref.desktop->layout + 1) % 2);
} else if (parse_layout(*args, &lyt)) {
- change_layout(trg.monitor, trg.desktop, lyt);
+ change_layout(ref.monitor, ref.desktop, lyt);
} else {
fail(rsp, "desktop %s: Invalid argument: '%s'.\n", *(args - 1), *args);
break;
fail(rsp, "desktop %s: Not enough arguments.\n", *(args - 1));
break;
}
- rename_desktop(trg.monitor, trg.desktop, *args);
+ rename_desktop(ref.monitor, ref.desktop, *args);
} else if (streq("-r", *args) || streq("--remove", *args)) {
if (num > 1) {
fail(rsp, "desktop %s: Trailing commands.\n", *args);
break;
}
- if (trg.desktop->root == NULL &&
- trg.monitor->desk_head != trg.monitor->desk_tail) {
- remove_desktop(trg.monitor, trg.desktop);
+ if (ref.desktop->root == NULL &&
+ ref.monitor->desk_head != ref.monitor->desk_tail) {
+ remove_desktop(ref.monitor, ref.desktop);
return;
} else {
fail(rsp, "");
}
if (changed) {
- arrange(trg.monitor, trg.desktop);
+ arrange(ref.monitor, ref.desktop);
}
}
}
coordinates_t ref = {mon, NULL, NULL};
- coordinates_t trg = ref;
if ((*args)[0] != OPT_CHR) {
int ret;
- if ((ret = monitor_from_desc(*args, &ref, &trg)) == SELECTOR_OK) {
+ coordinates_t tmp = ref;
+ if ((ret = monitor_from_desc(*args, &tmp, &ref)) == SELECTOR_OK) {
num--, args++;
} else {
handle_failure(ret, "monitor", *args, rsp);
while (num > 0) {
if (streq("-f", *args) || streq("--focus", *args)) {
- coordinates_t dst = trg;
+ coordinates_t dst = ref;
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
num--, args++;
int ret;
- if ((ret = monitor_from_desc(*args, &trg, &dst)) != SELECTOR_OK) {
+ if ((ret = monitor_from_desc(*args, &ref, &dst)) != SELECTOR_OK) {
handle_failure(ret, "monitor -f", *args, rsp);
fail(rsp, "");
return;
fail(rsp, "monitor %s: Not enough arguments.\n", *(args - 1));
return;
}
- desktop_t *d = trg.monitor->desk_head;
+ desktop_t *d = ref.monitor->desk_head;
while (num > 0 && d != NULL) {
- rename_desktop(trg.monitor, d, *args);
+ rename_desktop(ref.monitor, d, *args);
d = d->next;
num--, args++;
}
put_status(SBSC_MASK_REPORT);
while (num > 0) {
- add_desktop(trg.monitor, make_desktop(*args, XCB_NONE));
+ add_desktop(ref.monitor, make_desktop(*args, XCB_NONE));
num--, args++;
}
while (d != NULL) {
desktop_t *next = d->next;
if (d == mon->desk) {
- focus_node(trg.monitor, d->prev, d->prev->focus);
+ focus_node(ref.monitor, d->prev, d->prev->focus);
}
- merge_desktops(trg.monitor, d, mon, mon->desk);
- remove_desktop(trg.monitor, d);
+ merge_desktops(ref.monitor, d, mon, mon->desk);
+ remove_desktop(ref.monitor, d);
d = next;
}
} else if (streq("-a", *args) || streq("--add-desktops", *args)) {
return;
}
while (num > 0) {
- add_desktop(trg.monitor, make_desktop(*args, XCB_NONE));
+ add_desktop(ref.monitor, make_desktop(*args, XCB_NONE));
num--, args++;
}
} else if (streq("-r", *args) || streq("--remove", *args)) {
fail(rsp, "");
return;
}
- remove_monitor(trg.monitor);
+ remove_monitor(ref.monitor);
return;
} else if (streq("-o", *args) || streq("--order-desktops", *args)) {
num--, args++;
fail(rsp, "monitor %s: Not enough arguments.\n", *(args - 1));
return;
}
- desktop_t *d = trg.monitor->desk_head;
+ desktop_t *d = ref.monitor->desk_head;
while (d != NULL && num > 0) {
desktop_t *next = d->next;
coordinates_t dst;
- if (locate_desktop(*args, &dst) && dst.monitor == trg.monitor) {
- swap_desktops(trg.monitor, d, dst.monitor, dst.desktop);
+ if (locate_desktop(*args, &dst) && dst.monitor == ref.monitor) {
+ swap_desktops(ref.monitor, d, dst.monitor, dst.desktop);
if (next == dst.desktop) {
next = d;
}
}
xcb_rectangle_t r;
if (parse_rectangle(*args, &r)) {
- update_root(trg.monitor, &r);
+ update_root(ref.monitor, &r);
} else {
fail(rsp, "monitor %s: Invalid argument: '%s'.\n", *(args - 1), *args);
return;
fail(rsp, "monitor %s: Not enough arguments.\n", *(args - 1));
return;
}
- rename_monitor(trg.monitor, *args);
+ rename_monitor(ref.monitor, *args);
} else if (streq("-s", *args) || streq("--swap", *args)) {
num--, args++;
if (num < 1) {
}
coordinates_t dst;
int ret;
- if ((ret = monitor_from_desc(*args, &trg, &dst)) == SELECTOR_OK) {
- if (!swap_monitors(trg.monitor, dst.monitor)) {
+ if ((ret = monitor_from_desc(*args, &ref, &dst)) == SELECTOR_OK) {
+ if (!swap_monitors(ref.monitor, dst.monitor)) {
fail(rsp, "");
return;
}
dom = DOMAIN_TREE, d++;
} else if (streq("-M", *args) || streq("--monitors", *args)) {
dom = DOMAIN_MONITOR, d++;
+ if (num > 1 && *(args + 1)[0] != OPT_CHR) {
+ num--, args++;
+ int ret;
+ coordinates_t tmp = ref;
+ if ((ret = monitor_from_desc(*args, &tmp, &ref)) != SELECTOR_OK) {
+ handle_failure(ret, "query -M", *args, rsp);
+ break;
+ }
+ }
} else if (streq("-D", *args) || streq("--desktops", *args)) {
dom = DOMAIN_DESKTOP, d++;
+ if (num > 1 && *(args + 1)[0] != OPT_CHR) {
+ num--, args++;
+ int ret;
+ coordinates_t tmp = ref;
+ if ((ret = desktop_from_desc(*args, &tmp, &ref)) != SELECTOR_OK) {
+ handle_failure(ret, "query -D", *args, rsp);
+ break;
+ }
+ }
} else if (streq("-N", *args) || streq("--nodes", *args)) {
dom = DOMAIN_NODE, d++;
+ if (num > 1 && *(args + 1)[0] != OPT_CHR) {
+ num--, args++;
+ int ret;
+ coordinates_t tmp = ref;
+ if ((ret = node_from_desc(*args, &tmp, &ref)) != SELECTOR_OK) {
+ handle_failure(ret, "query -N", *args, rsp);
+ break;
+ }
+ }
} else if (streq("-m", *args) || streq("--monitor", *args)) {
if (num > 1 && *(args + 1)[0] != OPT_CHR) {
num--, args++;
}
if (dom == DOMAIN_NODE) {
- if (query_node_ids(trg, node_sel, rsp) < 1) {
+ if (query_node_ids(&ref, &trg, node_sel, rsp) < 1) {
fail(rsp, "");
}
} else if (dom == DOMAIN_DESKTOP) {
- if (query_desktop_ids(trg, desktop_sel, rsp) < 1) {
+ if (query_desktop_ids(&ref, &trg, desktop_sel, rsp) < 1) {
fail(rsp, "");
}
} else if (dom == DOMAIN_MONITOR) {
- if (query_monitor_ids(trg, monitor_sel, rsp) < 1) {
+ if (query_monitor_ids(&ref, &trg, monitor_sel, rsp) < 1) {
fail(rsp, "");
}
} else {
fprintf(rsp, "]");
}
-int query_node_ids(coordinates_t loc, node_select_t *sel, FILE *rsp)
+int query_node_ids(coordinates_t *ref, coordinates_t *trg, node_select_t *sel, FILE *rsp)
{
int count = 0;
for (monitor_t *m = mon_head; m != NULL; m = m->next) {
- if (loc.monitor != NULL && m != loc.monitor) {
+ if (trg->monitor != NULL && m != trg->monitor) {
continue;
}
for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
- if (loc.desktop != NULL && d != loc.desktop) {
+ if (trg->desktop != NULL && d != trg->desktop) {
continue;
}
- count += query_node_ids_in(d->root, d, m, loc, sel, rsp);
+ count += query_node_ids_in(d->root, d, m, ref, trg, sel, rsp);
}
}
return count;
}
-int query_node_ids_in(node_t *n, desktop_t *d, monitor_t *m, coordinates_t loc, node_select_t *sel, FILE *rsp)
+int query_node_ids_in(node_t *n, desktop_t *d, monitor_t *m, coordinates_t *ref, coordinates_t *trg, node_select_t *sel, FILE *rsp)
{
int count = 0;
if (n == NULL) {
return 0;
} else {
- coordinates_t ref = {mon, mon->desk, mon->desk->focus};
- coordinates_t trg = {m, d, n};
- if ((loc.node == NULL || n == loc.node) &&
- (sel == NULL || node_matches(&trg, &ref, *sel))) {
+ coordinates_t loc = {m, d, n};
+ if ((trg->node == NULL || n == trg->node) &&
+ (sel == NULL || node_matches(&loc, ref, *sel))) {
fprintf(rsp, "0x%08X\n", n->id);
count++;
}
- count += query_node_ids_in(n->first_child, d, m, loc, sel, rsp);
- count += query_node_ids_in(n->second_child, d, m, loc, sel, rsp);
+ count += query_node_ids_in(n->first_child, d, m, ref, trg, sel, rsp);
+ count += query_node_ids_in(n->second_child, d, m, ref, trg, sel, rsp);
}
return count;
}
-int query_desktop_ids(coordinates_t loc, desktop_select_t *sel, FILE *rsp)
+int query_desktop_ids(coordinates_t *ref, coordinates_t *trg, desktop_select_t *sel, FILE *rsp)
{
int count = 0;
for (monitor_t *m = mon_head; m != NULL; m = m->next) {
- if (loc.monitor != NULL && m != loc.monitor) {
+ if (trg->monitor != NULL && m != trg->monitor) {
continue;
}
for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
- coordinates_t ref = {mon, mon->desk, NULL};
- coordinates_t trg = {m, d, NULL};
- if ((loc.desktop != NULL && d != loc.desktop) ||
- (sel != NULL && !desktop_matches(&trg, &ref, *sel))) {
+ coordinates_t loc = {m, d, NULL};
+ if ((trg->desktop != NULL && d != trg->desktop) ||
+ (sel != NULL && !desktop_matches(&loc, ref, *sel))) {
continue;
}
fprintf(rsp, "0x%08X\n", d->id);
return count;
}
-int query_monitor_ids(coordinates_t loc, monitor_select_t *sel, FILE *rsp)
+int query_monitor_ids(coordinates_t *ref, coordinates_t *trg, monitor_select_t *sel, FILE *rsp)
{
int count = 0;
for (monitor_t *m = mon_head; m != NULL; m = m->next) {
- coordinates_t ref = {mon, NULL, NULL};
- coordinates_t trg = {m, NULL, NULL};
- if ((loc.monitor != NULL && m != loc.monitor) ||
- (sel != NULL && !monitor_matches(&trg, &ref, *sel))) {
+ coordinates_t loc = {m, NULL, NULL};
+ if ((trg->monitor != NULL && m != trg->monitor) ||
+ (sel != NULL && !monitor_matches(&loc, ref, *sel))) {
continue;
}
fprintf(rsp, "0x%08X\n", m->id);
.locked = OPTION_NONE,
.urgent = OPTION_NONE,
.same_class = OPTION_NONE,
+ .descendant_of = OPTION_NONE,
+ .ancestor_of = OPTION_NONE,
.below = OPTION_NONE,
.normal = OPTION_NONE,
.above = OPTION_NONE
return SELECTOR_BAD_MODIFIERS;
}
- dst->monitor = ref->monitor;
- dst->desktop = ref->desktop;
dst->node = NULL;
direction_t dir;
} else if (streq("last", desc)) {
history_find_node(HISTORY_OLDER, ref, dst, sel);
} else if (streq("biggest", desc)) {
- dst->node = find_biggest(ref->monitor, ref->desktop, ref->node, sel);
+ find_biggest(ref, dst, sel);
} else if (streq("pointed", desc)) {
xcb_window_t win;
query_pointer(&win, NULL);
} else if (streq("focused", desc)) {
coordinates_t loc = {mon, mon->desk, mon->desk->focus};
if (node_matches(&loc, ref, sel)) {
- dst->monitor = mon;
- dst->desktop = mon->desk;
- dst->node = mon->desk->focus;
+ *dst = loc;
}
} else if (*desc == '@') {
desc++;
+ *dst = *ref;
if (colon != NULL) {
*colon = '\0';
int ret;
return false;
}
+ if (sel.descendant_of != OPTION_NONE &&
+ !is_descendant(loc->node, ref->node)
+ ? sel.descendant_of == OPTION_TRUE
+ : sel.descendant_of == OPTION_FALSE) {
+ return false;
+ }
+
+ if (sel.ancestor_of != OPTION_NONE &&
+ !is_descendant(ref->node, loc->node)
+ ? sel.ancestor_of == OPTION_TRUE
+ : sel.ancestor_of == OPTION_FALSE) {
+ return false;
+ }
+
#define WSTATE(p, e) \
if (sel.p != OPTION_NONE && \
loc->node->client->state != e \