]> git.lizzy.rs Git - bspwm.git/commitdiff
Allow negated window modifiers to match non-wins
authorEmanuele Torre <torreemanuele6@gmail.com>
Tue, 1 Dec 2020 05:48:13 +0000 (06:48 +0100)
committerBastien Dejean <nihilhill@gmail.com>
Fri, 28 May 2021 10:17:06 +0000 (12:17 +0200)
For example, `.!floating` used to only match nodes that hold a window
that is not in floating state; now, `.!floating` will match any node
that is not a node that holds a window that's in floating state.

The old behavior was counterintuitive, since e.g. `.tiled` and `.!tiled`
were not complementaries (they were complementaries with respect to the
windows, not the nodes) while the other standard node modifiers were.

Closes #1232.

src/query.c

index c3faa0a0ccc1b18a1675b7aa95c3a00e1c92bddf..aaaf3eec94ec90d0997866e0d23a30135df0f92b 100644 (file)
@@ -1135,26 +1135,16 @@ bool node_matches(coordinates_t *loc, coordinates_t *ref, node_select_t *sel)
        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)) {
-               return false;
-       }
-
-       if (ref->node != NULL && ref->node->client != NULL &&
-           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) {
-               return false;
+#define NSPLIT(p, e) \
+       if (sel->p != OPTION_NONE && \
+           loc->node->split_type != e \
+           ? sel->p == OPTION_TRUE \
+           : sel->p == OPTION_FALSE) { \
+               return false; \
        }
+       NSPLIT(horizontal, TYPE_HORIZONTAL)
+       NSPLIT(vertical, TYPE_VERTICAL)
+#undef NSPLIT
 
        if (sel->descendant_of != OPTION_NONE &&
            !is_descendant(loc->node, ref->node)
@@ -1170,6 +1160,29 @@ bool node_matches(coordinates_t *loc, coordinates_t *ref, node_select_t *sel)
                return false;
        }
 
+       if (loc->node->client == NULL) {
+               if (sel->same_class == OPTION_TRUE ||
+                   sel->tiled == OPTION_TRUE ||
+                   sel->pseudo_tiled == OPTION_TRUE ||
+                   sel->floating == OPTION_TRUE ||
+                   sel->fullscreen == OPTION_TRUE ||
+                   sel->below == OPTION_TRUE ||
+                   sel->normal == OPTION_TRUE ||
+                   sel->above == OPTION_TRUE ||
+                   sel->urgent == OPTION_TRUE) {
+                       return false;
+               }
+               return true;
+       }
+
+       if (ref->node != NULL && ref->node->client != NULL &&
+           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) {
+               return false;
+       }
+
 #define WSTATE(p, e) \
        if (sel->p != OPTION_NONE && \
            loc->node->client->state != e \
@@ -1205,20 +1218,6 @@ bool node_matches(coordinates_t *loc, coordinates_t *ref, node_select_t *sel)
        WFLAG(urgent)
 #undef WFLAG
 
-       if (sel->horizontal != OPTION_NONE &&
-           loc->node->split_type != TYPE_HORIZONTAL
-           ? sel->horizontal == OPTION_TRUE
-           : sel->horizontal == OPTION_FALSE) {
-               return false;
-       }
-
-       if (sel->vertical != OPTION_NONE &&
-           loc->node->split_type != TYPE_VERTICAL
-           ? sel->vertical == OPTION_TRUE
-           : sel->vertical == OPTION_FALSE) {
-               return false;
-       }
-
        return true;
 }