Merge pull request #1771 from Airblader/feature-1769
Implement new criterion 'workspace'.
This commit is contained in:
@ -411,6 +411,11 @@ void cmd_criteria_add(I3_CMD, char *ctype, char *cvalue) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(ctype, "workspace") == 0) {
|
||||
current_match->workspace = regex_new(cvalue);
|
||||
return;
|
||||
}
|
||||
|
||||
ELOG("Unknown criterion: %s\n", ctype);
|
||||
}
|
||||
|
||||
|
@ -137,6 +137,11 @@ CFGFUN(criteria_add, const char *ctype, const char *cvalue) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(ctype, "workspace") == 0) {
|
||||
current_match->workspace = regex_new(cvalue);
|
||||
return;
|
||||
}
|
||||
|
||||
ELOG("Unknown criterion: %s\n", ctype);
|
||||
}
|
||||
|
||||
|
15
src/match.c
15
src/match.c
@ -48,6 +48,7 @@ bool match_is_empty(Match *match) {
|
||||
match->class == NULL &&
|
||||
match->instance == NULL &&
|
||||
match->window_role == NULL &&
|
||||
match->workspace == NULL &&
|
||||
match->urgent == U_DONTCHECK &&
|
||||
match->id == XCB_NONE &&
|
||||
match->window_type == UINT32_MAX &&
|
||||
@ -78,6 +79,7 @@ void match_copy(Match *dest, Match *src) {
|
||||
DUPLICATE_REGEX(class);
|
||||
DUPLICATE_REGEX(instance);
|
||||
DUPLICATE_REGEX(window_role);
|
||||
DUPLICATE_REGEX(workspace);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -172,6 +174,19 @@ bool match_matches_window(Match *match, i3Window *window) {
|
||||
LOG("urgent matches oldest\n");
|
||||
}
|
||||
|
||||
if (match->workspace != NULL) {
|
||||
Con *con = con_by_window_id(window->id);
|
||||
assert(con != NULL);
|
||||
Con *ws = con_get_workspace(con);
|
||||
assert(ws != NULL);
|
||||
|
||||
if (regex_matches(match->workspace, ws->name)) {
|
||||
LOG("workspace matches (%s)\n", ws->name);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (match->dock != M_DONTCHECK) {
|
||||
if ((window->dock == W_DOCK_TOP && match->dock == M_DOCK_TOP) ||
|
||||
(window->dock == W_DOCK_BOTTOM && match->dock == M_DOCK_BOTTOM) ||
|
||||
|
Reference in New Issue
Block a user