Skip to content

Commit

Permalink
Allow negated window modifiers to match non-wins
Browse files Browse the repository at this point in the history
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 baskerville#1232.
  • Loading branch information
emanuele6 authored and baskerville committed May 28, 2021
1 parent e908026 commit badfd6c
Showing 1 changed file with 32 additions and 33 deletions.
65 changes: 32 additions & 33 deletions src/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 \
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit badfd6c

Please sign in to comment.