- client_select_t sel;
- sel.type = CLIENT_TYPE_ALL;
- sel.class = CLIENT_CLASS_ALL;
- sel.mode = CLIENT_MODE_ALL;
- sel.urgency = CLIENT_URGENCY_ALL;
- char *tok;
- while ((tok = strrchr(desc, CAT_CHR)) != NULL) {
- tok[0] = '\0';
- tok++;
- if (streq("tiled", tok)) {
- sel.type = CLIENT_TYPE_TILED;
- } else if (streq("floating", tok)) {
- sel.type = CLIENT_TYPE_FLOATING;
- } else if (streq("like", tok)) {
- sel.class = CLIENT_CLASS_EQUAL;
- } else if (streq("unlike", tok)) {
- sel.class = CLIENT_CLASS_DIFFER;
- } else if (streq("automatic", tok)) {
- sel.mode = CLIENT_MODE_AUTOMATIC;
- } else if (streq("manual", tok)) {
- sel.mode = CLIENT_MODE_MANUAL;
- } else if (streq("urgent", tok)) {
- sel.urgency = CLIENT_URGENCY_ON;
- } else if (streq("nonurgent", tok)) {
- sel.urgency = CLIENT_URGENCY_OFF;
- }
- }
-
- dst->monitor = ref->monitor;
- dst->desktop = ref->desktop;
- dst->node = NULL;
-
- direction_t dir;
- cycle_dir_t cyc;
- if (parse_direction(desc, &dir)) {
- dst->node = nearest_neighbor(dst->desktop, ref->node, dir, sel);
- } else if (parse_cycle_direction(desc, &cyc)) {
- dst->node = closest_node(ref->desktop, ref->node, cyc, sel);
- } else if (streq("last", desc)) {
- dst->node = history_last(ref->desktop->history, ref->node, sel);
- } else if (streq("biggest", desc)) {
- dst->node = find_biggest(ref->desktop, ref->node, sel);
- } else if (streq("focused", desc)) {
- if (node_matches(ref->node, mon->desk->focus, sel)) {
- dst->monitor = mon;
- dst->desktop = mon->desk;
- dst->node = mon->desk->focus;
- }
- } else {
- long int wid;
- if (parse_window_id(desc, &wid))
- locate_window(wid, dst);
- }
-
- return (dst->node != NULL);
+ client_select_t sel = {CLIENT_TYPE_ALL, CLIENT_CLASS_ALL, CLIENT_MODE_ALL, false, false, false};
+ char *tok;
+ while ((tok = strrchr(desc, CAT_CHR)) != NULL) {
+ tok[0] = '\0';
+ tok++;
+ if (streq("tiled", tok)) {
+ sel.type = CLIENT_TYPE_TILED;
+ } else if (streq("floating", tok)) {
+ sel.type = CLIENT_TYPE_FLOATING;
+ } else if (streq("like", tok)) {
+ sel.class = CLIENT_CLASS_EQUAL;
+ } else if (streq("unlike", tok)) {
+ sel.class = CLIENT_CLASS_DIFFER;
+ } else if (streq("manual", tok)) {
+ sel.mode = CLIENT_MODE_MANUAL;
+ } else if (streq("automatic", tok)) {
+ sel.mode = CLIENT_MODE_AUTOMATIC;
+ } else if (streq("urgent", tok)) {
+ sel.urgent = true;
+ } else if (streq("local", tok)) {
+ sel.local = true;
+ } else if (streq("unfocused", tok)) {
+ sel.unfocused = true;
+ }
+ }
+
+ dst->monitor = ref->monitor;
+ dst->desktop = ref->desktop;
+ dst->node = NULL;
+
+ direction_t dir;
+ cycle_dir_t cyc;
+ history_dir_t hdi;
+ if (parse_direction(desc, &dir)) {
+ dst->node = nearest_neighbor(ref->monitor, ref->desktop, ref->node, dir, sel);
+ if (dst->node == NULL && num_monitors > 1) {
+ monitor_t *m = nearest_monitor(ref->monitor, dir, (desktop_select_t) {DESKTOP_STATUS_ALL, false, false});
+ if (m != NULL) {
+ coordinates_t loc = {m, m->desk, m->desk->focus};
+ if (node_matches(&loc, ref, sel)) {
+ dst->monitor = m;
+ dst->desktop = m->desk;
+ dst->node = m->desk->focus;
+ }
+ }
+ }
+ } else if (parse_cycle_direction(desc, &cyc)) {
+ dst->node = closest_node(ref->monitor, ref->desktop, ref->node, cyc, sel);
+ } else if (parse_history_direction(desc, &hdi)) {
+ history_find_node(hdi, ref, dst, sel);
+ } 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);
+ } 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;
+ }
+ } else {
+ long int wid;
+ if (parse_window_id(desc, &wid))
+ locate_window(wid, dst);
+ }
+
+ return (dst->node != NULL);