aboutsummaryrefslogtreecommitdiff
path: root/src/match.c
diff options
context:
space:
mode:
authorOrestis Floros <orestisflo@gmail.com>2019-10-20 12:18:05 +0300
committerOrestis Floros <orestisflo@gmail.com>2020-04-10 14:27:02 +0200
commit1eb7cb248b9c0b8b9f4b3c82f030690b3586eaf5 (patch)
tree0cc79111525380287e7bd2e8575274643dae6be5 /src/match.c
parente2b2a286251481abd83e72127a6f486753756c7e (diff)
downloadi3-1eb7cb248b9c0b8b9f4b3c82f030690b3586eaf5.tar.gz
i3-1eb7cb248b9c0b8b9f4b3c82f030690b3586eaf5.zip
Extend tiling/floating criteria with optional auto/user values
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
Diffstat (limited to 'src/match.c')
-rw-r--r--src/match.c59
1 files changed, 52 insertions, 7 deletions
diff --git a/src/match.c b/src/match.c
index a8850af4..a4ef05a3 100644
--- a/src/match.c
+++ b/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,6 +395,23 @@ void match_parse_property(Match *match, const char *ctype, const char *cvalue) {
return;
}
+ if (strcmp(ctype, "tiling_auto") == 0) {
+ match->window_mode = WM_TILING_AUTO;
+ return;
+ }
+ if (strcmp(ctype, "tiling_user") == 0) {
+ match->window_mode = WM_TILING_USER;
+ return;
+ }
+ if (strcmp(ctype, "floating_auto") == 0) {
+ match->window_mode = WM_FLOATING_AUTO;
+ return;
+ }
+ if (strcmp(ctype, "floating_user") == 0) {
+ match->window_mode = WM_FLOATING_USER;
+ return;
+ }
+
if (strcmp(ctype, "floating") == 0) {
match->window_mode = WM_FLOATING;
return;