aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@users.noreply.github.com>2022-11-12 16:44:08 +0100
committerGitHub <noreply@github.com>2022-11-12 16:44:08 +0100
commit1ba0eaca2298afda86fecc17549b2d5881aca5fe (patch)
tree001d270c12c1771304f24a6d5e7a77fd541f866f
parent2ac6180b90ce0860a6d99588af4801578070bf75 (diff)
downloadi3-1ba0eaca2298afda86fecc17549b2d5881aca5fe.tar.gz
i3-1ba0eaca2298afda86fecc17549b2d5881aca5fe.zip
Make floating_from and tiling_from criterion work in commands, too (#5278)
Fixes https://github.com/i3/i3/issues/5258
-rw-r--r--parser-specs/commands.spec18
-rw-r--r--release-notes/bugfixes/3-floating-from-tiling-from1
-rw-r--r--testcases/t/271-for_window_tilingfloating.t49
3 files changed, 66 insertions, 2 deletions
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 => <<EOT;
+use i3test i3_autostart => 0;
+use X11::XCB qw(PROP_MODE_REPLACE);
+
+my $config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
for_window [tiling] mark --add tiling
@@ -26,7 +29,8 @@ for_window [floating_from="auto"] mark --add floating_auto
for_window [tiling_from="user"] mark --add tiling_user
for_window [floating_from="user"] mark --add floating_user
EOT
-use X11::XCB qw(PROP_MODE_REPLACE);
+
+my $pid = launch_with_config($config);
##############################################################
# Check that the auto tiling / floating criteria work.
@@ -83,4 +87,45 @@ is_deeply($nodes[0]->{nodes}[0]->{marks}, [ 'B', 'floating_user' ], "Only 'float
##############################################################
+exit_gracefully($pid);
+
+################################################################################
+# Verify floating_from/tiling_from works as command criterion (issue #5258).
+################################################################################
+
+$config = <<EOT;
+# i3 config file (v4)
+font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
+
+for_window [tiling] mark --add tiling
+for_window [floating] mark --add floating
+EOT
+
+$pid = launch_with_config($config);
+
+$tmp = fresh_workspace;
+$A = open_window;
+$B = open_floating_window;
+
+@nodes = @{get_ws($tmp)->{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;