From 30860eba8786b82269859e635a11995d283bd4e4 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 1 Nov 2012 13:52:59 +0100 Subject: [PATCH] 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 --- lib/awful/icccm.lua.in | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/awful/icccm.lua.in b/lib/awful/icccm.lua.in index 3035413e..98a5edac 100644 --- a/lib/awful/icccm.lua.in +++ b/lib/awful/icccm.lua.in @@ -13,6 +13,21 @@ local math = math -- Make sure we don't get into an endless loop 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) if size_hints_lock 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 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 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) end - c:geometry(geom) + c:geometry({ width = geom.width + titlebar.width, height = geom.height + titlebar.height }) size_hints_lock = false end