Merge branch 'fix-resize-too-much' into next
This commit is contained in:
commit
3fa361be2f
@ -14,6 +14,7 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "all.h"
|
||||
|
||||
@ -106,6 +107,14 @@ char *parse_cmd(const char *new) {
|
||||
return json_output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if a is definitely greater than b (using the given epsilon)
|
||||
*
|
||||
*/
|
||||
bool definitelyGreaterThan(float a, float b, float epsilon) {
|
||||
return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%error-verbose
|
||||
@ -807,10 +816,21 @@ resize:
|
||||
focused->percent = percentage;
|
||||
if (other->percent == 0.0)
|
||||
other->percent = percentage;
|
||||
double new_focused_percent = focused->percent + ((double)ppt / 100.0);
|
||||
double new_other_percent = other->percent - ((double)ppt / 100.0);
|
||||
LOG("new_focused_percent = %f\n", new_focused_percent);
|
||||
LOG("new_other_percent = %f\n", new_other_percent);
|
||||
/* Ensure that the new percentages are positive and greater than
|
||||
* 0.05 to have a reasonable minimum size. */
|
||||
if (definitelyGreaterThan(new_focused_percent, 0.05, DBL_EPSILON) &&
|
||||
definitelyGreaterThan(new_other_percent, 0.05, DBL_EPSILON)) {
|
||||
focused->percent += ((double)ppt / 100.0);
|
||||
other->percent -= ((double)ppt / 100.0);
|
||||
LOG("focused->percent after = %f\n", focused->percent);
|
||||
LOG("other->percent after = %f\n", other->percent);
|
||||
} else {
|
||||
LOG("Not resizing, already at minimum size\n");
|
||||
}
|
||||
}
|
||||
|
||||
tree_render();
|
||||
|
Loading…
Reference in New Issue
Block a user