Extend tiling/floating criteria with optional auto/user values (#4006)
The default `tiling` and `floating` behavior is preserved and matches both cases. Adds a new handler to `remanage_window` on A_I3_FLOATING_WINDOW change. Mainly in order to `run_assignments`, this makes `for_window [floating]` directives to work for windows which where initially opened as tiling. Now, when floating is enabled, `for_window` will trigger correctly. Same applies to `for_window [tiling]`. The obvious solution of `run_assignments` after `floating_{enable,disable}` doesn't work because `run_assignments` modifies the parser state in src/assignments.c:51. Fixes #3588 Co-Authored-By: Michael Stapelberg <michael@stapelberg.de>
This commit is contained in:
70
src/match.c
70
src/match.c
@ -215,15 +215,43 @@ bool match_matches_window(Match *match, i3Window *window) {
|
||||
}
|
||||
|
||||
if (match->window_mode != WM_ANY) {
|
||||
if ((con = con_by_window_id(window->id)) == NULL)
|
||||
if ((con = con_by_window_id(window->id)) == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool floating = (con_inside_floating(con) != NULL);
|
||||
|
||||
if ((match->window_mode == WM_TILING && floating) ||
|
||||
(match->window_mode == WM_FLOATING && !floating)) {
|
||||
LOG("window_mode does not match\n");
|
||||
return false;
|
||||
switch (match->window_mode) {
|
||||
case WM_TILING_AUTO:
|
||||
if (con->floating != FLOATING_AUTO_OFF) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case WM_TILING_USER:
|
||||
if (con->floating != FLOATING_USER_OFF) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case WM_TILING:
|
||||
if (con_inside_floating(con) != NULL) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case WM_FLOATING_AUTO:
|
||||
if (con->floating != FLOATING_AUTO_ON) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case WM_FLOATING_USER:
|
||||
if (con->floating != FLOATING_USER_ON) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case WM_FLOATING:
|
||||
if (con_inside_floating(con) == NULL) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case WM_ANY:
|
||||
assert(false);
|
||||
}
|
||||
|
||||
LOG("window_mode matches\n");
|
||||
@ -367,10 +395,38 @@ void match_parse_property(Match *match, const char *ctype, const char *cvalue) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(ctype, "tiling_from") == 0 &&
|
||||
cvalue != NULL &&
|
||||
strcmp(cvalue, "auto") == 0) {
|
||||
match->window_mode = WM_TILING_AUTO;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(ctype, "tiling_from") == 0 &&
|
||||
cvalue != NULL &&
|
||||
strcmp(cvalue, "user") == 0) {
|
||||
match->window_mode = WM_TILING_USER;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(ctype, "floating") == 0) {
|
||||
match->window_mode = WM_FLOATING;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(ctype, "floating_from") == 0 &&
|
||||
cvalue != NULL &&
|
||||
strcmp(cvalue, "auto") == 0) {
|
||||
match->window_mode = WM_FLOATING_AUTO;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(ctype, "floating_from") == 0 &&
|
||||
cvalue != NULL &&
|
||||
strcmp(cvalue, "user") == 0) {
|
||||
match->window_mode = WM_FLOATING_USER;
|
||||
return;
|
||||
}
|
||||
|
||||
ELOG("Unknown criterion: %s\n", ctype);
|
||||
}
|
||||
|
Reference in New Issue
Block a user