]> git.lizzy.rs Git - bspwm.git/blobdiff - src/query.c
Add monitor/desktop/node descriptor: `any`
[bspwm.git] / src / query.c
index bc51a4a233617ef1c2a00619a39796023e8cc569..f1c9c91c29f79910b6654758ead5eb4b607b7b27 100644 (file)
@@ -33,6 +33,7 @@
 #include "window.h"
 #include "tree.h"
 #include "query.h"
+#include "geometry.h"
 
 void query_tree(FILE *rsp)
 {
@@ -122,12 +123,16 @@ void query_node(node_t *n, FILE *rsp)
                fprintf(rsp, "\"sticky\":%s,", BOOL_STR(n->sticky));
                fprintf(rsp, "\"private\":%s,", BOOL_STR(n->private));
                fprintf(rsp, "\"locked\":%s,", BOOL_STR(n->locked));
+               fprintf(rsp, "\"marked\":%s,", BOOL_STR(n->marked));
                fprintf(rsp, "\"presel\":");
                query_presel(n->presel, rsp);
                fprintf(rsp,",");
                fprintf(rsp, "\"rectangle\":");
                query_rectangle(n->rectangle, rsp);
                fprintf(rsp,",");
+               fprintf(rsp, "\"constraints\":");
+               query_constraints(n->constraints, rsp);
+               fprintf(rsp,",");
                fprintf(rsp, "\"firstChild\":");
                query_node(n->first_child, rsp);
                fprintf(rsp,",");
@@ -178,6 +183,11 @@ void query_rectangle(xcb_rectangle_t r, FILE *rsp)
        fprintf(rsp, "{\"x\":%i,\"y\":%i,\"width\":%u,\"height\":%u}", r.x, r.y, r.width, r.height);
 }
 
