# enable floating mode and move container to workspace 4
for_window [class="^evil-app$"] floating enable, move container to workspace 4
+
+# move all floating windows to the scratchpad
+bindsym $mod+x [floating] move scratchpad
------------------------------------
The criteria which are currently implemented are:
Compares the i3-internal container ID, which you can get via the IPC
interface. Handy for scripting. Use the special value +\_\_focused__+
to match only the currently focused window.
+floating::
+ Only matches floating windows. This criterion requires no value.
+tiling::
+ Only matches tiling windows. This criterion requires no value.
The criteria +class+, +instance+, +role+, +title+, +workspace+ and +mark+ are
actually regular expressions (PCRE). See +pcresyntax(3)+ or +perldoc perlre+ for
M_DOCK_BOTTOM = 3
} dock;
xcb_window_t id;
- enum { M_ANY = 0,
- M_TILING,
- M_FLOATING } floating;
+ enum { WM_ANY = 0,
+ WM_TILING,
+ WM_FLOATING } window_mode;
Con *con_id;
/* Where the window looking for a match should be inserted:
ctype = 'title' -> CRITERION
ctype = 'urgent' -> CRITERION
ctype = 'workspace' -> CRITERION
+ ctype = 'tiling', 'floating'
+ -> call cmd_criteria_add($ctype, NULL); CRITERIA
']' -> call cmd_criteria_match_windows(); INITIAL
state CRITERION:
ctype = 'title' -> CRITERION
ctype = 'urgent' -> CRITERION
ctype = 'workspace' -> CRITERION
+ ctype = 'tiling', 'floating'
+ -> call cfg_criteria_add($ctype, NULL); CRITERIA
']'
-> call cfg_criteria_pop_state()
void match_init(Match *match) {
memset(match, 0, sizeof(Match));
match->urgent = U_DONTCHECK;
+ match->window_mode = WM_ANY;
/* we use this as the placeholder value for "not set". */
match->window_type = UINT32_MAX;
}
match->window_type == UINT32_MAX &&
match->con_id == NULL &&
match->dock == M_NODOCK &&
- match->floating == M_ANY);
+ match->window_mode == WM_ANY);
}
/*
}
}
+ if (match->window_mode != WM_ANY) {
+ 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;
+ }
+
+ LOG("window_mode matches\n");
+ }
+
return true;
}
return;
}
+ if (strcmp(ctype, "tiling") == 0) {
+ match->window_mode = WM_TILING;
+ return;
+ }
+
+ if (strcmp(ctype, "floating") == 0) {
+ match->window_mode = WM_FLOATING;
+ return;
+ }
+
ELOG("Unknown criterion: %s\n", ctype);
}
exit_gracefully($pid);
+##############################################################
+# 13: check that the tiling / floating criteria work.
+##############################################################
+
+$config = <<"EOT";
+# i3 config file (v4)
+font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
+for_window [tiling] mark tiled
+for_window [floating] mark floated
+EOT
+
+$pid = launch_with_config($config);
+$tmp = fresh_workspace;
+
+open_window;
+open_floating_window;
+
+@nodes = @{get_ws($tmp)->{nodes}};
+cmp_ok(@nodes, '==', 1, 'one tiling container on this workspace');
+is_deeply($nodes[0]->{marks}, [ 'tiled' ], "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}, [ 'floated' ], "mark set for 'floating' criterion");
+
+exit_gracefully($pid);
+
##############################################################
done_testing;