Merge branch 'fix-resize-too-much'
This commit is contained in:
commit
fefbc3d384
|
@ -14,6 +14,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <float.h>
|
||||||
|
|
||||||
#include "all.h"
|
#include "all.h"
|
||||||
|
|
||||||
|
@ -106,6 +107,14 @@ char *parse_cmd(const char *new) {
|
||||||
return json_output;
|
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
|
%error-verbose
|
||||||
|
@ -807,10 +816,21 @@ resize:
|
||||||
focused->percent = percentage;
|
focused->percent = percentage;
|
||||||
if (other->percent == 0.0)
|
if (other->percent == 0.0)
|
||||||
other->percent = percentage;
|
other->percent = percentage;
|
||||||
focused->percent += ((double)ppt / 100.0);
|
double new_focused_percent = focused->percent + ((double)ppt / 100.0);
|
||||||
other->percent -= ((double)ppt / 100.0);
|
double new_other_percent = other->percent - ((double)ppt / 100.0);
|
||||||
LOG("focused->percent after = %f\n", focused->percent);
|
LOG("new_focused_percent = %f\n", new_focused_percent);
|
||||||
LOG("other->percent after = %f\n", other->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();
|
tree_render();
|
||||||
|
|
Loading…
Reference in New Issue