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:
Orestis Floros
2020-04-12 13:49:08 +02:00
committed by GitHub
parent e7191af8b3
commit ae757c6848
9 changed files with 216 additions and 26 deletions

View File

@ -181,16 +181,18 @@ state NO_FOCUS_END:
# Criteria: Used by for_window and assign.
state CRITERIA:
ctype = 'class' -> CRITERION
ctype = 'instance' -> CRITERION
ctype = 'window_role' -> CRITERION
ctype = 'con_id' -> CRITERION
ctype = 'id' -> CRITERION
ctype = 'window_type' -> CRITERION
ctype = 'con_mark' -> CRITERION
ctype = 'title' -> CRITERION
ctype = 'urgent' -> CRITERION
ctype = 'workspace' -> CRITERION
ctype = 'class' -> CRITERION
ctype = 'instance' -> CRITERION
ctype = 'window_role' -> CRITERION
ctype = 'con_id' -> CRITERION
ctype = 'id' -> CRITERION
ctype = 'window_type' -> CRITERION
ctype = 'con_mark' -> CRITERION
ctype = 'title' -> CRITERION
ctype = 'urgent' -> CRITERION
ctype = 'workspace' -> CRITERION
ctype = 'floating_from' -> CRITERION_FROM
ctype = 'tiling_from' -> CRITERION_FROM
ctype = 'tiling', 'floating'
-> call cfg_criteria_add($ctype, NULL); CRITERIA
']'
@ -199,6 +201,22 @@ state CRITERIA:
state CRITERION:
'=' -> CRITERION_STR
state CRITERION_FROM:
'=' -> CRITERION_FROM_STR_START
state CRITERION_FROM_STR_START:
'"' -> CRITERION_FROM_STR
kind = 'auto', 'user'
-> call cfg_criteria_add($ctype, $kind); CRITERIA
state CRITERION_FROM_STR:
kind = 'auto', 'user'
-> CRITERION_FROM_STR_END
state CRITERION_FROM_STR_END:
'"'
-> call cfg_criteria_add($ctype, $kind); CRITERIA
state CRITERION_STR:
cvalue = word
-> call cfg_criteria_add($ctype, $cvalue); CRITERIA