]> git.lizzy.rs Git - bspwm.git/commitdiff
Honor all the descriptor-free constraints
authorBastien Dejean <nihilhill@gmail.com>
Sun, 26 Jul 2020 19:19:37 +0000 (21:19 +0200)
committerBastien Dejean <nihilhill@gmail.com>
Sun, 26 Jul 2020 19:19:37 +0000 (21:19 +0200)
Fixes #1094.

src/messages.c
src/query.c
src/query.h

index 0d3978cd1b014e881a7aa27920a7ba68800fe42a..d843c85c54a0c02845d09b61fd8da13c3be84946 100644 (file)
@@ -1096,11 +1096,11 @@ void cmd_query(char **args, int num, FILE *rsp)
        }
 
        if (dom == DOMAIN_NODE) {
-               if (query_node_ids(&ref, &trg, node_sel, rsp) < 1) {
+               if (query_node_ids(&ref, &trg, monitor_sel, desktop_sel, node_sel, rsp) < 1) {
                        fail(rsp, "");
                }
        } else if (dom == DOMAIN_DESKTOP) {
-               if (query_desktop_ids(&ref, &trg, desktop_sel, print_ids ? fprint_desktop_id : fprint_desktop_name, rsp) < 1) {
+               if (query_desktop_ids(&ref, &trg, monitor_sel, desktop_sel, print_ids ? fprint_desktop_id : fprint_desktop_name, rsp) < 1) {
                        fail(rsp, "");
                }
        } else if (dom == DOMAIN_MONITOR) {
index f1be4b2569377381bb13022326c98085d7a06ca0..c3a6077bd986e30bca842187d0c99aa860cb7afa 100644 (file)
@@ -242,15 +242,19 @@ void query_subscribers(FILE *rsp)
        fprintf(rsp, "]");
 }
 
-int query_node_ids(coordinates_t *ref, coordinates_t *trg, node_select_t *sel, FILE *rsp)
+int query_node_ids(coordinates_t *ref, coordinates_t *trg, monitor_select_t *mon_sel, desktop_select_t *desk_sel, node_select_t *sel, FILE *rsp)
 {
        int count = 0;
        for (monitor_t *m = mon_head; m != NULL; m = m->next) {
-               if (trg->monitor != NULL && m != trg->monitor) {
+               coordinates_t loc = {m, NULL, NULL};
+               if ((trg->monitor != NULL && m != trg->monitor) ||
+                   (mon_sel != NULL && !monitor_matches(&loc, ref, mon_sel))) {
                        continue;
                }
                for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
-                       if (trg->desktop != NULL && d != trg->desktop) {
+                       coordinates_t loc = {m, d, NULL};
+                       if ((trg->desktop != NULL && d != trg->desktop) ||
+                           (desk_sel != NULL && !desktop_matches(&loc, ref, desk_sel))) {
                                continue;
                        }
                        count += query_node_ids_in(d->root, d, m, ref, trg, sel, rsp);
@@ -277,11 +281,13 @@ int query_node_ids_in(node_t *n, desktop_t *d, monitor_t *m, coordinates_t *ref,
        return count;
 }
 
-int query_desktop_ids(coordinates_t *ref, coordinates_t *trg, desktop_select_t *sel, desktop_printer_t printer, FILE *rsp)
+int query_desktop_ids(coordinates_t *ref, coordinates_t *trg, monitor_select_t *mon_sel, desktop_select_t *sel, desktop_printer_t printer, FILE *rsp)
 {
        int count = 0;
        for (monitor_t *m = mon_head; m != NULL; m = m->next) {
-               if (trg->monitor != NULL && m != trg->monitor) {
+               coordinates_t loc = {m, NULL, NULL};
+               if ((trg->monitor != NULL && m != trg->monitor) ||
+                   (mon_sel != NULL && !monitor_matches(&loc, ref, mon_sel))) {
                        continue;
                }
                for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
@@ -303,7 +309,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);
index 02e78d541538518187fc347fe230a28d15f8d2e6..9d87e5b9d9678bda2c27006bc1957a532f5f7c4e 100644 (file)
@@ -57,9 +57,9 @@ void query_history(FILE *rsp);
 void query_coordinates(coordinates_t *loc, FILE *rsp);
 void query_stack(FILE *rsp);
 void query_subscribers(FILE *rsp);
-int query_node_ids(coordinates_t *ref, coordinates_t *trg, node_select_t *sel, FILE *rsp);
+int query_node_ids(coordinates_t *ref, coordinates_t *trg, monitor_select_t *mon_sel, desktop_select_t *desk_sel, 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 query_desktop_ids(coordinates_t *ref, coordinates_t *trg, desktop_select_t *sel, desktop_printer_t printer, FILE *rsp);
+int query_desktop_ids(coordinates_t *ref, coordinates_t *trg, monitor_select_t *mon_sel, desktop_select_t *sel, desktop_printer_t printer, FILE *rsp);
 int query_monitor_ids(coordinates_t *ref, coordinates_t *trg, monitor_select_t *sel, monitor_printer_t printer, FILE *rsp);
 void fprint_monitor_id(monitor_t *m, FILE *rsp);
 void fprint_monitor_name(monitor_t *m, FILE *rsp);