Merge pull request #1880 from Airblader/feature-665
Move data from Con to Window
This commit is contained in:
commit
ee2983c791
@ -409,6 +409,18 @@ struct Window {
|
||||
|
||||
/** Depth of the window */
|
||||
uint16_t depth;
|
||||
|
||||
/* the wanted size of the window, used in combination with size
|
||||
* increments (see below). */
|
||||
int base_width;
|
||||
int base_height;
|
||||
|
||||
/* minimum increment size specified for the window (in pixels) */
|
||||
int width_increment;
|
||||
int height_increment;
|
||||
|
||||
/* aspect ratio from WM_NORMAL_HINTS (MPlayer uses this for example) */
|
||||
double aspect_ratio;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -570,21 +582,10 @@ struct Con {
|
||||
|
||||
double percent;
|
||||
|
||||
/* aspect ratio from WM_NORMAL_HINTS (MPlayer uses this for example) */
|
||||
double aspect_ratio;
|
||||
/* the wanted size of the window, used in combination with size
|
||||
* increments (see below). */
|
||||
int base_width;
|
||||
int base_height;
|
||||
|
||||
/* the x11 border pixel attribute */
|
||||
int border_width;
|
||||
int current_border_width;
|
||||
|
||||
/* minimum increment size specified for the window (in pixels) */
|
||||
int width_increment;
|
||||
int height_increment;
|
||||
|
||||
struct Window *window;
|
||||
|
||||
/* 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
|
||||
* height increment or width increment.
|
||||
* fixes #1011 */
|
||||
if (strcmp(direction, "up") == 0 || strcmp(direction, "down") == 0 ||
|
||||
strcmp(direction, "height") == 0) {
|
||||
if (px < 0)
|
||||
px = (-px < focused_con->height_increment) ? -focused_con->height_increment : px;
|
||||
else
|
||||
px = (px < focused_con->height_increment) ? focused_con->height_increment : px;
|
||||
} else if (strcmp(direction, "left") == 0 || strcmp(direction, "right") == 0) {
|
||||
if (px < 0)
|
||||
px = (-px < focused_con->width_increment) ? -focused_con->width_increment : px;
|
||||
else
|
||||
px = (px < focused_con->width_increment) ? focused_con->width_increment : px;
|
||||
const i3Window *window = focused_con->window;
|
||||
if (window != NULL) {
|
||||
if (strcmp(direction, "up") == 0 || strcmp(direction, "down") == 0 ||
|
||||
strcmp(direction, "height") == 0) {
|
||||
if (px < 0)
|
||||
px = (-px < window->height_increment) ? -window->height_increment : px;
|
||||
else
|
||||
px = (px < window->height_increment) ? window->height_increment : px;
|
||||
} else if (strcmp(direction, "left") == 0 || strcmp(direction, "right") == 0) {
|
||||
if (px < 0)
|
||||
px = (-px < window->width_increment) ? -window->width_increment : px;
|
||||
else
|
||||
px = (px < window->width_increment) ? window->width_increment : px;
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(direction, "up") == 0) {
|
||||
|
@ -39,15 +39,16 @@ Con *con_new_skeleton(Con *parent, i3Window *window) {
|
||||
Con *new = scalloc(1, sizeof(Con));
|
||||
new->on_remove_child = con_on_remove_child;
|
||||
TAILQ_INSERT_TAIL(&all_cons, new, all_cons);
|
||||
new->aspect_ratio = 0.0;
|
||||
new->type = CT_CON;
|
||||
new->window = window;
|
||||
new->border_style = config.default_border;
|
||||
new->current_border_width = -1;
|
||||
if (window)
|
||||
if (window) {
|
||||
new->depth = window->depth;
|
||||
else
|
||||
new->window->aspect_ratio = 0.0;
|
||||
} else {
|
||||
new->depth = XCB_COPY_FROM_PARENT;
|
||||
}
|
||||
DLOG("opening window\n");
|
||||
|
||||
TAILQ_INIT(&(new->floating_head));
|
||||
|
@ -42,7 +42,7 @@ void floating_check_size(Con *floating_con) {
|
||||
Con *focused_con = con_descend_focused(floating_con);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* We have to do the opposite calculations that render_con() do
|
||||
@ -54,18 +54,18 @@ void floating_check_size(Con *floating_con) {
|
||||
if (con_border_style(focused_con) == BS_NORMAL)
|
||||
border_rect.height += render_deco_height();
|
||||
|
||||
if (focused_con->height_increment &&
|
||||
floating_con->rect.height >= focused_con->base_height + border_rect.height) {
|
||||
floating_con->rect.height -= focused_con->base_height + border_rect.height;
|
||||
floating_con->rect.height -= floating_con->rect.height % focused_con->height_increment;
|
||||
floating_con->rect.height += focused_con->base_height + border_rect.height;
|
||||
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 -= floating_con->rect.height % focused_con->window->height_increment;
|
||||
floating_con->rect.height += focused_con->window->base_height + border_rect.height;
|
||||
}
|
||||
|
||||
if (focused_con->width_increment &&
|
||||
floating_con->rect.width >= focused_con->base_width + border_rect.width) {
|
||||
floating_con->rect.width -= focused_con->base_width + border_rect.width;
|
||||
floating_con->rect.width -= floating_con->rect.width % focused_con->width_increment;
|
||||
floating_con->rect.width += focused_con->base_width + border_rect.width;
|
||||
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 -= floating_con->rect.width % focused_con->window->width_increment;
|
||||
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;
|
||||
if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_RESIZE_INC)) {
|
||||
if (size_hints.width_inc > 0 && size_hints.width_inc < 0xFFFF)
|
||||
if (con->width_increment != size_hints.width_inc) {
|
||||
con->width_increment = size_hints.width_inc;
|
||||
if (con->window->width_increment != size_hints.width_inc) {
|
||||
con->window->width_increment = size_hints.width_inc;
|
||||
changed = true;
|
||||
}
|
||||
if (size_hints.height_inc > 0 && size_hints.height_inc < 0xFFFF)
|
||||
if (con->height_increment != size_hints.height_inc) {
|
||||
con->height_increment = size_hints.height_inc;
|
||||
if (con->window->height_increment != size_hints.height_inc) {
|
||||
con->window->height_increment = size_hints.height_inc;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
@ -960,10 +960,10 @@ static bool handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t stat
|
||||
base_height = size_hints.min_height;
|
||||
}
|
||||
|
||||
if (base_width != con->base_width ||
|
||||
base_height != con->base_height) {
|
||||
con->base_width = base_width;
|
||||
con->base_height = base_height;
|
||||
if (base_width != con->window->base_width ||
|
||||
base_height != con->window->base_height) {
|
||||
con->window->base_width = base_width;
|
||||
con->window->base_height = base_height;
|
||||
DLOG("client's base_height changed to %d\n", base_height);
|
||||
DLOG("client's base_width changed to %d\n", base_width);
|
||||
changed = true;
|
||||
@ -999,8 +999,8 @@ static bool handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t stat
|
||||
} else
|
||||
goto render_and_return;
|
||||
|
||||
if (fabs(con->aspect_ratio - aspect_ratio) > DBL_EPSILON) {
|
||||
con->aspect_ratio = aspect_ratio;
|
||||
if (fabs(con->window->aspect_ratio - aspect_ratio) > DBL_EPSILON) {
|
||||
con->window->aspect_ratio = aspect_ratio;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
|
@ -172,14 +172,14 @@ void render_con(Con *con, bool render_fullscreen) {
|
||||
* Ignoring aspect ratio during fullscreen was necessary to fix MPlayer
|
||||
* subtitle rendering, see http://bugs.i3wm.org/594 */
|
||||
if (!render_fullscreen &&
|
||||
con->aspect_ratio > 0.0) {
|
||||
con->window->aspect_ratio > 0.0) {
|
||||
DLOG("aspect_ratio = %f, current width/height are %d/%d\n",
|
||||
con->aspect_ratio, inset->width, inset->height);
|
||||
con->window->aspect_ratio, inset->width, inset->height);
|
||||
double new_height = inset->height + 1;
|
||||
int new_width = inset->width;
|
||||
|
||||
while (new_height > inset->height) {
|
||||
new_height = (1.0 / con->aspect_ratio) * new_width;
|
||||
new_height = (1.0 / con->window->aspect_ratio) * new_width;
|
||||
|
||||
if (new_height > inset->height)
|
||||
new_width--;
|
||||
|
Loading…
Reference in New Issue
Block a user