Bugfix: Fix duplicate return value for 'resize' command

This commit is contained in:
Michael Stapelberg 2012-07-22 21:25:38 +02:00
parent 167b38b184
commit 83dc5d5cb6
1 changed files with 19 additions and 11 deletions

View File

@ -500,7 +500,7 @@ static void cmd_resize_floating(I3_CMD, char *way, char *direction, Con *floatin
} }
} }
static void cmd_resize_tiling_direction(I3_CMD, char *way, char *direction, int ppt) { static bool cmd_resize_tiling_direction(I3_CMD, char *way, char *direction, int ppt) {
LOG("tiling resize\n"); LOG("tiling resize\n");
/* get the appropriate current container (skip stacked/tabbed cons) */ /* get the appropriate current container (skip stacked/tabbed cons) */
Con *current = focused; Con *current = focused;
@ -533,7 +533,7 @@ static void cmd_resize_tiling_direction(I3_CMD, char *way, char *direction, int
LOG("You cannot resize in that direction. Your focus is in a %s split container currently.\n", LOG("You cannot resize in that direction. Your focus is in a %s split container currently.\n",
(orientation == HORIZ ? "horizontal" : "vertical")); (orientation == HORIZ ? "horizontal" : "vertical"));
ysuccess(false); ysuccess(false);
return; return false;
} }
if (strcmp(direction, "up") == 0 || strcmp(direction, "left") == 0) { if (strcmp(direction, "up") == 0 || strcmp(direction, "left") == 0) {
@ -544,7 +544,7 @@ static void cmd_resize_tiling_direction(I3_CMD, char *way, char *direction, int
if (other == TAILQ_END(workspaces)) { if (other == TAILQ_END(workspaces)) {
LOG("No other container in this direction found, cannot resize.\n"); LOG("No other container in this direction found, cannot resize.\n");
ysuccess(false); ysuccess(false);
return; return false;
} }
LOG("other->percent = %f\n", other->percent); LOG("other->percent = %f\n", other->percent);
LOG("current->percent before = %f\n", current->percent); LOG("current->percent before = %f\n", current->percent);
@ -567,9 +567,11 @@ static void cmd_resize_tiling_direction(I3_CMD, char *way, char *direction, int
} else { } else {
LOG("Not resizing, already at minimum size\n"); LOG("Not resizing, already at minimum size\n");
} }
return true;
} }
static void cmd_resize_tiling_width_height(I3_CMD, char *way, char *direction, int ppt) { static bool cmd_resize_tiling_width_height(I3_CMD, char *way, char *direction, int ppt) {
LOG("width/height resize\n"); LOG("width/height resize\n");
/* get the appropriate current container (skip stacked/tabbed cons) */ /* get the appropriate current container (skip stacked/tabbed cons) */
Con *current = focused; Con *current = focused;
@ -601,13 +603,13 @@ static void cmd_resize_tiling_width_height(I3_CMD, char *way, char *direction, i
LOG("You cannot resize in that direction. Your focus is in a %s split container currently.\n", LOG("You cannot resize in that direction. Your focus is in a %s split container currently.\n",
(orientation == HORIZ ? "horizontal" : "vertical")); (orientation == HORIZ ? "horizontal" : "vertical"));
ysuccess(false); ysuccess(false);
return; return false;
} }
if (children == 1) { if (children == 1) {
LOG("This is the only container, cannot resize.\n"); LOG("This is the only container, cannot resize.\n");
ysuccess(false); ysuccess(false);
return; return false;
} }
/* Ensure all the other children have a percentage set. */ /* Ensure all the other children have a percentage set. */
@ -630,13 +632,13 @@ static void cmd_resize_tiling_width_height(I3_CMD, char *way, char *direction, i
if (!definitelyGreaterThan(child->percent - subtract_percent, 0.05, DBL_EPSILON)) { if (!definitelyGreaterThan(child->percent - subtract_percent, 0.05, DBL_EPSILON)) {
LOG("Not resizing, already at minimum size (child %p would end up with a size of %.f\n", child, child->percent - subtract_percent); LOG("Not resizing, already at minimum size (child %p would end up with a size of %.f\n", child, child->percent - subtract_percent);
ysuccess(false); ysuccess(false);
return; return false;
} }
} }
if (!definitelyGreaterThan(new_current_percent, 0.05, DBL_EPSILON)) { if (!definitelyGreaterThan(new_current_percent, 0.05, DBL_EPSILON)) {
LOG("Not resizing, already at minimum size\n"); LOG("Not resizing, already at minimum size\n");
ysuccess(false); ysuccess(false);
return; return false;
} }
current->percent += ((double)ppt / 100.0); current->percent += ((double)ppt / 100.0);
@ -648,6 +650,8 @@ static void cmd_resize_tiling_width_height(I3_CMD, char *way, char *direction, i
child->percent -= subtract_percent; child->percent -= subtract_percent;
LOG("child->percent after (%p) = %f\n", child, child->percent); LOG("child->percent after (%p) = %f\n", child, child->percent);
} }
return true;
} }
/* /*
@ -670,9 +674,13 @@ void cmd_resize(I3_CMD, char *way, char *direction, char *resize_px, char *resiz
cmd_resize_floating(current_match, cmd_output, way, direction, floating_con, px); cmd_resize_floating(current_match, cmd_output, way, direction, floating_con, px);
} else { } else {
if (strcmp(direction, "width") == 0 || if (strcmp(direction, "width") == 0 ||
strcmp(direction, "height") == 0) strcmp(direction, "height") == 0) {
cmd_resize_tiling_width_height(current_match, cmd_output, way, direction, ppt); if (!cmd_resize_tiling_width_height(current_match, cmd_output, way, direction, ppt))
else cmd_resize_tiling_direction(current_match, cmd_output, way, direction, ppt); return;
} else {
if (!cmd_resize_tiling_direction(current_match, cmd_output, way, direction, ppt))
return;
}
} }
cmd_output->needs_tree_render = true; cmd_output->needs_tree_render = true;