From cf2d40772e76e2f7994343420f7b3d148cce88e8 Mon Sep 17 00:00:00 2001 From: tobias Date: Mon, 9 Mar 2020 18:48:56 +0100 Subject: [PATCH] Add node modifiers: `horizontal`, `vertical` --- doc/bspwm.1 | 14 ++++++++++++-- doc/bspwm.1.asciidoc | 6 ++++++ src/parse.c | 2 ++ src/query.c | 18 +++++++++++++++++- src/types.h | 2 ++ 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/doc/bspwm.1 b/doc/bspwm.1 index 7e0a5c4..e1ae476 100644 --- a/doc/bspwm.1 +++ b/doc/bspwm.1 @@ -4,10 +4,10 @@ .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 03/16/2020 .\" Manual: Bspwm Manual -.\" Source: Bspwm 0.9.9-6-g41b2de0 +.\" Source: Bspwm 0.9.9-7-gda1dc1d .\" Language: English .\" -.TH "BSPWM" "1" "03/16/2020" "Bspwm 0\&.9\&.9\-6\-g41b2de0" "Bspwm Manual" +.TH "BSPWM" "1" "03/16/2020" "Bspwm 0\&.9\&.9\-7\-gda1dc1d" "Bspwm Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -274,6 +274,16 @@ Only consider nodes in the reference desktop\&. Only consider leaf nodes\&. .RE .PP +[!]horizontal +.RS 4 +Only consider nodes whose split type is horizontal\&. +.RE +.PP +[!]vertical +.RS 4 +Only consider nodes whose split type is vertical\&. +.RE +.PP [!]window .RS 4 Only consider nodes that hold a window\&. diff --git a/doc/bspwm.1.asciidoc b/doc/bspwm.1.asciidoc index fac7616..da6f80d 100644 --- a/doc/bspwm.1.asciidoc +++ b/doc/bspwm.1.asciidoc @@ -174,6 +174,12 @@ Modifiers [!]leaf:: Only consider leaf nodes. +[!]horizontal:: + Only consider nodes whose split type is horizontal. + +[!]vertical:: + Only consider nodes whose split type is vertical. + [!]window:: Only consider nodes that hold a window. diff --git a/src/parse.c b/src/parse.c index 8035d10..d623fa0 100644 --- a/src/parse.c +++ b/src/parse.c @@ -542,6 +542,8 @@ bool parse_node_modifiers(char *desc, node_select_t *sel) GET_MOD(below) GET_MOD(normal) GET_MOD(above) + GET_MOD(horizontal) + GET_MOD(vertical) } else { return false; } diff --git a/src/query.c b/src/query.c index 4959f81..f1be4b2 100644 --- a/src/query.c +++ b/src/query.c @@ -470,7 +470,9 @@ node_select_t make_node_select(void) .ancestor_of = OPTION_NONE, .below = OPTION_NONE, .normal = OPTION_NONE, - .above = OPTION_NONE + .above = OPTION_NONE, + .horizontal = OPTION_NONE, + .vertical = OPTION_NONE }; return sel; } @@ -1140,6 +1142,20 @@ 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; } diff --git a/src/types.h b/src/types.h index 2c15a26..9da6565 100644 --- a/src/types.h +++ b/src/types.h @@ -183,6 +183,8 @@ typedef struct { option_bool_t below; option_bool_t normal; option_bool_t above; + option_bool_t horizontal; + option_bool_t vertical; } node_select_t; typedef struct { -- 2.44.0