diff --git a/doc/bspwm.1 b/doc/bspwm.1
index 7e66d33..54c69b0 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.79.1
-.\" Date: 05/28/2016
+.\" Date: 09/22/2016
.\" Manual: Bspwm Manual
-.\" Source: Bspwm 0.9.1-80-g4583587
+.\" Source: Bspwm 0.9.1-95-g70b477d
.\" Language: English
.\"
-.TH "BSPWM" "1" "05/28/2016" "Bspwm 0\&.9\&.1\-80\-g4583587" "Bspwm Manual"
+.TH "BSPWM" "1" "09/22/2016" "Bspwm 0\&.9\&.1\-95\-g70b477d" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -96,7 +96,7 @@ Select a node\&.
.RS 4
.\}
.nf
-NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|last|older|newer|focused|pointed|biggest|)[\&.[!]focused][\&.[!]automatic][\&.[!]local][\&.[!]leaf][\&.[!]window][\&.[!]STATE][\&.[!]FLAG][\&.[!]LAYER][\&.[!]same_class][\&.[!]descendant_of][\&.[!]ancestor_of]
+NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|last|older|newer|focused|pointed|biggest|)[\&.[!]focused][\&.[!]automatic][\&.[!]local][\&.[!]active][\&.[!]leaf][\&.[!]window][\&.[!]STATE][\&.[!]FLAG][\&.[!]LAYER][\&.[!]same_class][\&.[!]descendant_of][\&.[!]ancestor_of]
STATE := tiled|pseudo_tiled|floating|fullscreen
@@ -230,6 +230,11 @@ Only consider nodes in automatic or manual insertion mode\&.
Only consider nodes in or not in the reference desktop\&.
.RE
.PP
+[!]active
+.RS 4
+Only consider nodes in or not in the active desktop of their monitor\&.
+.RE
+.PP
[!]leaf
.RS 4
Only consider leaves or internal nodes\&.
diff --git a/doc/bspwm.1.asciidoc b/doc/bspwm.1.asciidoc
index 3282069..0c538e1 100644
--- a/doc/bspwm.1.asciidoc
+++ b/doc/bspwm.1.asciidoc
@@ -70,7 +70,7 @@ Node
Select a node.
----
-NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|last|older|newer|focused|pointed|biggest|)[.[!]focused][.[!]automatic][.[!]local][.[!]leaf][.[!]window][.[!]STATE][.[!]FLAG][.[!]LAYER][.[!]same_class][.[!]descendant_of][.[!]ancestor_of]
+NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|last|older|newer|focused|pointed|biggest|)[.[!]focused][.[!]automatic][.[!]local][.[!]active][.[!]leaf][.[!]window][.[!]STATE][.[!]FLAG][.[!]LAYER][.[!]same_class][.[!]descendant_of][.[!]ancestor_of]
STATE := tiled|pseudo_tiled|floating|fullscreen
@@ -148,6 +148,9 @@ Modifiers
[!]local::
Only consider nodes in or not in the reference desktop.
+[!]active::
+ Only consider nodes in or not in the active desktop of their monitor.
+
[!]leaf::
Only consider leaves or internal nodes.
diff --git a/parse.c b/parse.c
index 5c40672..2ee1a2d 100644
--- a/parse.c
+++ b/parse.c
@@ -439,6 +439,7 @@ bool parse_node_modifiers(char *desc, node_select_t *sel)
GET_MOD(automatic)
GET_MOD(focused)
GET_MOD(local)
+ GET_MOD(active)
GET_MOD(leaf)
GET_MOD(window)
GET_MOD(pseudo_tiled)
diff --git a/query.c b/query.c
index 11e774a..025d506 100644
--- a/query.c
+++ b/query.c
@@ -339,6 +339,7 @@ node_select_t make_node_select(void)
.automatic = OPTION_NONE,
.focused = OPTION_NONE,
.local = OPTION_NONE,
+ .active = OPTION_NONE,
.leaf = OPTION_NONE,
.window = OPTION_NONE,
.tiled = OPTION_NONE,
@@ -851,6 +852,13 @@ bool node_matches(coordinates_t *loc, coordinates_t *ref, node_select_t sel)
return false;
}
+ if (sel.active != OPTION_NONE &&
+ loc->desktop != loc->monitor->desk
+ ? sel.active == OPTION_TRUE
+ : sel.active == OPTION_FALSE) {
+ return false;
+ }
+
if (sel.leaf != OPTION_NONE &&
!is_leaf(loc->node)
? sel.leaf == OPTION_TRUE
diff --git a/types.h b/types.h
index 2ad5c2f..3df8869 100644
--- a/types.h
+++ b/types.h
@@ -143,6 +143,7 @@ typedef struct {
option_bool_t automatic;
option_bool_t focused;
option_bool_t local;
+ option_bool_t active;
option_bool_t leaf;
option_bool_t window;
option_bool_t tiled;