Implement special value 'current' for output. (#2483)

This commit introduces the special 'current' value for outputs in both of

* move con to output current
* move workspace to output current

fixes #2357
This commit is contained in:
Ingo Bürk
2016-09-30 17:28:02 +02:00
committed by Michael Stapelberg
parent 6a8fb69eff
commit c71f6f8f7c
7 changed files with 63 additions and 42 deletions

View File

@ -31,18 +31,33 @@ Con *output_get_content(Con *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);
}
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);
return 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;
}