client: stop duplicating size hints data
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
f6917a2288
commit
9d175377b8
|
@ -370,7 +370,7 @@ awful.hooks.manage.register(function (c)
|
||||||
-- awful.client.setslave(c)
|
-- awful.client.setslave(c)
|
||||||
|
|
||||||
-- Honor size hints: if you want to drop the gaps between windows, set this to false.
|
-- Honor size hints: if you want to drop the gaps between windows, set this to false.
|
||||||
-- c.honorsizehints = false
|
-- c.size_hints_honor = false
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Hook function to execute when arranging the screen.
|
-- Hook function to execute when arranging the screen.
|
||||||
|
|
103
client.c
103
client.c
|
@ -482,7 +482,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen,
|
||||||
c->icon = image_ref(&icon);
|
c->icon = image_ref(&icon);
|
||||||
|
|
||||||
/* we honor size hints by default */
|
/* we honor size hints by default */
|
||||||
c->honorsizehints = true;
|
c->size_hints_honor = true;
|
||||||
|
|
||||||
/* update hints */
|
/* update hints */
|
||||||
property_update_wm_normal_hints(c, NULL);
|
property_update_wm_normal_hints(c, NULL);
|
||||||
|
@ -598,46 +598,85 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen,
|
||||||
area_t
|
area_t
|
||||||
client_geometry_hints(client_t *c, area_t geometry)
|
client_geometry_hints(client_t *c, area_t geometry)
|
||||||
{
|
{
|
||||||
double dx, dy, max, min, ratio;
|
int32_t basew, baseh, minw, minh;
|
||||||
|
|
||||||
if(c->minay > 0 && c->maxay > 0 && (geometry.height - c->baseh) > 0
|
/* base size is substituted with min size if not specified */
|
||||||
&& (geometry.width - c->basew) > 0)
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
|
||||||
{
|
{
|
||||||
dx = (double) (geometry.width - c->basew);
|
basew = c->size_hints.base_width;
|
||||||
dy = (double) (geometry.height - c->baseh);
|
baseh = c->size_hints.base_height;
|
||||||
min = (double) (c->minax) / (double) (c->minay);
|
}
|
||||||
max = (double) (c->maxax) / (double) (c->maxay);
|
else if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
|
||||||
ratio = dx / dy;
|
{
|
||||||
|
basew = c->size_hints.min_width;
|
||||||
|
baseh = c->size_hints.min_height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
basew = baseh = 0;
|
||||||
|
|
||||||
|
/* min size is substituted with base size if not specified */
|
||||||
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE)
|
||||||
|
{
|
||||||
|
minw = c->size_hints.min_width;
|
||||||
|
minh = c->size_hints.min_height;
|
||||||
|
}
|
||||||
|
else if(c->size_hints.flags & XCB_SIZE_HINT_P_SIZE)
|
||||||
|
{
|
||||||
|
minw = c->size_hints.base_width;
|
||||||
|
minh = c->size_hints.base_height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
minw = minh = 0;
|
||||||
|
|
||||||
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_ASPECT
|
||||||
|
&& c->size_hints.min_aspect_num > 0
|
||||||
|
&& c->size_hints.min_aspect_den > 0
|
||||||
|
&& geometry.height - baseh > 0
|
||||||
|
&& geometry.width - basew > 0)
|
||||||
|
{
|
||||||
|
double dx = (double) (geometry.width - basew);
|
||||||
|
double dy = (double) (geometry.height - baseh);
|
||||||
|
double min = (double) c->size_hints.min_aspect_num / (double) c->size_hints.min_aspect_den;
|
||||||
|
double max = (double) c->size_hints.max_aspect_num / (double) c->size_hints.min_aspect_den;
|
||||||
|
double ratio = dx / dy;
|
||||||
if(max > 0 && min > 0 && ratio > 0)
|
if(max > 0 && min > 0 && ratio > 0)
|
||||||
{
|
{
|
||||||
if(ratio < min)
|
if(ratio < min)
|
||||||
{
|
{
|
||||||
dy = (dx * min + dy) / (min * min + 1);
|
dy = (dx * min + dy) / (min * min + 1);
|
||||||
dx = dy * min;
|
dx = dy * min;
|
||||||
geometry.width = (int) dx + c->basew;
|
geometry.width = (int) dx + basew;
|
||||||
geometry.height = (int) dy + c->baseh;
|
geometry.height = (int) dy + baseh;
|
||||||
}
|
}
|
||||||
else if(ratio > max)
|
else if(ratio > max)
|
||||||
{
|
{
|
||||||
dy = (dx * min + dy) / (max * max + 1);
|
dy = (dx * min + dy) / (max * max + 1);
|
||||||
dx = dy * min;
|
dx = dy * min;
|
||||||
geometry.width = (int) dx + c->basew;
|
geometry.width = (int) dx + basew;
|
||||||
geometry.height = (int) dy + c->baseh;
|
geometry.height = (int) dy + baseh;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(c->minw && geometry.width < c->minw)
|
|
||||||
geometry.width = c->minw;
|
if(minw)
|
||||||
if(c->minh && geometry.height < c->minh)
|
geometry.width = MAX(geometry.width, minw);
|
||||||
geometry.height = c->minh;
|
if(minh)
|
||||||
if(c->maxw && geometry.width > c->maxw)
|
geometry.height = MAX(geometry.height, minh);
|
||||||
geometry.width = c->maxw;
|
|
||||||
if(c->maxh && geometry.height > c->maxh)
|
if(c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE)
|
||||||
geometry.height = c->maxh;
|
{
|
||||||
if(c->incw)
|
if(c->size_hints.max_width)
|
||||||
geometry.width -= (geometry.width - c->basew) % c->incw;
|
geometry.width = MIN(geometry.width, c->size_hints.max_width);
|
||||||
if(c->inch)
|
if(c->size_hints.max_height)
|
||||||
geometry.height -= (geometry.height - c->baseh) % c->inch;
|
geometry.height = MIN(geometry.height, c->size_hints.max_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(c->size_hints.flags & (XCB_SIZE_HINT_P_RESIZE_INC | XCB_SIZE_HINT_BASE_SIZE)
|
||||||
|
&& c->size_hints.width_inc && c->size_hints.height_inc)
|
||||||
|
{
|
||||||
|
geometry.width -= (geometry.width - basew) % c->size_hints.width_inc;
|
||||||
|
geometry.height -= (geometry.height - baseh) % c->size_hints.height_inc;
|
||||||
|
}
|
||||||
|
|
||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
@ -823,7 +862,7 @@ client_setmaxhoriz(client_t *c, bool s)
|
||||||
geometry.width = c->geometries.max.width;
|
geometry.width = c->geometries.max.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
client_resize(c, geometry, c->honorsizehints);
|
client_resize(c, geometry, c->size_hints_honor);
|
||||||
client_need_arrange(c);
|
client_need_arrange(c);
|
||||||
client_stack();
|
client_stack();
|
||||||
ewmh_client_update_hints(c);
|
ewmh_client_update_hints(c);
|
||||||
|
@ -867,7 +906,7 @@ client_setmaxvert(client_t *c, bool s)
|
||||||
geometry.height = c->geometries.max.height;
|
geometry.height = c->geometries.max.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
client_resize(c, geometry, c->honorsizehints);
|
client_resize(c, geometry, c->size_hints_honor);
|
||||||
client_need_arrange(c);
|
client_need_arrange(c);
|
||||||
client_stack();
|
client_stack();
|
||||||
ewmh_client_update_hints(c);
|
ewmh_client_update_hints(c);
|
||||||
|
@ -1339,7 +1378,7 @@ luaA_client_handlegeom(lua_State *L, bool full)
|
||||||
(*c)->border,
|
(*c)->border,
|
||||||
geometry);
|
geometry);
|
||||||
|
|
||||||
client_resize(*c, geometry, (*c)->honorsizehints);
|
client_resize(*c, geometry, (*c)->size_hints_honor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(full)
|
if(full)
|
||||||
|
@ -1450,7 +1489,7 @@ luaA_client_newindex(lua_State *L)
|
||||||
client_setsticky(*c, luaA_checkboolean(L, 3));
|
client_setsticky(*c, luaA_checkboolean(L, 3));
|
||||||
break;
|
break;
|
||||||
case A_TK_HONORSIZEHINTS:
|
case A_TK_HONORSIZEHINTS:
|
||||||
(*c)->honorsizehints = luaA_checkboolean(L, 3);
|
(*c)->size_hints_honor = luaA_checkboolean(L, 3);
|
||||||
client_need_arrange(*c);
|
client_need_arrange(*c);
|
||||||
break;
|
break;
|
||||||
case A_TK_BORDER_WIDTH:
|
case A_TK_BORDER_WIDTH:
|
||||||
|
@ -1500,7 +1539,7 @@ luaA_client_newindex(lua_State *L)
|
||||||
* \lfield minimize Define it the client must be iconify, i.e. only visible in
|
* \lfield minimize Define it the client must be iconify, i.e. only visible in
|
||||||
* taskbar.
|
* taskbar.
|
||||||
* \lfield icon_path Path to the icon used to identify.
|
* \lfield icon_path Path to the icon used to identify.
|
||||||
* \lfield honorsizehints Honor size hints, i.e. respect size ratio.
|
* \lfield size_hints_honor Honor size hints, i.e. respect size ratio.
|
||||||
* \lfield border_width The client border width.
|
* \lfield border_width The client border width.
|
||||||
* \lfield border_color The client border color.
|
* \lfield border_color The client border color.
|
||||||
* \lfield titlebar The client titlebar.
|
* \lfield titlebar The client titlebar.
|
||||||
|
@ -1671,7 +1710,9 @@ luaA_client_index(lua_State *L)
|
||||||
lua_pushboolean(L, (*c)->issticky);
|
lua_pushboolean(L, (*c)->issticky);
|
||||||
break;
|
break;
|
||||||
case A_TK_HONORSIZEHINTS:
|
case A_TK_HONORSIZEHINTS:
|
||||||
lua_pushboolean(L, (*c)->honorsizehints);
|
luaA_deprecate(L, "size_hints_honor");
|
||||||
|
case A_TK_SIZE_HINTS_HONOR:
|
||||||
|
lua_pushboolean(L, (*c)->size_hints_honor);
|
||||||
break;
|
break;
|
||||||
case A_TK_BORDER_WIDTH:
|
case A_TK_BORDER_WIDTH:
|
||||||
lua_pushnumber(L, (*c)->border);
|
lua_pushnumber(L, (*c)->border);
|
||||||
|
|
6
client.h
6
client.h
|
@ -122,8 +122,10 @@ client_lower(client_t *c)
|
||||||
static inline bool
|
static inline bool
|
||||||
client_isfixed(client_t *c)
|
client_isfixed(client_t *c)
|
||||||
{
|
{
|
||||||
return (c->maxw && c->minw && c->maxh && c->minh
|
return (c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE
|
||||||
&& c->maxw == c->minw && c->maxh == c->minh);
|
&& c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE
|
||||||
|
&& c->size_hints.max_width == c->size_hints.min_width
|
||||||
|
&& c->size_hints.max_height == c->size_hints.min_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if a client is tagged
|
/** Returns true if a client is tagged
|
||||||
|
|
|
@ -76,6 +76,7 @@ screen
|
||||||
selected
|
selected
|
||||||
Shift
|
Shift
|
||||||
size_hints
|
size_hints
|
||||||
|
size_hints_honor
|
||||||
skip_taskbar
|
skip_taskbar
|
||||||
south
|
south
|
||||||
start
|
start
|
||||||
|
|
52
property.c
52
property.c
|
@ -132,58 +132,6 @@ property_update_wm_normal_hints(client_t *c, xcb_get_property_reply_t *reply)
|
||||||
&c->size_hints, NULL))
|
&c->size_hints, NULL))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((c->size_hints.flags & XCB_SIZE_HINT_P_SIZE))
|
|
||||||
{
|
|
||||||
c->basew = c->size_hints.base_width;
|
|
||||||
c->baseh = c->size_hints.base_height;
|
|
||||||
}
|
|
||||||
else if((c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE))
|
|
||||||
{
|
|
||||||
c->basew = c->size_hints.min_width;
|
|
||||||
c->baseh = c->size_hints.min_height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
c->basew = c->baseh = 0;
|
|
||||||
|
|
||||||
if((c->size_hints.flags & XCB_SIZE_HINT_P_RESIZE_INC))
|
|
||||||
{
|
|
||||||
c->incw = c->size_hints.width_inc;
|
|
||||||
c->inch = c->size_hints.height_inc;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
c->incw = c->inch = 0;
|
|
||||||
|
|
||||||
if((c->size_hints.flags & XCB_SIZE_HINT_P_MAX_SIZE))
|
|
||||||
{
|
|
||||||
c->maxw = c->size_hints.max_width;
|
|
||||||
c->maxh = c->size_hints.max_height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
c->maxw = c->maxh = 0;
|
|
||||||
|
|
||||||
if((c->size_hints.flags & XCB_SIZE_HINT_P_MIN_SIZE))
|
|
||||||
{
|
|
||||||
c->minw = c->size_hints.min_width;
|
|
||||||
c->minh = c->size_hints.min_height;
|
|
||||||
}
|
|
||||||
else if((c->size_hints.flags & XCB_SIZE_HINT_BASE_SIZE))
|
|
||||||
{
|
|
||||||
c->minw = c->size_hints.base_width;
|
|
||||||
c->minh = c->size_hints.base_height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
c->minw = c->minh = 0;
|
|
||||||
|
|
||||||
if((c->size_hints.flags & XCB_SIZE_HINT_P_ASPECT))
|
|
||||||
{
|
|
||||||
c->minax = c->size_hints.min_aspect_num;
|
|
||||||
c->minay = c->size_hints.min_aspect_den;
|
|
||||||
c->maxax = c->size_hints.max_aspect_num;
|
|
||||||
c->maxay = c->size_hints.max_aspect_den;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
c->minax = c->maxax = c->minay = c->maxay = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -161,13 +161,8 @@ struct client_t
|
||||||
/** Client geometry when (un)-max */
|
/** Client geometry when (un)-max */
|
||||||
area_t max;
|
area_t max;
|
||||||
} geometries;
|
} geometries;
|
||||||
/* Size hints */
|
|
||||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
|
||||||
int minax, maxax, minay, maxay;
|
|
||||||
/** Strut */
|
/** Strut */
|
||||||
strut_t strut;
|
strut_t strut;
|
||||||
/** Respect resize hints */
|
|
||||||
bool honorsizehints;
|
|
||||||
/** Border width and pre-fullscreen border width */
|
/** Border width and pre-fullscreen border width */
|
||||||
int border, border_fs;
|
int border, border_fs;
|
||||||
xcolor_t border_color;
|
xcolor_t border_color;
|
||||||
|
@ -223,6 +218,7 @@ struct client_t
|
||||||
image_t *icon;
|
image_t *icon;
|
||||||
/** Size hints */
|
/** Size hints */
|
||||||
xcb_size_hints_t size_hints;
|
xcb_size_hints_t size_hints;
|
||||||
|
bool size_hints_honor;
|
||||||
/** Window it is transient for */
|
/** Window it is transient for */
|
||||||
client_t *transient_for;
|
client_t *transient_for;
|
||||||
/** Next and previous clients */
|
/** Next and previous clients */
|
||||||
|
|
Loading…
Reference in New Issue