From 1ba0eaca2298afda86fecc17549b2d5881aca5fe Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 12 Nov 2022 16:44:08 +0100 Subject: [PATCH] Make floating_from and tiling_from criterion work in commands, too (#5278) Fixes https://github.com/i3/i3/issues/5258 --- parser-specs/commands.spec | 18 +++++++ .../bugfixes/3-floating-from-tiling-from | 1 + testcases/t/271-for_window_tilingfloating.t | 49 ++++++++++++++++++- 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 release-notes/bugfixes/3-floating-from-tiling-from diff --git a/parser-specs/commands.spec b/parser-specs/commands.spec index c0171d2e..284c0180 100644 --- a/parser-specs/commands.spec +++ b/parser-specs/commands.spec @@ -57,6 +57,8 @@ state CRITERIA: ctype = 'urgent' -> CRITERION ctype = 'workspace' -> CRITERION ctype = 'machine' -> CRITERION + ctype = 'floating_from' -> CRITERION_FROM + ctype = 'tiling_from' -> CRITERION_FROM ctype = 'tiling', 'floating', 'all' -> call cmd_criteria_add($ctype, NULL); CRITERIA ']' -> call cmd_criteria_match_windows(); INITIAL @@ -64,6 +66,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 cmd_criteria_add($ctype, $kind); CRITERIA + +state CRITERION_FROM_STR: + kind = 'auto', 'user' + -> CRITERION_FROM_STR_END + +state CRITERION_FROM_STR_END: + '"' + -> call cmd_criteria_add($ctype, $kind); CRITERIA + state CRITERION_STR: cvalue = word -> call cmd_criteria_add($ctype, $cvalue); CRITERIA diff --git a/release-notes/bugfixes/3-floating-from-tiling-from b/release-notes/bugfixes/3-floating-from-tiling-from new file mode 100644 index 00000000..a29b5102 --- /dev/null +++ b/release-notes/bugfixes/3-floating-from-tiling-from @@ -0,0 +1 @@ +The floating_from and tiling_from criteria now also work in commands diff --git a/testcases/t/271-for_window_tilingfloating.t b/testcases/t/271-for_window_tilingfloating.t index f3947d6e..f11908ab 100644 --- a/testcases/t/271-for_window_tilingfloating.t +++ b/testcases/t/271-for_window_tilingfloating.t @@ -14,7 +14,10 @@ # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf # (unless you are already familiar with Perl) # -use i3test i3_config => < 0; +use X11::XCB qw(PROP_MODE_REPLACE); + +my $config = <{nodes}[0]->{marks}, [ 'B', 'floating_user' ], "Only 'float ############################################################## +exit_gracefully($pid); + +################################################################################ +# Verify floating_from/tiling_from works as command criterion (issue #5258). +################################################################################ + +$config = <{nodes}}; +cmp_ok(@nodes, '==', 1, 'one tiling container on this workspace'); +is_deeply($nodes[0]->{marks}, [ 'tiling' ], "mark set for 'tiling' criterion"); + +@nodes = @{get_ws($tmp)->{floating_nodes}}; +cmp_ok(@nodes, '==', 1, 'one floating container on this workspace'); +is_deeply($nodes[0]->{nodes}[0]->{marks}, [ 'floating' ], "mark set for 'floating' criterion"); + +cmd '[tiling_from="auto" con_mark="tiling"] mark --add tiling_auto'; +cmd '[floating_from="auto" con_mark="floating"] mark --add floating_auto'; + +@nodes = @{get_ws($tmp)->{nodes}}; +cmp_ok(@nodes, '==', 1, 'one tiling container on this workspace'); +is_deeply($nodes[0]->{marks}, [ 'tiling', 'tiling_auto' ], "mark set for 'tiling' criterion"); + +@nodes = @{get_ws($tmp)->{floating_nodes}}; +cmp_ok(@nodes, '==', 1, 'one floating container on this workspace'); +is_deeply($nodes[0]->{nodes}[0]->{marks}, [ 'floating', 'floating_auto' ], "mark set for 'floating' criterion"); + +exit_gracefully($pid); + done_testing;