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}
    }
This commit is contained in:
Steven Allen 2013-07-13 18:29:12 -04:00
parent 74deafbf77
commit a61f4a32ab
3 changed files with 19 additions and 0 deletions

View file

@ -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;
}
}

6
tree.c
View file

@ -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;
}

View file

@ -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 {