Correctly handle command criteria for "move window to output".
This commit is contained in:
parent
ee5db875c2
commit
852a2853e3
|
@ -1194,41 +1194,37 @@ void cmd_mode(I3_CMD, char *mode) {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void cmd_move_con_to_output(I3_CMD, char *name) {
|
void cmd_move_con_to_output(I3_CMD, char *name) {
|
||||||
owindow *current;
|
DLOG("Should move window to output \"%s\".\n", name);
|
||||||
|
|
||||||
DLOG("should move window to output %s\n", name);
|
|
||||||
|
|
||||||
HANDLE_EMPTY_MATCH;
|
HANDLE_EMPTY_MATCH;
|
||||||
|
|
||||||
Output *current_output = NULL;
|
owindow *current;
|
||||||
// TODO: fix the handling of criteria
|
bool had_error = false;
|
||||||
TAILQ_FOREACH(current, &owindows, owindows)
|
|
||||||
current_output = get_output_of_con(current->con);
|
|
||||||
assert(current_output != NULL);
|
|
||||||
|
|
||||||
Output *output = get_output_from_string(current_output, name);
|
|
||||||
if (!output) {
|
|
||||||
LOG("No such output found.\n");
|
|
||||||
ysuccess(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get visible workspace on output */
|
|
||||||
Con *ws = NULL;
|
|
||||||
GREP_FIRST(ws, output_get_content(output->con), workspace_is_visible(child));
|
|
||||||
if (!ws) {
|
|
||||||
ysuccess(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TAILQ_FOREACH(current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
|
|
||||||
|
Output *current_output = get_output_of_con(current->con);
|
||||||
|
assert(current_output != NULL);
|
||||||
|
|
||||||
|
Output *output = get_output_from_string(current_output, name);
|
||||||
|
if (output == NULL) {
|
||||||
|
ELOG("Could not find output \"%s\", skipping.\n", name);
|
||||||
|
had_error = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Con *ws = NULL;
|
||||||
|
GREP_FIRST(ws, output_get_content(output->con), workspace_is_visible(child));
|
||||||
|
if (ws == NULL) {
|
||||||
|
ELOG("Could not find a visible workspace on output %p.\n", output);
|
||||||
|
had_error = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
con_move_to_workspace(current->con, ws, true, false, false);
|
con_move_to_workspace(current->con, ws, true, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_output->needs_tree_render = true;
|
cmd_output->needs_tree_render = true;
|
||||||
// XXX: default reply for now, make this a better reply
|
ysuccess(!had_error);
|
||||||
ysuccess(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
#!perl
|
||||||
|
# vim:ts=4:sw=4:expandtab
|
||||||
|
#
|
||||||
|
# Please read the following documents before working on tests:
|
||||||
|
# • http://build.i3wm.org/docs/testsuite.html
|
||||||
|
# (or docs/testsuite)
|
||||||
|
#
|
||||||
|
# • http://build.i3wm.org/docs/lib-i3test.html
|
||||||
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
||||||
|
#
|
||||||
|
# • http://build.i3wm.org/docs/ipc.html
|
||||||
|
# (or docs/ipc)
|
||||||
|
#
|
||||||
|
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
||||||
|
# (unless you are already familiar with Perl)
|
||||||
|
#
|
||||||
|
# Verifies that "move container to output" works correctly when
|
||||||
|
# used with command criteria.
|
||||||
|
# Bug still in: 4.10.4-349-gee5db87
|
||||||
|
use i3test i3_autostart => 0;
|
||||||
|
|
||||||
|
my $config = <<EOT;
|
||||||
|
# i3 config file (v4)
|
||||||
|
font pango:monospace 8
|
||||||
|
|
||||||
|
fake-outputs 800x600+0+0,800x600+800+0,800x600+0+600,800x600+800+600
|
||||||
|
EOT
|
||||||
|
|
||||||
|
my $pid = launch_with_config($config);
|
||||||
|
|
||||||
|
my $ws_top_left = fresh_workspace(output => 0);
|
||||||
|
my $ws_top_right = fresh_workspace(output => 1);
|
||||||
|
my $ws_bottom_left = fresh_workspace(output => 2);
|
||||||
|
my $ws_bottom_right = fresh_workspace(output => 3);
|
||||||
|
|
||||||
|
cmd "workspace " . $ws_top_left;
|
||||||
|
open_window(wm_class => 'moveme');
|
||||||
|
cmd "workspace " . $ws_bottom_left;
|
||||||
|
open_window(wm_class => 'moveme');
|
||||||
|
|
||||||
|
cmd '[class="moveme"] move window to output right';
|
||||||
|
|
||||||
|
is_num_children($ws_top_left, 0, 'no containers on the upper left workspace');
|
||||||
|
is_num_children($ws_top_right, 1, 'one container on the upper right workspace');
|
||||||
|
is_num_children($ws_bottom_left, 0, 'no containers on the lower left workspace');
|
||||||
|
is_num_children($ws_bottom_right, 1, 'one container on the lower right workspace');
|
||||||
|
|
||||||
|
exit_gracefully($pid);
|
||||||
|
|
||||||
|
done_testing;
|
Loading…
Reference in New Issue