awful.icccm: Handle titlebars
Size hints should be applied to the "real" client geometry. That means the area taken by titlebars should be ignored. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
77fedaeee8
commit
30860eba87
|
@ -13,6 +13,21 @@ local math = math
|
||||||
-- Make sure we don't get into an endless loop
|
-- Make sure we don't get into an endless loop
|
||||||
local size_hints_lock = false
|
local size_hints_lock = false
|
||||||
|
|
||||||
|
local function get_titlebar_size(c)
|
||||||
|
local res, _ = {}
|
||||||
|
_, res.top = c:titlebar_top()
|
||||||
|
_, res.right = c:titlebar_right()
|
||||||
|
_, res.bottom = c:titlebar_bottom()
|
||||||
|
_, res.left = c:titlebar_left()
|
||||||
|
|
||||||
|
res.x = res.left
|
||||||
|
res.y = res.top
|
||||||
|
res.width = res.left + res.right
|
||||||
|
res.height = res.top + res.bottom
|
||||||
|
|
||||||
|
return res
|
||||||
|
end
|
||||||
|
|
||||||
local function apply_size_hints(c)
|
local function apply_size_hints(c)
|
||||||
if size_hints_lock then return end
|
if size_hints_lock then return end
|
||||||
if not c.size_hints_honor then return end
|
if not c.size_hints_honor then return end
|
||||||
|
@ -23,6 +38,11 @@ local function apply_size_hints(c)
|
||||||
|
|
||||||
local geom = c:geometry()
|
local geom = c:geometry()
|
||||||
local hints = c.size_hints
|
local hints = c.size_hints
|
||||||
|
local titlebar = get_titlebar_size(c)
|
||||||
|
|
||||||
|
-- Apply size hints to the client size without titlebars
|
||||||
|
geom.width = geom.width - titlebar.width
|
||||||
|
geom.height = geom.height - titlebar.height
|
||||||
|
|
||||||
local basew, baseh
|
local basew, baseh
|
||||||
local real_basew, real_baseh = 0, 0
|
local real_basew, real_baseh = 0, 0
|
||||||
|
@ -112,7 +132,7 @@ local function apply_size_hints(c)
|
||||||
geom.height = apply_inc(geom.height, hints.height_inc, baseh)
|
geom.height = apply_inc(geom.height, hints.height_inc, baseh)
|
||||||
end
|
end
|
||||||
|
|
||||||
c:geometry(geom)
|
c:geometry({ width = geom.width + titlebar.width, height = geom.height + titlebar.height })
|
||||||
|
|
||||||
size_hints_lock = false
|
size_hints_lock = false
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue