From 853bb7345252d84e1ee33ae0b8ccde1a5b4b91b2 Mon Sep 17 00:00:00 2001 From: Emanuele Torre Date: Sat, 5 Sep 2020 20:45:31 +0200 Subject: [PATCH] Add {,user}_LAYOUT modifiers to desktop selectors `.tiled`, `.monocle`, `.user_tiled` and `.user_monocle` can now be used in desktop selectors. --- doc/bspwm.1 | 17 +++++++++++++++-- doc/bspwm.1.asciidoc | 9 +++++++++ src/parse.c | 4 ++++ src/query.c | 28 +++++++++++++++++++++++++++- src/types.h | 4 ++++ 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/doc/bspwm.1 b/doc/bspwm.1 index 3879ea1..c3cbd6e 100644 --- a/doc/bspwm.1 +++ b/doc/bspwm.1 @@ -4,10 +4,10 @@ .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 09/08/2020 .\" Manual: Bspwm Manual -.\" Source: Bspwm 0.9.10-8-ge64864b +.\" Source: Bspwm 0.9.10-9-gab72002 .\" Language: English .\" -.TH "BSPWM" "1" "09/08/2020" "Bspwm 0\&.9\&.10\-8\-ge64864b" "Bspwm Manual" +.TH "BSPWM" "1" "09/08/2020" "Bspwm 0\&.9\&.10\-9\-gab72002" "Bspwm Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -328,6 +328,9 @@ DESKTOP_SEL := [DESKTOP_SEL#](CYCLE_DIR|any|last|newest|older|newer| [MONITOR_SEL:](focused|^)| |)[\&.[!]focused][\&.[!]active] [\&.[!]occupied][\&.[!]urgent][\&.[!]local] + [\&.[!]LAYOUT][\&.[!]user_LAYOUT] + +LAYOUT := tiled|monocle .fi .if n \{\ .RE @@ -426,6 +429,16 @@ Only consider urgent desktops\&. .RS 4 Only consider desktops inside the reference monitor\&. .RE +.PP +[!](tiled|monocle) +.RS 4 +Only consider desktops with the given layout\&. +.RE +.PP +[!](user_tiled|user_monocle) +.RS 4 +Only consider desktops which have the given layout as userLayout\&. +.RE .RE .SS "Monitor" .sp diff --git a/doc/bspwm.1.asciidoc b/doc/bspwm.1.asciidoc index 06263bc..7a17b8d 100644 --- a/doc/bspwm.1.asciidoc +++ b/doc/bspwm.1.asciidoc @@ -211,6 +211,9 @@ DESKTOP_SEL := [DESKTOP_SEL#](CYCLE_DIR|any|last|newest|older|newer| [MONITOR_SEL:](focused|^)| |)[.[!]focused][.[!]active] [.[!]occupied][.[!]urgent][.[!]local] + [.[!]LAYOUT][.[!]user_LAYOUT] + +LAYOUT := tiled|monocle ---- Descriptors @@ -264,6 +267,12 @@ Modifiers [!]local:: Only consider desktops inside the reference monitor. +[!](tiled|monocle):: + Only consider desktops with the given layout. + +[!](user_tiled|user_monocle):: + Only consider desktops which have the given layout as userLayout. + Monitor ~~~~~~~ diff --git a/src/parse.c b/src/parse.c index d623fa0..05adf44 100644 --- a/src/parse.c +++ b/src/parse.c @@ -503,6 +503,10 @@ bool parse_desktop_modifiers(char *desc, desktop_select_t *sel) GET_MOD(active) GET_MOD(urgent) GET_MOD(local) + GET_MOD(tiled) + GET_MOD(monocle) + GET_MOD(user_tiled) + GET_MOD(user_monocle) } else { return false; } diff --git a/src/query.c b/src/query.c index 5181413..9e0cc63 100644 --- a/src/query.c +++ b/src/query.c @@ -511,7 +511,11 @@ desktop_select_t make_desktop_select(void) .focused = OPTION_NONE, .active = OPTION_NONE, .urgent = OPTION_NONE, - .local = OPTION_NONE + .local = OPTION_NONE, + .tiled = OPTION_NONE, + .monocle = OPTION_NONE, + .user_tiled = OPTION_NONE, + .user_monocle = OPTION_NONE }; return sel; } @@ -1240,6 +1244,28 @@ bool desktop_matches(coordinates_t *loc, coordinates_t *ref, desktop_select_t *s return false; } +#define DLAYOUT(p, e) \ + if (sel->p != OPTION_NONE && \ + loc->desktop->layout != e \ + ? sel->p == OPTION_TRUE \ + : sel->p == OPTION_FALSE) { \ + return false; \ + } + DLAYOUT(tiled, LAYOUT_TILED) + DLAYOUT(monocle, LAYOUT_MONOCLE) +#undef DLAYOUT + +#define DUSERLAYOUT(p, e) \ + if (sel->p != OPTION_NONE && \ + loc->desktop->user_layout != e \ + ? sel->p == OPTION_TRUE \ + : sel->p == OPTION_FALSE) { \ + return false; \ + } + DUSERLAYOUT(user_tiled, LAYOUT_TILED) + DUSERLAYOUT(user_monocle, LAYOUT_MONOCLE) +#undef DUSERLAYOUT + return true; } diff --git a/src/types.h b/src/types.h index 425b1f6..c11b591 100644 --- a/src/types.h +++ b/src/types.h @@ -193,6 +193,10 @@ typedef struct { option_bool_t active; option_bool_t urgent; option_bool_t local; + option_bool_t tiled; + option_bool_t monocle; + option_bool_t user_tiled; + option_bool_t user_monocle; } desktop_select_t; typedef struct { -- 2.44.0