From a61f4a32abf4e1d023e97e5e5d3a56b3a537be9e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sat, 13 Jul 2013 18:29:12 -0400 Subject: [PATCH] Add mode modifier Allows selecting windows based on their mode (manual/automatic). This is useful for duplicating the old shift-can-be-transplant behavior. # Usage: squish DIR squish() { dir=$1 bspc window -w ${dir}.manual || bspc window -s ${dir} } --- query.c | 5 +++++ tree.c | 6 ++++++ types.h | 8 ++++++++ 3 files changed, 19 insertions(+) diff --git a/query.c b/query.c index 65d4a50..c7e5715 100644 --- a/query.c +++ b/query.c @@ -128,6 +128,7 @@ bool node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst) client_select_t sel; sel.type = CLIENT_TYPE_ALL; sel.class = CLIENT_CLASS_ALL; + sel.mode = CLIENT_MODE_ALL; char *tok; while ((tok = strrchr(desc, CAT_CHR)) != NULL) { tok[0] = '\0'; @@ -140,6 +141,10 @@ bool node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst) sel.class = CLIENT_CLASS_EQUAL; } else if (streq("unlike", tok)) { sel.class = CLIENT_CLASS_DIFFER; + } else if (streq("automatic", tok)) { + sel.mode = CLIENT_MODE_AUTOMATIC; + } else if (streq("manual", tok)) { + sel.mode = CLIENT_MODE_MANUAL; } } diff --git a/tree.c b/tree.c index 5543437..1424c55 100644 --- a/tree.c +++ b/tree.c @@ -63,6 +63,12 @@ bool node_matches(node_t *c, node_t *t, client_select_t sel) : sel.class == CLIENT_CLASS_EQUAL ) return false; + if (sel.mode != CLIENT_MODE_ALL && + t->split_mode == MODE_MANUAL + ? sel.mode == CLIENT_MODE_AUTOMATIC + : sel.mode == CLIENT_MODE_MANUAL) + return false; + return true; } diff --git a/types.h b/types.h index 6e0ef82..da78bc4 100644 --- a/types.h +++ b/types.h @@ -48,9 +48,17 @@ typedef enum { CLIENT_CLASS_DIFFER } client_class_t; + +typedef enum { + CLIENT_MODE_ALL, + CLIENT_MODE_AUTOMATIC, + CLIENT_MODE_MANUAL +} client_mode_t; + typedef struct { client_type_t type; client_class_t class; + client_mode_t mode; } client_select_t; typedef enum {