Skip to content

Commit 853bb73

Browse files
emanuele6baskerville
authored andcommitted
Add {,user}_LAYOUT modifiers to desktop selectors
`.tiled`, `.monocle`, `.user_tiled` and `.user_monocle` can now be used in desktop selectors.
1 parent 09d86ca commit 853bb73

File tree

5 files changed

+59
-3
lines changed

5 files changed

+59
-3
lines changed

doc/bspwm.1

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
55
.\" Date: 09/08/2020
66
.\" Manual: Bspwm Manual
7-
.\" Source: Bspwm 0.9.10-8-ge64864b
7+
.\" Source: Bspwm 0.9.10-9-gab72002
88
.\" Language: English
99
.\"
10-
.TH "BSPWM" "1" "09/08/2020" "Bspwm 0\&.9\&.10\-8\-ge64864b" "Bspwm Manual"
10+
.TH "BSPWM" "1" "09/08/2020" "Bspwm 0\&.9\&.10\-9\-gab72002" "Bspwm Manual"
1111
.\" -----------------------------------------------------------------
1212
.\" * Define some portability stuff
1313
.\" -----------------------------------------------------------------
@@ -328,6 +328,9 @@ DESKTOP_SEL := [DESKTOP_SEL#](CYCLE_DIR|any|last|newest|older|newer|
328328
[MONITOR_SEL:](focused|^<n>)|
329329
<desktop_id>|<desktop_name>)[\&.[!]focused][\&.[!]active]
330330
[\&.[!]occupied][\&.[!]urgent][\&.[!]local]
331+
[\&.[!]LAYOUT][\&.[!]user_LAYOUT]
332+
333+
LAYOUT := tiled|monocle
331334
.fi
332335
.if n \{\
333336
.RE
@@ -426,6 +429,16 @@ Only consider urgent desktops\&.
426429
.RS 4
427430
Only consider desktops inside the reference monitor\&.
428431
.RE
432+
.PP
433+
[!](tiled|monocle)
434+
.RS 4
435+
Only consider desktops with the given layout\&.
436+
.RE
437+
.PP
438+
[!](user_tiled|user_monocle)
439+
.RS 4
440+
Only consider desktops which have the given layout as userLayout\&.
441+
.RE
429442
.RE
430443
.SS "Monitor"
431444
.sp

doc/bspwm.1.asciidoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ DESKTOP_SEL := [DESKTOP_SEL#](CYCLE_DIR|any|last|newest|older|newer|
211211
[MONITOR_SEL:](focused|^<n>)|
212212
<desktop_id>|<desktop_name>)[.[!]focused][.[!]active]
213213
[.[!]occupied][.[!]urgent][.[!]local]
214+
[.[!]LAYOUT][.[!]user_LAYOUT]
215+
216+
LAYOUT := tiled|monocle
214217
----
215218

216219
Descriptors
@@ -264,6 +267,12 @@ Modifiers
264267
[!]local::
265268
Only consider desktops inside the reference monitor.
266269

270+
[!](tiled|monocle)::
271+
Only consider desktops with the given layout.
272+
273+
[!](user_tiled|user_monocle)::
274+
Only consider desktops which have the given layout as userLayout.
275+
267276
Monitor
268277
~~~~~~~
269278

src/parse.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,10 @@ bool parse_desktop_modifiers(char *desc, desktop_select_t *sel)
503503
GET_MOD(active)
504504
GET_MOD(urgent)
505505
GET_MOD(local)
506+
GET_MOD(tiled)
507+
GET_MOD(monocle)
508+
GET_MOD(user_tiled)
509+
GET_MOD(user_monocle)
506510
} else {
507511
return false;
508512
}

src/query.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,11 @@ desktop_select_t make_desktop_select(void)
511511
.focused = OPTION_NONE,
512512
.active = OPTION_NONE,
513513
.urgent = OPTION_NONE,
514-
.local = OPTION_NONE
514+
.local = OPTION_NONE,
515+
.tiled = OPTION_NONE,
516+
.monocle = OPTION_NONE,
517+
.user_tiled = OPTION_NONE,
518+
.user_monocle = OPTION_NONE
515519
};
516520
return sel;
517521
}
@@ -1240,6 +1244,28 @@ bool desktop_matches(coordinates_t *loc, coordinates_t *ref, desktop_select_t *s
12401244
return false;
12411245
}
12421246

1247+
#define DLAYOUT(p, e) \
1248+
if (sel->p != OPTION_NONE && \
1249+
loc->desktop->layout != e \
1250+
? sel->p == OPTION_TRUE \
1251+
: sel->p == OPTION_FALSE) { \
1252+
return false; \
1253+
}
1254+
DLAYOUT(tiled, LAYOUT_TILED)
1255+
DLAYOUT(monocle, LAYOUT_MONOCLE)
1256+
#undef DLAYOUT
1257+
1258+
#define DUSERLAYOUT(p, e) \
1259+
if (sel->p != OPTION_NONE && \
1260+
loc->desktop->user_layout != e \
1261+
? sel->p == OPTION_TRUE \
1262+
: sel->p == OPTION_FALSE) { \
1263+
return false; \
1264+
}
1265+
DUSERLAYOUT(user_tiled, LAYOUT_TILED)
1266+
DUSERLAYOUT(user_monocle, LAYOUT_MONOCLE)
1267+
#undef DUSERLAYOUT
1268+
12431269
return true;
12441270
}
12451271

src/types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ typedef struct {
193193
option_bool_t active;
194194
option_bool_t urgent;
195195
option_bool_t local;
196+
option_bool_t tiled;
197+
option_bool_t monocle;
198+
option_bool_t user_tiled;
199+
option_bool_t user_monocle;
196200
} desktop_select_t;
197201

198202
typedef struct {

0 commit comments

Comments
 (0)