wrap when moving things to outputs with direction

This commit is contained in:
Francesco Mazzoli
2013-01-25 00:02:09 +01:00
committed by Michael Stapelberg
parent 3cd4b8c111
commit f13d8ed06f
3 changed files with 60 additions and 37 deletions

View File

@ -55,23 +55,15 @@ static bool definitelyGreaterThan(float a, float b, float epsilon) {
static Output *get_output_from_string(Output *current_output, const char *output_str) {
Output *output;
if (strcasecmp(output_str, "left") == 0) {
output = get_output_next(D_LEFT, current_output, CLOSEST_OUTPUT);
if (!output)
output = get_output_most(D_RIGHT, current_output);
} else if (strcasecmp(output_str, "right") == 0) {
output = get_output_next(D_RIGHT, current_output, CLOSEST_OUTPUT);
if (!output)
output = get_output_most(D_LEFT, current_output);
} else if (strcasecmp(output_str, "up") == 0) {
output = get_output_next(D_UP, current_output, CLOSEST_OUTPUT);
if (!output)
output = get_output_most(D_DOWN, current_output);
} else if (strcasecmp(output_str, "down") == 0) {
output = get_output_next(D_DOWN, current_output, CLOSEST_OUTPUT);
if (!output)
output = get_output_most(D_UP, current_output);
} else output = 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);
return output;
}
@ -1052,13 +1044,13 @@ void cmd_move_con_to_output(I3_CMD, char *name) {
// TODO: clean this up with commands.spec as soon as we switched away from the lex/yacc command parser
if (strcasecmp(name, "up") == 0)
output = get_output_next(D_UP, current_output, CLOSEST_OUTPUT);
output = get_output_next_wrap(D_UP, current_output);
else if (strcasecmp(name, "down") == 0)
output = get_output_next(D_DOWN, current_output, CLOSEST_OUTPUT);
output = get_output_next_wrap(D_DOWN, current_output);
else if (strcasecmp(name, "left") == 0)
output = get_output_next(D_LEFT, current_output, CLOSEST_OUTPUT);
output = get_output_next_wrap(D_LEFT, current_output);
else if (strcasecmp(name, "right") == 0)
output = get_output_next(D_RIGHT, current_output, CLOSEST_OUTPUT);
output = get_output_next_wrap(D_RIGHT, current_output);
else
output = get_output_by_name(name);