+void query_constraints(constraints_t c, FILE *rsp)
+{
+       fprintf(rsp, "{\"min_width\":%u,\"min_height\":%u}", c.min_width, c.min_height);
+}
+
 void query_padding(padding_t p, FILE *rsp)
 {
        fprintf(rsp, "{\"top\":%i,\"right\":%i,\"bottom\":%i,\"left\":%i}", p.top, p.right, p.bottom, p.left);
@@ -237,7 +247,7 @@ int query_node_ids_in(node_t *n, desktop_t *d, monitor_t *m, coordinates_t *ref,
        } else {
                coordinates_t loc = {m, d, n};
                if ((trg->node == NULL || n == trg->node) &&
-                   (sel == NULL || node_matches(&loc, ref, *sel))) {
+                   (sel == NULL || node_matches(&loc, ref, sel))) {
                        fprintf(rsp, "0x%08X\n", n->id);
                        count++;
                }
@@ -257,7 +267,7 @@ int query_desktop_ids(coordinates_t *ref, coordinates_t *trg, desktop_select_t *
                for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
                        coordinates_t loc = {m, d, NULL};
                        if ((trg->desktop != NULL && d != trg->desktop) ||
-                           (sel != NULL && !desktop_matches(&loc, ref, *sel))) {
+                           (sel != NULL && !desktop_matches(&loc, ref, sel))) {
                                continue;
                        }
                        printer(d, rsp);
@@ -273,7 +283,7 @@ int query_monitor_ids(coordinates_t *ref, coordinates_t *trg, monitor_select_t *
        for (monitor_t *m = mon_head; m != NULL; m = m->next) {
                coordinates_t loc = {m, NULL, NULL};
                if ((trg->monitor != NULL && m != trg->monitor) ||
-                       (sel != NULL && !monitor_matches(&loc, ref, *sel))) {
+                       (sel != NULL && !monitor_matches(&loc, ref, sel))) {
                        continue;
                }
                printer(m, rsp);
@@ -332,6 +342,27 @@ void print_modifier_mask(uint16_t m, FILE *rsp)
        }
 }
 
+void print_button_index(int8_t b, FILE *rsp)
+{
+       switch (b) {
+               case XCB_BUTTON_INDEX_ANY:
+                       fprintf(rsp, "any");
+                       break;
+               case XCB_BUTTON_INDEX_1:
+                       fprintf(rsp, "button1");
+                       break;
+               case XCB_BUTTON_INDEX_2:
+                       fprintf(rsp, "button2");
+                       break;
+               case XCB_BUTTON_INDEX_3:
+                       fprintf(rsp, "button3");
+                       break;
+               case -1:
+                       fprintf(rsp, "none");
+                       break;
+       }
+}
+
 void print_pointer_action(pointer_action_t a, FILE *rsp)
 {
        switch (a) {
@@ -353,6 +384,32 @@ void print_pointer_action(pointer_action_t a, FILE *rsp)
        }
 }
 
+void print_rule_consequence(char **buf, rule_consequence_t *csq)
+{
+       char *rect_buf = NULL;
+       print_rectangle(&rect_buf, csq->rect);
+       if (rect_buf == NULL) {
+               rect_buf = malloc(1);
+               *rect_buf = '\0';
+       }
+       asprintf(buf, "monitor=%s desktop=%s node=%s state=%s layer=%s split_dir=%s split_ratio=%lf hidden=%s sticky=%s private=%s locked=%s marked=%s center=%s follow=%s manage=%s focus=%s border=%s rectangle=%s",
+               csq->monitor_desc, csq->desktop_desc, csq->node_desc,
+               csq->state == NULL ? "" : STATE_STR(*csq->state),
+               csq->layer == NULL ? "" : LAYER_STR(*csq->layer),
+               csq->split_dir, csq->split_ratio,
+               ON_OFF_STR(csq->hidden), ON_OFF_STR(csq->sticky), ON_OFF_STR(csq->private),
+               ON_OFF_STR(csq->locked), ON_OFF_STR(csq->marked), ON_OFF_STR(csq->center), ON_OFF_STR(csq->follow),
+               ON_OFF_STR(csq->manage), ON_OFF_STR(csq->focus), ON_OFF_STR(csq->border), rect_buf);
+       free(rect_buf);
+}
+
+void print_rectangle(char **buf, xcb_rectangle_t *rect)
+{
+       if (rect != NULL) {
+               asprintf(buf, "%hux%hu+%hi+%hi", rect->width, rect->height, rect->x, rect->y);
+       }
+}
+
 node_select_t make_node_select(void)
 {
        node_select_t sel = {
@@ -370,6 +427,7 @@ node_select_t make_node_select(void)
                .sticky = OPTION_NONE,
                .private = OPTION_NONE,
                .locked = OPTION_NONE,
+               .marked = OPTION_NONE,
                .urgent = OPTION_NONE,
                .same_class = OPTION_NONE,
                .descendant_of = OPTION_NONE,
@@ -444,26 +502,30 @@ int node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
        cycle_dir_t cyc;
        history_dir_t hdi;
        if (parse_direction(desc, &dir)) {
-               find_nearest_neighbor(ref, dst, dir, sel);
+               find_nearest_neighbor(ref, dst, dir, &sel);
        } else if (parse_cycle_direction(desc, &cyc)) {
-               find_closest_node(ref, dst, cyc, sel);
+               find_closest_node(ref, dst, cyc, &sel);
        } else if (parse_history_direction(desc, &hdi)) {
-               history_find_node(hdi, ref, dst, sel);
+               history_find_node(hdi, ref, dst, &sel);
+       } else if (streq("any", desc)) {
+               find_any_node(ref, dst, &sel);
        } else if (streq("last", desc)) {
-               history_find_node(HISTORY_OLDER, ref, dst, sel);
+               history_find_node(HISTORY_OLDER, ref, dst, &sel);
+       } else if (streq("newest", desc)) {
+               history_find_newest_node(ref, dst, &sel);
        } else if (streq("biggest", desc)) {
-               find_biggest(ref, dst, sel);
+               find_biggest(ref, dst, &sel);
        } else if (streq("pointed", desc)) {
-               xcb_window_t win;
+               xcb_window_t win = XCB_NONE;
                query_pointer(&win, NULL);
-               if (locate_window(win, dst) && node_matches(dst, ref, sel)) {
+               if (locate_window(win, dst) && node_matches(dst, ref, &sel)) {
                        return SELECTOR_OK;
                } else {
                        return SELECTOR_INVALID;
                }
        } else if (streq("focused", desc)) {
                coordinates_t loc = {mon, mon->desk, mon->desk->focus};
-               if (node_matches(&loc, ref, sel)) {
+               if (node_matches(&loc, ref, &sel)) {
                        *dst = loc;
                }
        } else if (*desc == '@') {
@@ -506,7 +568,7 @@ int node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
                }
                free(desc_copy);
                if (dst->node != NULL) {
-                       if (node_matches(dst, ref, sel)) {
+                       if (node_matches(dst, ref, &sel)) {
                                return SELECTOR_OK;
                        } else {
                                return SELECTOR_INVALID;
@@ -519,7 +581,7 @@ int node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
                uint32_t id;
                if (parse_id(desc, &id)) {
                        free(desc_copy);
-                       if (find_by_id(id, dst) && node_matches(dst, ref, sel)) {
+                       if (find_by_id(id, dst) && node_matches(dst, ref, &sel)) {
                                return SELECTOR_OK;
                        } else {
                                return SELECTOR_INVALID;
@@ -541,6 +603,11 @@ int node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
 
 int desktop_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
 {
+       if (*desc == '%') {
+               locate_desktop(desc + 1, dst);
+               goto end;
+       }
+
        coordinates_t ref_copy = *ref;
        ref = &ref_copy;
        char *desc_copy = copy_string(desc, strlen(desc));
@@ -575,14 +642,18 @@ int desktop_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
        uint16_t idx;
        uint32_t id;
        if (parse_cycle_direction(desc, &cyc)) {
-               find_closest_desktop(ref, dst, cyc, sel);
+               find_closest_desktop(ref, dst, cyc, &sel);
        } else if (parse_history_direction(desc, &hdi)) {
-               history_find_desktop(hdi, ref, dst, sel);
+               history_find_desktop(hdi, ref, dst, &sel);
+       } else if (streq("any", desc)) {
+               find_any_desktop(ref, dst, &sel);
        } else if (streq("last", desc)) {
-               history_find_desktop(HISTORY_OLDER, ref, dst, sel);
+               history_find_desktop(HISTORY_OLDER, ref, dst, &sel);
+       } else if (streq("newest", desc)) {
+               history_find_newest_desktop(ref, dst, &sel);
        } else if (streq("focused", desc)) {
                coordinates_t loc = {mon, mon->desk, NULL};
-               if (desktop_matches(&loc, ref, sel)) {
+               if (desktop_matches(&loc, ref, &sel)) {
                        *dst = loc;
                }
        } else if (colon != NULL) {
@@ -591,12 +662,12 @@ int desktop_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
                if ((ret = monitor_from_desc(desc, ref, dst)) == SELECTOR_OK) {
                        if (streq("focused", colon + 1)) {
                                coordinates_t loc = {dst->monitor, dst->monitor->desk, NULL};
-                               if (desktop_matches(&loc, ref, sel)) {
+                               if (desktop_matches(&loc, ref, &sel)) {
                                        *dst = loc;
                                }
                        } else if (parse_index(colon + 1, &idx)) {
                                free(desc_copy);
-                               if (desktop_from_index(idx, dst, dst->monitor) && desktop_matches(dst, ref, sel)) {
+                               if (desktop_from_index(idx, dst, dst->monitor) && desktop_matches(dst, ref, &sel)) {
                                        return SELECTOR_OK;
                                } else {
                                        return SELECTOR_INVALID;
@@ -611,34 +682,36 @@ int desktop_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
                }
        } else if (parse_index(desc, &idx) && desktop_from_index(idx, dst, NULL)) {
                free(desc_copy);
-               if (desktop_matches(dst, ref, sel)) {
+               if (desktop_matches(dst, ref, &sel)) {
                        return SELECTOR_OK;
                } else {
                        return SELECTOR_INVALID;
                }
        } else if (parse_id(desc, &id) && desktop_from_id(id, dst, NULL)) {
                free(desc_copy);
-               if (desktop_matches(dst, ref, sel)) {
+               if (desktop_matches(dst, ref, &sel)) {
                        return SELECTOR_OK;
                } else {
                        return SELECTOR_INVALID;
                }
        } else {
-               if (locate_desktop(desc, dst)) {
+               int hits = 0;
+               if (desktop_from_name(desc, ref, dst, &sel, &hits)) {
                        free(desc_copy);
-                       if (desktop_matches(dst, ref, sel)) {
-                               return SELECTOR_OK;
-                       } else {
-                               return SELECTOR_INVALID;
-                       }
+                       return SELECTOR_OK;
                } else {
                        free(desc_copy);
-                       return SELECTOR_BAD_DESCRIPTOR;
+                       if (hits > 0) {
+                               return SELECTOR_INVALID;
+                       } else {
+                               return SELECTOR_BAD_DESCRIPTOR;
+                       }
                }
        }
 
        free(desc_copy);
 
+end:
        if (dst->desktop == NULL) {
                return SELECTOR_INVALID;
        }
@@ -648,6 +721,11 @@ int desktop_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
 
 int monitor_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
 {
+       if (*desc == '%') {
+               locate_monitor(desc + 1, dst);
+               goto end;
+       }
+
        coordinates_t ref_copy = *ref;
        ref = &ref_copy;
        char *desc_copy = copy_string(desc, strlen(desc));
@@ -682,35 +760,48 @@ int monitor_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
        uint16_t idx;
        uint32_t id;
        if (parse_direction(desc, &dir)) {
-               dst->monitor = nearest_monitor(ref->monitor, dir, sel);
+               dst->monitor = nearest_monitor(ref->monitor, dir, &sel);
        } else if (parse_cycle_direction(desc, &cyc)) {
-               dst->monitor = closest_monitor(ref->monitor, cyc, sel);
+               dst->monitor = closest_monitor(ref->monitor, cyc, &sel);
        } else if (parse_history_direction(desc, &hdi)) {
-               history_find_monitor(hdi, ref, dst, sel);
+               history_find_monitor(hdi, ref, dst, &sel);
+       } else if (streq("any", desc)) {
+               find_any_monitor(ref, dst, &sel);
        } else if (streq("last", desc)) {
-               history_find_monitor(HISTORY_OLDER, ref, dst, sel);
+               history_find_monitor(HISTORY_OLDER, ref, dst, &sel);
+       } else if (streq("newest", desc)) {
+               history_find_newest_monitor(ref, dst, &sel);
        } else if (streq("primary", desc)) {
                if (pri_mon != NULL) {
                        coordinates_t loc = {pri_mon, NULL, NULL};
-                       if (monitor_matches(&loc, ref, sel)) {
+                       if (monitor_matches(&loc, ref, &sel)) {
                                dst->monitor = pri_mon;
                        }
                }
        } else if (streq("focused", desc)) {
                coordinates_t loc = {mon, NULL, NULL};
-               if (monitor_matches(&loc, ref, sel)) {
+               if (monitor_matches(&loc, ref, &sel)) {
                        dst->monitor = mon;
                }
+       } else if (streq("pointed", desc)) {
+               xcb_point_t pointer;
+               query_pointer(NULL, &pointer);
+               for (monitor_t *m = mon_head; m != NULL; m = m->next) {
+                       if (is_inside(pointer, m->rectangle)) {
+                               dst->monitor = m;
+                               break;
+                       }
+               }
        } else if (parse_index(desc, &idx) && monitor_from_index(idx, dst)) {
                free(desc_copy);
-               if (monitor_matches(dst, ref, sel)) {
+               if (monitor_matches(dst, ref, &sel)) {
                        return SELECTOR_OK;
                } else {
                        return SELECTOR_INVALID;
                }
        } else if (parse_id(desc, &id) && monitor_from_id(id, dst)) {
                free(desc_copy);
-               if (monitor_matches(dst, ref, sel)) {
+               if (monitor_matches(dst, ref, &sel)) {
                        return SELECTOR_OK;
                } else {
                        return SELECTOR_INVALID;
@@ -718,7 +809,7 @@ int monitor_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
        } else {
                if (locate_monitor(desc, dst)) {
                        free(desc_copy);
-                       if (monitor_matches(dst, ref, sel)) {
+                       if (monitor_matches(dst, ref, &sel)) {
                                return SELECTOR_OK;
                        } else {
                                return SELECTOR_INVALID;
@@ -731,6 +822,7 @@ int monitor_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
 
        free(desc_copy);
 
+end:
        if (dst->monitor == NULL) {
                return SELECTOR_INVALID;
        }
@@ -801,6 +893,26 @@ bool desktop_from_id(uint32_t id, coordinates_t *loc, monitor_t *mm)
        return false;
 }
 
+bool desktop_from_name(char *name, coordinates_t *ref, coordinates_t *dst, desktop_select_t *sel, int *hits)
+{
+       for (monitor_t *m = mon_head; m != NULL; m = m->next) {
+               for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
+                       if (streq(d->name, name)) {
+                               if (hits != NULL) {
+                                       (*hits)++;
+                               }
+                               coordinates_t loc = {m, d, NULL};
+                               if (desktop_matches(&loc, ref, sel)) {
+                                       dst->monitor = m;
+                                       dst->desktop = d;
+                                       return true;
+                               }
+                       }
+               }
+       }
+       return false;
+}
+
 bool desktop_from_index(uint16_t idx, coordinates_t *loc, monitor_t *mm)
 {
        for (monitor_t *m = mon_head; m != NULL; m = m->next) {
@@ -845,107 +957,108 @@ bool monitor_from_index(int idx, coordinates_t *loc)
        return false;
 }
 
-bool node_matches(coordinates_t *loc, coordinates_t *ref, node_select_t sel)
+bool node_matches(coordinates_t *loc, coordinates_t *ref, node_select_t *sel)
 {
        if (loc->node == NULL) {
                return false;
        }
 
-       if (sel.focused != OPTION_NONE &&
+       if (sel->focused != OPTION_NONE &&
            loc->node != loc->desktop->focus
-           ? sel.focused == OPTION_TRUE
-           : sel.focused == OPTION_FALSE) {
+           ? sel->focused == OPTION_TRUE
+           : sel->focused == OPTION_FALSE) {
                return false;
        }
 
-       if (sel.automatic != OPTION_NONE &&
+       if (sel->automatic != OPTION_NONE &&
            loc->node->presel != NULL
-           ? sel.automatic == OPTION_TRUE
-           : sel.automatic == OPTION_FALSE) {
+           ? sel->automatic == OPTION_TRUE
+           : sel->automatic == OPTION_FALSE) {
                return false;
        }
 
-       if (sel.local != OPTION_NONE &&
+       if (sel->local != OPTION_NONE &&
            loc->desktop != ref->desktop
-           ? sel.local == OPTION_TRUE
-           : sel.local == OPTION_FALSE) {
+           ? sel->local == OPTION_TRUE
+           : sel->local == OPTION_FALSE) {
                return false;
        }
 
-       if (sel.active != OPTION_NONE &&
+       if (sel->active != OPTION_NONE &&
            loc->desktop != loc->monitor->desk
-           ? sel.active == OPTION_TRUE
-           : sel.active == OPTION_FALSE) {
+           ? sel->active == OPTION_TRUE
+           : sel->active == OPTION_FALSE) {
                return false;
        }
 
-       if (sel.leaf != OPTION_NONE &&
+       if (sel->leaf != OPTION_NONE &&
            !is_leaf(loc->node)
-           ? sel.leaf == OPTION_TRUE
-           : sel.leaf == OPTION_FALSE) {
+           ? sel->leaf == OPTION_TRUE
+           : sel->leaf == OPTION_FALSE) {
                return false;
        }
 
-       if (sel.window != OPTION_NONE &&
+       if (sel->window != OPTION_NONE &&
            loc->node->client == NULL
-           ? sel.window == OPTION_TRUE
-           : sel.window == OPTION_FALSE) {
+           ? sel->window == OPTION_TRUE
+           : sel->window == OPTION_FALSE) {
                return false;
        }
 
 #define NFLAG(p) \
-       if (sel.p != OPTION_NONE && \
+       if (sel->p != OPTION_NONE && \
            !loc->node->p \
-           ? sel.p == OPTION_TRUE \
-           : sel.p == OPTION_FALSE) { \
+           ? sel->p == OPTION_TRUE \
+           : sel->p == OPTION_FALSE) { \
                return false; \
        }
        NFLAG(hidden)
        NFLAG(sticky)
        NFLAG(private)
        NFLAG(locked)
-#undef WFLAG
+       NFLAG(marked)
+#undef NFLAG
 
        if (loc->node->client == NULL &&
-               (sel.same_class != OPTION_NONE ||
-                sel.tiled != OPTION_NONE ||
-                sel.pseudo_tiled != OPTION_NONE ||
-                sel.floating != OPTION_NONE ||
-                sel.fullscreen != OPTION_NONE ||
-                sel.below != OPTION_NONE ||
-                sel.normal != OPTION_NONE ||
-                sel.above != OPTION_NONE ||
-                sel.urgent != OPTION_NONE)) {
+               (sel->same_class != OPTION_NONE ||
+                sel->tiled != OPTION_NONE ||
+                sel->pseudo_tiled != OPTION_NONE ||
+                sel->floating != OPTION_NONE ||
+                sel->fullscreen != OPTION_NONE ||
+                sel->below != OPTION_NONE ||
+                sel->normal != OPTION_NONE ||
+                sel->above != OPTION_NONE ||
+                sel->urgent != OPTION_NONE)) {
                return false;
        }
 
        if (ref->node != NULL && ref->node->client != NULL &&
-           sel.same_class != OPTION_NONE &&
+           sel->same_class != OPTION_NONE &&
            streq(loc->node->client->class_name, ref->node->client->class_name)
-           ? sel.same_class == OPTION_FALSE
-           : sel.same_class == OPTION_TRUE) {
+           ? sel->same_class == OPTION_FALSE
+           : sel->same_class == OPTION_TRUE) {
                return false;
        }
 
-       if (sel.descendant_of != OPTION_NONE &&
+       if (sel->descendant_of != OPTION_NONE &&
            !is_descendant(loc->node, ref->node)
-           ? sel.descendant_of == OPTION_TRUE
-           : sel.descendant_of == OPTION_FALSE) {
+           ? sel->descendant_of == OPTION_TRUE
+           : sel->descendant_of == OPTION_FALSE) {
                return false;
        }
 
-       if (sel.ancestor_of != OPTION_NONE &&
+       if (sel->ancestor_of != OPTION_NONE &&
            !is_descendant(ref->node, loc->node)
-           ? sel.ancestor_of == OPTION_TRUE
-           : sel.ancestor_of == OPTION_FALSE) {
+           ? sel->ancestor_of == OPTION_TRUE
+           : sel->ancestor_of == OPTION_FALSE) {
                return false;
        }
 
 #define WSTATE(p, e) \
-       if (sel.p != OPTION_NONE && \
+       if (sel->p != OPTION_NONE && \
            loc->node->client->state != e \
-           ? sel.p == OPTION_TRUE \
-           : sel.p == OPTION_FALSE) { \
+           ? sel->p == OPTION_TRUE \
+           : sel->p == OPTION_FALSE) { \
                return false; \
        }
        WSTATE(tiled, STATE_TILED)
@@ -955,10 +1068,10 @@ bool node_matches(coordinates_t *loc, coordinates_t *ref, node_select_t sel)
 #undef WSTATE
 
 #define WLAYER(p, e) \
-       if (sel.p != OPTION_NONE && \
+       if (sel->p != OPTION_NONE && \
            loc->node->client->layer != e \
-           ? sel.p == OPTION_TRUE \
-           : sel.p == OPTION_FALSE) { \
+           ? sel->p == OPTION_TRUE \
+           : sel->p == OPTION_FALSE) { \
                return false; \
        }
        WLAYER(below, LAYER_BELOW)
@@ -967,10 +1080,10 @@ bool node_matches(coordinates_t *loc, coordinates_t *ref, node_select_t sel)
 #undef WLAYER
 
 #define WFLAG(p) \
-       if (sel.p != OPTION_NONE && \
+       if (sel->p != OPTION_NONE && \
            !loc->node->client->p \
-           ? sel.p == OPTION_TRUE \
-           : sel.p == OPTION_FALSE) { \
+           ? sel->p == OPTION_TRUE \
+           : sel->p == OPTION_FALSE) { \
                return false; \
        }
        WFLAG(urgent)
@@ -979,52 +1092,52 @@ bool node_matches(coordinates_t *loc, coordinates_t *ref, node_select_t sel)
        return true;
 }
 
-bool desktop_matches(coordinates_t *loc, coordinates_t *ref, desktop_select_t sel)
+bool desktop_matches(coordinates_t *loc, coordinates_t *ref, desktop_select_t *sel)
 {
-       if (sel.occupied != OPTION_NONE &&
+       if (sel->occupied != OPTION_NONE &&
            loc->desktop->root == NULL
-           ? sel.occupied == OPTION_TRUE
-           : sel.occupied == OPTION_FALSE) {
+           ? sel->occupied == OPTION_TRUE
+           : sel->occupied == OPTION_FALSE) {
                return false;
        }
 
-       if (sel.focused != OPTION_NONE &&
+       if (sel->focused != OPTION_NONE &&
            loc->desktop != loc->monitor->desk
-           ? sel.focused == OPTION_TRUE
-           : sel.focused == OPTION_FALSE) {
+           ? sel->focused == OPTION_TRUE
+           : sel->focused == OPTION_FALSE) {
                return false;
        }
 
-       if (sel.urgent != OPTION_NONE &&
+       if (sel->urgent != OPTION_NONE &&
            !is_urgent(loc->desktop)
-           ? sel.urgent == OPTION_TRUE
-           : sel.urgent == OPTION_FALSE) {
+           ? sel->urgent == OPTION_TRUE
+           : sel->urgent == OPTION_FALSE) {
                return false;
        }
 
-       if (sel.local != OPTION_NONE &&
+       if (sel->local != OPTION_NONE &&
            ref->monitor != loc->monitor
-           ? sel.local == OPTION_TRUE
-           : sel.local == OPTION_FALSE) {
+           ? sel->local == OPTION_TRUE
+           : sel->local == OPTION_FALSE) {
                return false;
        }
 
        return true;
 }
 
-bool monitor_matches(coordinates_t *loc, __attribute__((unused)) coordinates_t *ref, monitor_select_t sel)
+bool monitor_matches(coordinates_t *loc, __attribute__((unused)) coordinates_t *ref, monitor_select_t *sel)
 {
-       if (sel.occupied != OPTION_NONE &&
+       if (sel->occupied != OPTION_NONE &&
            loc->monitor->desk->root == NULL
-           ? sel.occupied == OPTION_TRUE
-           : sel.occupied == OPTION_FALSE) {
+           ? sel->occupied == OPTION_TRUE
+           : sel->occupied == OPTION_FALSE) {
                return false;
        }
 
-       if (sel.focused != OPTION_NONE &&
+       if (sel->focused != OPTION_NONE &&
            mon != loc->monitor
-           ? sel.focused == OPTION_TRUE
-           : sel.focused == OPTION_FALSE) {
+           ? sel->focused == OPTION_TRUE
+           : sel->focused == OPTION_FALSE) {
                return false;
        }