tiling resize: remove minimum size (was 5%)

fixes #3071
This commit is contained in:
Johannes Lange 2017-12-26 09:37:22 +01:00
parent 320246ab47
commit 8f30a04425
1 changed files with 9 additions and 20 deletions

View File

@ -78,14 +78,6 @@
} \ } \
} while (0) } while (0)
/*
* Returns true if a is definitely greater than b (using the given epsilon)
*
*/
static bool definitelyGreaterThan(float a, float b, float epsilon) {
return (a - b) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
/* /*
* Checks whether we switched to a new workspace and returns false in that case, * Checks whether we switched to a new workspace and returns false in that case,
* signaling that further workspace switching should be done by the calling function * signaling that further workspace switching should be done by the calling function
@ -525,8 +517,8 @@ static bool cmd_resize_tiling_direction(I3_CMD, Con *current, const char *way, c
LOG("default percentage = %f\n", percentage); LOG("default percentage = %f\n", percentage);
/* resize */ /* resize */
LOG("second->percent = %f\n", second->percent);
LOG("first->percent before = %f\n", first->percent); LOG("first->percent before = %f\n", first->percent);
LOG("second->percent before = %f\n", second->percent);
if (first->percent == 0.0) if (first->percent == 0.0)
first->percent = percentage; first->percent = percentage;
if (second->percent == 0.0) if (second->percent == 0.0)
@ -535,12 +527,10 @@ static bool cmd_resize_tiling_direction(I3_CMD, Con *current, const char *way, c
double new_second_percent = second->percent - ((double)ppt / 100.0); double new_second_percent = second->percent - ((double)ppt / 100.0);
LOG("new_first_percent = %f\n", new_first_percent); LOG("new_first_percent = %f\n", new_first_percent);
LOG("new_second_percent = %f\n", new_second_percent); LOG("new_second_percent = %f\n", new_second_percent);
/* Ensure that the new percentages are positive and greater than /* Ensure that the new percentages are positive. */
* 0.05 to have a reasonable minimum size. */ if (new_first_percent > 0.0 && new_second_percent > 0.0) {
if (definitelyGreaterThan(new_first_percent, 0.05, DBL_EPSILON) && first->percent = new_first_percent;
definitelyGreaterThan(new_second_percent, 0.05, DBL_EPSILON)) { second->percent = new_second_percent;
first->percent += ((double)ppt / 100.0);
second->percent -= ((double)ppt / 100.0);
LOG("first->percent after = %f\n", first->percent); LOG("first->percent after = %f\n", first->percent);
LOG("second->percent after = %f\n", second->percent); LOG("second->percent after = %f\n", second->percent);
} else { } else {
@ -602,24 +592,23 @@ static bool cmd_resize_tiling_width_height(I3_CMD, Con *current, const char *way
double subtract_percent = ((double)ppt / 100.0) / (children - 1); double subtract_percent = ((double)ppt / 100.0) / (children - 1);
LOG("new_current_percent = %f\n", new_current_percent); LOG("new_current_percent = %f\n", new_current_percent);
LOG("subtract_percent = %f\n", subtract_percent); LOG("subtract_percent = %f\n", subtract_percent);
/* Ensure that the new percentages are positive and greater than /* Ensure that the new percentages are positive. */
* 0.05 to have a reasonable minimum size. */
TAILQ_FOREACH(child, &(current->parent->nodes_head), nodes) { TAILQ_FOREACH(child, &(current->parent->nodes_head), nodes) {
if (child == current) if (child == current)
continue; continue;
if (!definitelyGreaterThan(child->percent - subtract_percent, 0.05, DBL_EPSILON)) { if (child->percent - subtract_percent <= 0.0) {
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 false; return false;
} }
} }
if (!definitelyGreaterThan(new_current_percent, 0.05, DBL_EPSILON)) { if (new_current_percent <= 0.0) {
LOG("Not resizing, already at minimum size\n"); LOG("Not resizing, already at minimum size\n");
ysuccess(false); ysuccess(false);
return false; return false;
} }
current->percent += ((double)ppt / 100.0); current->percent = new_current_percent;
LOG("current->percent after = %f\n", current->percent); LOG("current->percent after = %f\n", current->percent);
TAILQ_FOREACH(child, &(current->parent->nodes_head), nodes) { TAILQ_FOREACH(child, &(current->parent->nodes_head), nodes) {