+right+, +up+ or +down+), there are two commands:
*Syntax*:
-----------------------------------------------------
-move container to output left|right|down|up|<output>
-move workspace to output left|right|down|up|<output>
-----------------------------------------------------
+------------------------------------------------------------
+move container to output left|right|down|up|current|<output>
+move workspace to output left|right|down|up|current|<output>
+------------------------------------------------------------
*Examples*:
--------------------------------------------------------
*/
Output *get_output_from_string(Output *current_output, const char *output_str);
+/**
+ * Returns the output for the given con.
+ *
+ */
+Output *get_output_for_con(Con *con);
+
/**
* Iterates over all outputs and pushes sticky windows to the currently visible
* workspace on that output.
return (a - b) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
-/*
- * Returns the output containing the given container.
- */
-static Output *get_output_of_con(Con *con) {
- Con *output_con = con_get_output(con);
- Output *output = get_output_by_name(output_con->name);
- assert(output != NULL);
-
- return output;
-}
-
/*
* Checks whether we switched to a new workspace and returns false in that case,
* signaling that further workspace switching should be done by the calling function
TAILQ_FOREACH(current, &owindows, owindows) {
DLOG("matching: %p / %s\n", current->con, current->con->name);
- Output *current_output = get_output_of_con(current->con);
+ Output *current_output = get_output_for_con(current->con);
assert(current_output != NULL);
Output *output = get_output_from_string(current_output, name);
Output *output;
TAILQ_FOREACH(current, &owindows, owindows)
- current_output = get_output_of_con(current->con);
+ current_output = get_output_for_con(current->con);
assert(current_output != NULL);
output = get_output_from_string(current_output, name);
*/
static void move_to_output_directed(Con *con, direction_t direction) {
Con *old_ws = con_get_workspace(con);
- Con *current_output_con = con_get_output(con);
- Output *current_output = get_output_by_name(current_output_con->name);
+ Output *current_output = get_output_for_con(con);
Output *output = get_output_next(direction, current_output, CLOSEST_OUTPUT);
if (!output) {
*
*/
Output *get_output_from_string(Output *current_output, const char *output_str) {
- Output *output;
+ if (strcasecmp(output_str, "current") == 0) {
+ return get_output_for_con(focused);
+ } else if (strcasecmp(output_str, "left") == 0) {
+ return get_output_next_wrap(D_LEFT, current_output);
+ } else if (strcasecmp(output_str, "right") == 0) {
+ return get_output_next_wrap(D_RIGHT, current_output);
+ } else if (strcasecmp(output_str, "up") == 0) {
+ return get_output_next_wrap(D_UP, current_output);
+ } else if (strcasecmp(output_str, "down") == 0) {
+ return get_output_next_wrap(D_DOWN, current_output);
+ }
+
+ return get_output_by_name(output_str);
+}
- if (strcasecmp(output_str, "left") == 0)
- output = get_output_next_wrap(D_LEFT, current_output);
- else if (strcasecmp(output_str, "right") == 0)
- output = get_output_next_wrap(D_RIGHT, current_output);
- else if (strcasecmp(output_str, "up") == 0)
- output = get_output_next_wrap(D_UP, current_output);
- else if (strcasecmp(output_str, "down") == 0)
- output = get_output_next_wrap(D_DOWN, current_output);
- else
- output = get_output_by_name(output_str);
+Output *get_output_for_con(Con *con) {
+ Con *output_con = con_get_output(con);
+ if (output_con == NULL) {
+ ELOG("Could not get the output container for con = %p.\n", con);
+ return NULL;
+ }
+
+ Output *output = get_output_by_name(output_con->name);
+ if (output == NULL) {
+ ELOG("Could not get output from name \"%s\".\n", output_con->name);
+ return NULL;
+ }
return output;
}
bool workspace_move_to_output(Con *ws, const char *name) {
LOG("Trying to move workspace %p / %s to output \"%s\".\n", ws, ws->name, name);
- Con *current_output_con = con_get_output(ws);
- if (!current_output_con) {
- ELOG("Could not get the output container for workspace %p / %s.\n", ws, ws->name);
- return false;
- }
-
- Output *current_output = get_output_by_name(current_output_con->name);
- if (!current_output) {
+ Output *current_output = get_output_for_con(ws);
+ if (current_output == NULL) {
ELOG("Cannot get current output. This is a bug in i3.\n");
return false;
}
+
Output *output = get_output_from_string(current_output, name);
if (!output) {
ELOG("Could not get output from string \"%s\"\n", name);
use List::Util qw(first);
use i3test i3_autostart => 0;
-# TODO:
-# introduce 'move workspace 3 to output <output>' with synonym 'move workspace 3 to <output>'
-
# Ensure the pointer is at (0, 0) so that we really start on the first
# (the left) workspace.
$x->root->warp_pointer(0, 0);
ok(!($empty_ws ~~ @$x1), 'empty_ws not on fake-1');
ok($other_output_ws ~~ @$x0, 'other_output_ws on fake-0');
-exit_gracefully($pid);
+################################################################################
+# Verify that the special word 'current' can be used for the output.
+################################################################################
+my $ws1 = fresh_workspace(output => 1);
+open_window;
+cmd 'mark marked';
+
+my $ws0 = fresh_workspace(output => 0);
+
+($x0, $x1) = workspaces_per_screen();
+ok($ws0 ~~ @$x0, 'ws0 on fake-0');
+ok($ws1 ~~ @$x1, 'ws1 on fake-1');
+
+cmd '[con_mark=marked] move workspace to output current';
+
+($x0, $x1) = workspaces_per_screen();
+ok($ws1 ~~ @$x0, 'ws1 on fake-0');
+
+################################################################################
+
+exit_gracefully($pid);
done_testing;