Add con_move_to_output_name function

next
Orestis Floros 2017-09-16 20:14:35 +03:00
parent d726d09d49
commit e2bacc7df8
4 changed files with 35 additions and 23 deletions

View File

@ -307,7 +307,16 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates,
* visible workspace on the given output.
*
*/
void con_move_to_output(Con *con, Output *output);
void con_move_to_output(Con *con, Output *output, bool fix_coordinates);
/**
* Moves the given container to the currently focused container on the
* visible workspace on the output specified by the given name.
* The current output for the container is used to resolve relative names
* such as left, right, up, down.
*
*/
bool con_move_to_output_name(Con *con, const char *name, bool fix_coordinates);
/**
* Moves the given container to the given mark.

View File

@ -1044,25 +1044,7 @@ void cmd_move_con_to_output(I3_CMD, const char *name) {
TAILQ_FOREACH(current, &owindows, owindows) {
DLOG("matching: %p / %s\n", current->con, current->con->name);
Output *current_output = get_output_for_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);
had_error |= !con_move_to_output_name(current->con, name, true);
}
cmd_output->needs_tree_render = true;

View File

@ -1284,12 +1284,33 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool
* visible workspace on the given output.
*
*/
void con_move_to_output(Con *con, Output *output) {
void con_move_to_output(Con *con, Output *output, bool fix_coordinates) {
Con *ws = NULL;
GREP_FIRST(ws, output_get_content(output->con), workspace_is_visible(child));
assert(ws != NULL);
DLOG("Moving con %p to output %s\n", con, output_primary_name(output));
con_move_to_workspace(con, ws, false, false, false);
con_move_to_workspace(con, ws, fix_coordinates, false, false);
}
/*
* Moves the given container to the currently focused container on the
* visible workspace on the output specified by the given name.
* The current output for the container is used to resolve relative names
* such as left, right, up, down.
*
*/
bool con_move_to_output_name(Con *con, const char *name, bool fix_coordinates) {
Output *current_output = get_output_for_con(con);
assert(current_output != NULL);
Output *output = get_output_from_string(current_output, name);
if (output == NULL) {
ELOG("Could not find output \"%s\"\n", name);
return false;
}
con_move_to_output(con, output, fix_coordinates);
return true;
}
/*

View File

@ -384,7 +384,7 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
* needed e.g. for LibreOffice Impress multi-monitor
* presentations to work out of the box. */
if (output != NULL)
con_move_to_output(nc, output);
con_move_to_output(nc, output, false);
con_toggle_fullscreen(nc, CF_OUTPUT);
}
fs = NULL;