get_output_for_con: Assert result != NULL
- The result from con_get_output was always not NULL because con_get_output asserts so - get_output_by_name should always be able to get an output from the corresponding container - workspace_move_to_output doesn't return bool anymore since it can't fail
This commit is contained in:
parent
d0ab51db85
commit
351d891f4c
|
@ -218,7 +218,6 @@ Con *workspace_encapsulate(Con *ws);
|
|||
|
||||
/**
|
||||
* Move the given workspace to the specified output.
|
||||
* This returns true if and only if moving the workspace was successful.
|
||||
*
|
||||
*/
|
||||
bool workspace_move_to_output(Con *ws, Output *output);
|
||||
void workspace_move_to_output(Con *ws, Output *output);
|
||||
|
|
|
@ -1114,22 +1114,13 @@ void cmd_move_workspace_to_output(I3_CMD, const char *name) {
|
|||
}
|
||||
|
||||
Output *current_output = get_output_for_con(ws);
|
||||
if (current_output == NULL) {
|
||||
yerror("Cannot get current output. This is a bug in i3.");
|
||||
return;
|
||||
}
|
||||
|
||||
Output *target_output = get_output_from_string(current_output, name);
|
||||
if (!target_output) {
|
||||
yerror("Could not get output from string \"%s\"", name);
|
||||
return;
|
||||
}
|
||||
|
||||
bool success = workspace_move_to_output(ws, target_output);
|
||||
if (!success) {
|
||||
yerror("Failed to move workspace to output.");
|
||||
return;
|
||||
}
|
||||
workspace_move_to_output(ws, target_output);
|
||||
}
|
||||
|
||||
cmd_output->needs_tree_render = true;
|
||||
|
|
|
@ -1400,8 +1400,6 @@ void con_move_to_output(Con *con, Output *output, bool fix_coordinates) {
|
|||
*/
|
||||
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);
|
||||
|
|
10
src/output.c
10
src/output.c
|
@ -54,16 +54,8 @@ char *output_primary_name(Output *output) {
|
|||
|
||||
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, true);
|
||||
if (output == NULL) {
|
||||
ELOG("Could not get output from name \"%s\".\n", output_con->name);
|
||||
return NULL;
|
||||
}
|
||||
assert(output != NULL);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
|
@ -961,17 +961,11 @@ Con *workspace_encapsulate(Con *ws) {
|
|||
|
||||
/*
|
||||
* Move the given workspace to the specified output.
|
||||
* This returns true if and only if moving the workspace was successful.
|
||||
*/
|
||||
bool workspace_move_to_output(Con *ws, Output *output) {
|
||||
void workspace_move_to_output(Con *ws, Output *output) {
|
||||
DLOG("Moving workspace %p / %s to output %p / \"%s\".\n", ws, ws->name, output, output_primary_name(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;
|
||||
}
|
||||
|
||||
Con *content = output_get_content(output->con);
|
||||
DLOG("got output %p with content %p\n", output, content);
|
||||
|
||||
|
@ -1039,7 +1033,7 @@ bool workspace_move_to_output(Con *ws, Output *output) {
|
|||
}
|
||||
|
||||
if (!previously_visible_ws) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
/* NB: We cannot simply work with previously_visible_ws since it might have
|
||||
|
@ -1058,6 +1052,4 @@ bool workspace_move_to_output(Con *ws, Output *output) {
|
|||
CALL(previously_visible_ws, on_remove_child);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue