Move width_increment and height_increment from Con to Window.
relates to #665
This commit is contained in:
parent
80ce13e44e
commit
f43a15acde
@ -414,6 +414,10 @@ struct Window {
|
|||||||
* increments (see below). */
|
* increments (see below). */
|
||||||
int base_width;
|
int base_width;
|
||||||
int base_height;
|
int base_height;
|
||||||
|
|
||||||
|
/* minimum increment size specified for the window (in pixels) */
|
||||||
|
int width_increment;
|
||||||
|
int height_increment;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -582,10 +586,6 @@ struct Con {
|
|||||||
int border_width;
|
int border_width;
|
||||||
int current_border_width;
|
int current_border_width;
|
||||||
|
|
||||||
/* minimum increment size specified for the window (in pixels) */
|
|
||||||
int width_increment;
|
|
||||||
int height_increment;
|
|
||||||
|
|
||||||
struct Window *window;
|
struct Window *window;
|
||||||
|
|
||||||
/* timer used for disabling urgency */
|
/* timer used for disabling urgency */
|
||||||
|
@ -599,17 +599,20 @@ static void cmd_resize_floating(I3_CMD, char *way, char *direction, Con *floatin
|
|||||||
/* ensure that resize will take place even if pixel increment is smaller than
|
/* ensure that resize will take place even if pixel increment is smaller than
|
||||||
* height increment or width increment.
|
* height increment or width increment.
|
||||||
* fixes #1011 */
|
* fixes #1011 */
|
||||||
if (strcmp(direction, "up") == 0 || strcmp(direction, "down") == 0 ||
|
const i3Window *window = focused_con->window;
|
||||||
strcmp(direction, "height") == 0) {
|
if (window != NULL) {
|
||||||
if (px < 0)
|
if (strcmp(direction, "up") == 0 || strcmp(direction, "down") == 0 ||
|
||||||
px = (-px < focused_con->height_increment) ? -focused_con->height_increment : px;
|
strcmp(direction, "height") == 0) {
|
||||||
else
|
if (px < 0)
|
||||||
px = (px < focused_con->height_increment) ? focused_con->height_increment : px;
|
px = (-px < window->height_increment) ? -window->height_increment : px;
|
||||||
} else if (strcmp(direction, "left") == 0 || strcmp(direction, "right") == 0) {
|
else
|
||||||
if (px < 0)
|
px = (px < window->height_increment) ? window->height_increment : px;
|
||||||
px = (-px < focused_con->width_increment) ? -focused_con->width_increment : px;
|
} else if (strcmp(direction, "left") == 0 || strcmp(direction, "right") == 0) {
|
||||||
else
|
if (px < 0)
|
||||||
px = (px < focused_con->width_increment) ? focused_con->width_increment : px;
|
px = (-px < window->width_increment) ? -window->width_increment : px;
|
||||||
|
else
|
||||||
|
px = (px < window->width_increment) ? window->width_increment : px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(direction, "up") == 0) {
|
if (strcmp(direction, "up") == 0) {
|
||||||
|
@ -42,7 +42,7 @@ void floating_check_size(Con *floating_con) {
|
|||||||
Con *focused_con = con_descend_focused(floating_con);
|
Con *focused_con = con_descend_focused(floating_con);
|
||||||
|
|
||||||
/* obey size increments */
|
/* obey size increments */
|
||||||
if (focused_con->height_increment || focused_con->width_increment) {
|
if (focused_con->window != NULL && (focused_con->window->height_increment || focused_con->window->width_increment)) {
|
||||||
Rect border_rect = con_border_style_rect(focused_con);
|
Rect border_rect = con_border_style_rect(focused_con);
|
||||||
|
|
||||||
/* We have to do the opposite calculations that render_con() do
|
/* We have to do the opposite calculations that render_con() do
|
||||||
@ -54,17 +54,17 @@ void floating_check_size(Con *floating_con) {
|
|||||||
if (con_border_style(focused_con) == BS_NORMAL)
|
if (con_border_style(focused_con) == BS_NORMAL)
|
||||||
border_rect.height += render_deco_height();
|
border_rect.height += render_deco_height();
|
||||||
|
|
||||||
if (focused_con->height_increment &&
|
if (focused_con->window->height_increment &&
|
||||||
floating_con->rect.height >= focused_con->window->base_height + border_rect.height) {
|
floating_con->rect.height >= focused_con->window->base_height + border_rect.height) {
|
||||||
floating_con->rect.height -= focused_con->window->base_height + border_rect.height;
|
floating_con->rect.height -= focused_con->window->base_height + border_rect.height;
|
||||||
floating_con->rect.height -= floating_con->rect.height % focused_con->height_increment;
|
floating_con->rect.height -= floating_con->rect.height % focused_con->window->height_increment;
|
||||||
floating_con->rect.height += focused_con->window->base_height + border_rect.height;
|
floating_con->rect.height += focused_con->window->base_height + border_rect.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (focused_con->width_increment &&
|
if (focused_con->window->width_increment &&
|
||||||
floating_con->rect.width >= focused_con->window->base_width + border_rect.width) {
|
floating_con->rect.width >= focused_con->window->base_width + border_rect.width) {
|
||||||
floating_con->rect.width -= focused_con->window->base_width + border_rect.width;
|
floating_con->rect.width -= focused_con->window->base_width + border_rect.width;
|
||||||
floating_con->rect.width -= floating_con->rect.width % focused_con->width_increment;
|
floating_con->rect.width -= floating_con->rect.width % focused_con->window->width_increment;
|
||||||
floating_con->rect.width += focused_con->window->base_width + border_rect.width;
|
floating_con->rect.width += focused_con->window->base_width + border_rect.width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -932,13 +932,13 @@ static bool handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t stat
|
|||||||
bool changed = false;
|
bool changed = false;
|
||||||
if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_RESIZE_INC)) {
|
if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_RESIZE_INC)) {
|
||||||
if (size_hints.width_inc > 0 && size_hints.width_inc < 0xFFFF)
|
if (size_hints.width_inc > 0 && size_hints.width_inc < 0xFFFF)
|
||||||
if (con->width_increment != size_hints.width_inc) {
|
if (con->window->width_increment != size_hints.width_inc) {
|
||||||
con->width_increment = size_hints.width_inc;
|
con->window->width_increment = size_hints.width_inc;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
if (size_hints.height_inc > 0 && size_hints.height_inc < 0xFFFF)
|
if (size_hints.height_inc > 0 && size_hints.height_inc < 0xFFFF)
|
||||||
if (con->height_increment != size_hints.height_inc) {
|
if (con->window->height_increment != size_hints.height_inc) {
|
||||||
con->height_increment = size_hints.height_inc;
|
con->window->height_increment = size_hints.height_inc;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user