diff --git a/doc/bspwm.1 b/doc/bspwm.1
index e5694a5..6860c44 100644
--- a/doc/bspwm.1
+++ b/doc/bspwm.1
@@ -2,12 +2,12 @@
.\" Title: bspwm
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1
-.\" Date: 11/22/2015
+.\" Date: 11/23/2015
.\" Manual: Bspwm Manual
.\" Source: Bspwm 0.9
.\" Language: English
.\"
-.TH "BSPWM" "1" "11/22/2015" "Bspwm 0\&.9" "Bspwm Manual"
+.TH "BSPWM" "1" "11/23/2015" "Bspwm 0\&.9" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -95,7 +95,7 @@ Select a window\&.
.\}
.nf
WINDOW_SEL :=
- | (DIR|CYCLE_DIR|biggest|last|focused|older|newer)[\&.[!]automatic][\&.[!](tiled|pseudo_tiled|floating|fullscreen)][\&.below|\&.normal|\&.above][\&.[!]local][\&.[!]same_class][\&.[!]focused][\&.[!](urgent|sticky|private|locked)]
+ | (DIR|CYCLE_DIR|biggest|last|focused|older|newer)[\&.[!]automatic][\&.[!](tiled|pseudo_tiled|floating|fullscreen)][\&.[!](below|normal|above)][\&.[!]local][\&.[!]same_class][\&.[!]focused][\&.[!](urgent|sticky|private|locked)]
.fi
.if n \{\
.RE
@@ -183,9 +183,9 @@ Only consider windows in or not in the current desktop\&.
Only consider windows that have or don\(cqt have the given flag set\&.
.RE
.PP
-below|normal|above
+[!](below|normal|above)
.RS 4
-Only consider windows of the given layer\&.
+Only consider windows in or not in the given layer\&.
.RE
.RE
.SS "Desktop"
diff --git a/doc/bspwm.1.asciidoc b/doc/bspwm.1.asciidoc
index 417cdb1..485c486 100644
--- a/doc/bspwm.1.asciidoc
+++ b/doc/bspwm.1.asciidoc
@@ -68,7 +68,7 @@ Select a window.
----
WINDOW_SEL :=
- | (DIR|CYCLE_DIR|biggest|last|focused|older|newer)[.[!]automatic][.[!](tiled|pseudo_tiled|floating|fullscreen)][.below|.normal|.above][.[!]local][.[!]same_class][.[!]focused][.[!](urgent|sticky|private|locked)]
+ | (DIR|CYCLE_DIR|biggest|last|focused|older|newer)[.[!]automatic][.[!](tiled|pseudo_tiled|floating|fullscreen)][.[!](below|normal|above)][.[!]local][.[!]same_class][.[!]focused][.[!](urgent|sticky|private|locked)]
----
Primary Selectors
@@ -116,8 +116,8 @@ Modifiers
[!](private|urgent|sticky|locked)::
Only consider windows that have or don't have the given flag set.
-below|normal|above::
- Only consider windows of the given layer.
+[!](below|normal|above)::
+ Only consider windows in or not in the given layer.
Desktop
~~~~~~~
diff --git a/query.c b/query.c
index f7e0427..e2a54f0 100644
--- a/query.c
+++ b/query.c
@@ -253,7 +253,9 @@ client_select_t make_client_select(void)
.automatic = OPTION_NONE,
.local = OPTION_NONE,
.focused = OPTION_NONE,
- .layer = NULL
+ .below = OPTION_NONE,
+ .normal = OPTION_NONE,
+ .above = OPTION_NONE
};
return sel;
}
@@ -268,11 +270,6 @@ desktop_select_t make_desktop_select(void)
return sel;
}
-void cleanup_client_select(client_select_t *sel)
-{
- free(sel->layer);
-}
-
bool node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
{
client_select_t sel = make_client_select();
@@ -280,71 +277,32 @@ bool node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
while ((tok = strrchr(desc, CAT_CHR)) != NULL) {
tok[0] = '\0';
tok++;
+#define GET_MOD(k) \
+ } else if (streq(#k, tok)) { \
+ sel.k = OPTION_TRUE; \
+ } else if (streq("!" #k, tok)) { \
+ sel.k = OPTION_FALSE;
if (streq("tiled", tok)) {
sel.tiled = OPTION_TRUE;
} else if (streq("!tiled", tok)) {
sel.tiled = OPTION_FALSE;
- } else if (streq("pseudo_tiled", tok)) {
- sel.pseudo_tiled = OPTION_TRUE;
- } else if (streq("!pseudo_tiled", tok)) {
- sel.pseudo_tiled = OPTION_FALSE;
- } else if (streq("floating", tok)) {
- sel.floating = OPTION_TRUE;
- } else if (streq("!floating", tok)) {
- sel.floating = OPTION_FALSE;
- } else if (streq("same_class", tok)) {
- sel.same_class = OPTION_TRUE;
- } else if (streq("!same_class", tok)) {
- sel.same_class = OPTION_FALSE;
- } else if (streq("automatic", tok)) {
- sel.automatic = OPTION_TRUE;
- } else if (streq("!automatic", tok)) {
- sel.automatic = OPTION_FALSE;
- } else if (streq("fullscreen", tok)) {
- sel.fullscreen = OPTION_TRUE;
- } else if (streq("!fullscreen", tok)) {
- sel.fullscreen = OPTION_FALSE;
- } else if (streq("urgent", tok)) {
- sel.urgent = OPTION_TRUE;
- } else if (streq("!urgent", tok)) {
- sel.urgent = OPTION_FALSE;
- } else if (streq("local", tok)) {
- sel.local = OPTION_TRUE;
- } else if (streq("!local", tok)) {
- sel.local = OPTION_FALSE;
- } else if (streq("private", tok)) {
- sel.private = OPTION_TRUE;
- } else if (streq("!private", tok)) {
- sel.private = OPTION_FALSE;
- } else if (streq("sticky", tok)) {
- sel.sticky = OPTION_TRUE;
- } else if (streq("!sticky", tok)) {
- sel.sticky = OPTION_FALSE;
- } else if (streq("locked", tok)) {
- sel.locked = OPTION_TRUE;
- } else if (streq("!locked", tok)) {
- sel.locked = OPTION_FALSE;
- } else if (streq("focused", tok)) {
- sel.focused = OPTION_TRUE;
- } else if (streq("!focused", tok)) {
- sel.focused = OPTION_FALSE;
- } else if (streq("below", tok)) {
- if (sel.layer == NULL) {
- sel.layer = malloc(sizeof(stack_layer_t));
- }
- *(sel.layer) = LAYER_BELOW;
- } else if (streq("normal", tok)) {
- if (sel.layer == NULL) {
- sel.layer = malloc(sizeof(stack_layer_t));
- }
- *(sel.layer) = LAYER_NORMAL;
- } else if (streq("above", tok)) {
- if (sel.layer == NULL) {
- sel.layer = malloc(sizeof(stack_layer_t));
- }
- *(sel.layer) = LAYER_ABOVE;
+ GET_MOD(pseudo_tiled)
+ GET_MOD(floating)
+ GET_MOD(fullscreen)
+ GET_MOD(locked)
+ GET_MOD(sticky)
+ GET_MOD(private)
+ GET_MOD(urgent)
+ GET_MOD(same_class)
+ GET_MOD(automatic)
+ GET_MOD(local)
+ GET_MOD(focused)
+ GET_MOD(below)
+ GET_MOD(normal)
+ GET_MOD(above)
}
}
+#undef GET_MOD
dst->monitor = ref->monitor;
dst->desktop = ref->desktop;
@@ -387,8 +345,6 @@ bool node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
locate_window(wid, dst);
}
- cleanup_client_select(&sel);
-
return (dst->node != NULL);
}
@@ -629,7 +585,24 @@ bool node_matches(coordinates_t *loc, coordinates_t *ref, client_select_t sel)
return false;
}
- if (sel.layer != NULL && loc->node->client->layer != *(sel.layer)) {
+ if (sel.below != OPTION_NONE &&
+ loc->node->client->layer != LAYER_BELOW
+ ? sel.below == OPTION_TRUE
+ : sel.below == OPTION_FALSE) {
+ return false;
+ }
+
+ if (sel.normal != OPTION_NONE &&
+ loc->node->client->layer != LAYER_NORMAL
+ ? sel.normal == OPTION_TRUE
+ : sel.normal == OPTION_FALSE) {
+ return false;
+ }
+
+ if (sel.above != OPTION_NONE &&
+ loc->node->client->layer != LAYER_ABOVE
+ ? sel.above == OPTION_TRUE
+ : sel.above == OPTION_FALSE) {
return false;
}
diff --git a/query.h b/query.h
index 59a35be..09cbef5 100644
--- a/query.h
+++ b/query.h
@@ -47,7 +47,6 @@ void query_windows(coordinates_t loc, FILE *rsp);
void query_names(domain_t dom, coordinates_t loc, FILE *rsp);
client_select_t make_client_select(void);
desktop_select_t make_desktop_select(void);
-void cleanup_client_select(client_select_t *sel);
bool node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst);
bool desktop_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst);
bool monitor_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst);
diff --git a/types.h b/types.h
index 03e9ac0..e030c0f 100644
--- a/types.h
+++ b/types.h
@@ -139,7 +139,9 @@ typedef struct {
option_bool_t automatic;
option_bool_t local;
option_bool_t focused;
- stack_layer_t *layer;
+ option_bool_t below;
+ option_bool_t normal;
+ option_bool_t above;
} client_select_t;
typedef struct {