Make resize set ppt more accurate
See the testcase for the usecase.
This commit is contained in:
parent
51d230ad4c
commit
096cff0aad
|
@ -516,7 +516,7 @@ static bool cmd_resize_tiling_direction(I3_CMD, Con *current, const char *direct
|
||||||
return resize_neighboring_cons(first, second, px, ppt);
|
return resize_neighboring_cons(first, second, px, ppt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool cmd_resize_tiling_width_height(I3_CMD, Con *current, const char *direction, int px, int _ppt) {
|
static bool cmd_resize_tiling_width_height(I3_CMD, Con *current, const char *direction, int px, double 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) */
|
||||||
|
@ -542,10 +542,9 @@ static bool cmd_resize_tiling_width_height(I3_CMD, Con *current, const char *dir
|
||||||
child->percent = percentage;
|
child->percent = percentage;
|
||||||
}
|
}
|
||||||
|
|
||||||
double ppt = (double)_ppt / 100.0;
|
|
||||||
double new_current_percent;
|
double new_current_percent;
|
||||||
double subtract_percent;
|
double subtract_percent;
|
||||||
if (_ppt) {
|
if (ppt != 0.0) {
|
||||||
new_current_percent = current->percent + ppt;
|
new_current_percent = current->percent + ppt;
|
||||||
} else {
|
} else {
|
||||||
new_current_percent = px_resize_to_percent(current, px);
|
new_current_percent = px_resize_to_percent(current, px);
|
||||||
|
@ -611,9 +610,10 @@ void cmd_resize(I3_CMD, const char *way, const char *direction, long resize_px,
|
||||||
} else {
|
} else {
|
||||||
if (strcmp(direction, "width") == 0 ||
|
if (strcmp(direction, "width") == 0 ||
|
||||||
strcmp(direction, "height") == 0) {
|
strcmp(direction, "height") == 0) {
|
||||||
|
const double ppt = (double)resize_ppt / 100.0;
|
||||||
if (!cmd_resize_tiling_width_height(current_match, cmd_output,
|
if (!cmd_resize_tiling_width_height(current_match, cmd_output,
|
||||||
current->con, direction,
|
current->con, direction,
|
||||||
resize_px, resize_ppt))
|
resize_px, ppt))
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (!cmd_resize_tiling_direction(current_match, cmd_output,
|
if (!cmd_resize_tiling_direction(current_match, cmd_output,
|
||||||
|
@ -645,10 +645,10 @@ static bool resize_set_tiling(I3_CMD, Con *target, orientation_t resize_orientat
|
||||||
resize_find_tiling_participants(&target, &dummy, search_direction, true);
|
resize_find_tiling_participants(&target, &dummy, search_direction, true);
|
||||||
|
|
||||||
/* Calculate new size for the target container */
|
/* Calculate new size for the target container */
|
||||||
int ppt = 0;
|
double ppt = 0.0;
|
||||||
int px = 0;
|
int px = 0;
|
||||||
if (is_ppt) {
|
if (is_ppt) {
|
||||||
ppt = target_size - target->percent * 100;
|
ppt = (double)target_size / 100.0 - target->percent;
|
||||||
} else {
|
} else {
|
||||||
px = target_size - (resize_orientation == HORIZ ? target->rect.width : target->rect.height);
|
px = target_size - (resize_orientation == HORIZ ? target->rect.width : target->rect.height);
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,15 @@ cmd 'resize set 155 px 135 px';
|
||||||
cmp_float($nodes->[1]->{nodes}->[1]->{rect}->{width}, 155, 'bottom-right window got 155 px width');
|
cmp_float($nodes->[1]->{nodes}->[1]->{rect}->{width}, 155, 'bottom-right window got 155 px width');
|
||||||
cmp_float($nodes->[1]->{nodes}->[1]->{rect}->{height}, 135, 'bottom-right window got 135 px height');
|
cmp_float($nodes->[1]->{nodes}->[1]->{rect}->{height}, 135, 'bottom-right window got 135 px height');
|
||||||
|
|
||||||
|
# Mix ppt and px
|
||||||
|
cmd 'resize set 75 ppt 200 px';
|
||||||
|
|
||||||
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
|
|
||||||
|
cmp_float($nodes->[0]->{percent}, 0.25, 'left container got 25%');
|
||||||
|
cmp_float($nodes->[1]->{percent}, 0.75, 'right container got 75%');
|
||||||
|
cmp_float($nodes->[1]->{nodes}->[1]->{rect}->{height}, 200, 'bottom-right window got 200 px height');
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# resize from inside a tabbed container
|
# resize from inside a tabbed container
|
||||||
############################################################
|
############################################################
|
||||||
|
|
Loading…
Reference in New Issue