Bugfix: Retain absolute window position and size when changing floating borders (Thanks binzter)
Fixes: #561
This commit is contained in:
parent
c36042dfb1
commit
970d11709e
|
@ -233,6 +233,13 @@ Rect con_border_style_rect(Con *con);
|
||||||
*/
|
*/
|
||||||
int con_border_style(Con *con);
|
int con_border_style(Con *con);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the given border style on con, correctly keeping the position/size of a
|
||||||
|
* floating window.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void con_set_border_style(Con *con, int border_style);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function changes the layout of a given container. Use it to handle
|
* This function changes the layout of a given container. Use it to handle
|
||||||
* special cases like changing a whole workspace to stacked/tabbed (creates a
|
* special cases like changing a whole workspace to stacked/tabbed (creates a
|
||||||
|
|
|
@ -719,10 +719,12 @@ border:
|
||||||
|
|
||||||
TAILQ_FOREACH(current, &owindows, owindows) {
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
printf("matching: %p / %s\n", current->con, current->con->name);
|
printf("matching: %p / %s\n", current->con, current->con->name);
|
||||||
|
int border_style = current->con->border_style;
|
||||||
if ($2 == TOK_TOGGLE) {
|
if ($2 == TOK_TOGGLE) {
|
||||||
current->con->border_style++;
|
border_style++;
|
||||||
current->con->border_style %= 3;
|
border_style %= 3;
|
||||||
} else current->con->border_style = $2;
|
} else border_style = $2;
|
||||||
|
con_set_border_style(current->con, border_style);
|
||||||
}
|
}
|
||||||
|
|
||||||
tree_render();
|
tree_render();
|
||||||
|
|
46
src/con.c
46
src/con.c
|
@ -941,6 +941,52 @@ int con_border_style(Con *con) {
|
||||||
return con->border_style;
|
return con->border_style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets the given border style on con, correctly keeping the position/size of a
|
||||||
|
* floating window.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void con_set_border_style(Con *con, int border_style) {
|
||||||
|
/* Handle the simple case: non-floating containerns */
|
||||||
|
if (!con_is_floating(con)) {
|
||||||
|
con->border_style = border_style;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* For floating containers, we want to keep the position/size of the
|
||||||
|
* *window* itself. Since the window size is rendered based on the
|
||||||
|
* container which it is in, we first remove the border/decoration specific
|
||||||
|
* amount of pixels from parent->rect, change the border, then add the new
|
||||||
|
* border/decoration specific pixels. */
|
||||||
|
DLOG("This is a floating container\n");
|
||||||
|
|
||||||
|
/* Get current border/decoration pixel values. */
|
||||||
|
int deco_height =
|
||||||
|
(con->border_style == BS_NORMAL ? config.font.height + 5 : 0);
|
||||||
|
Rect bsr = con_border_style_rect(con);
|
||||||
|
Con *parent = con->parent;
|
||||||
|
|
||||||
|
con->rect.x += bsr.x;
|
||||||
|
con->rect.y += bsr.y;
|
||||||
|
con->rect.width += bsr.width;
|
||||||
|
con->rect.height += bsr.height;
|
||||||
|
|
||||||
|
/* Change the border style, get new border/decoration values. */
|
||||||
|
con->border_style = border_style;
|
||||||
|
bsr = con_border_style_rect(con);
|
||||||
|
deco_height = (con->border_style == BS_NORMAL ? config.font.height + 5 : 0);
|
||||||
|
|
||||||
|
con->rect.x -= bsr.x;
|
||||||
|
con->rect.y -= bsr.y;
|
||||||
|
con->rect.width -= bsr.width;
|
||||||
|
con->rect.height -= bsr.height;
|
||||||
|
|
||||||
|
parent->rect.x = con->rect.x;
|
||||||
|
parent->rect.y = con->rect.y - deco_height;
|
||||||
|
parent->rect.width = con->rect.width;
|
||||||
|
parent->rect.height = con->rect.height + deco_height;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function changes the layout of a given container. Use it to handle
|
* This function changes the layout of a given container. Use it to handle
|
||||||
* special cases like changing a whole workspace to stacked/tabbed (creates a
|
* special cases like changing a whole workspace to stacked/tabbed (creates a
|
||||||
|
|
Loading…
Reference in New Issue