From 3cbb59b0dcadc9e2894aad6b252e81a1c0c6ed9e Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 16 May 2012 23:03:32 +0200 Subject: [PATCH] FS#996: awful.ewmh: Connect to property::border_width signal For example, I have some lua code which sets the border width based on the number of visible clients. When just a single client is visible, the border width is 0, else it's what the theme says. Previously, this caused visible "glitches" for fullscreen'd and maximized clients. This patch fixes that and updates the client's geometry and border width appropriately. This has a slight chance of going into an endless loop if someone sets a fullscreen'd clients border width from its property::border_width signal. Just don't do that! Thanks to Arvydas Sidorenko for finding this issue. Signed-off-by: Uli Schlachter --- lib/awful/ewmh.lua.in | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/awful/ewmh.lua.in b/lib/awful/ewmh.lua.in index d6edd03d..bb6375ca 100644 --- a/lib/awful/ewmh.lua.in +++ b/lib/awful/ewmh.lua.in @@ -112,9 +112,29 @@ local function screen_change(window) end end +-- Update a client's settings when its border width changes +local function border_change(window) + -- Fix up the geometry in case this window needs to cover the whole screen. + local bw = window.border_width or 0 + local g = screen[window.screen].workarea + if window.maximized_vertical then + window:geometry { height = g.height - 2*bw, y = g.y } + end + if window.maximized_horizontal then + window:geometry { height = g.height - 2*bw, y = g.y } + end + if window.fullscreen then + -- This *will* cause an endless loop if some other property::border_width + -- signal dares to change the border width, too, so don't do that! + window.border_width = 0 + window:geometry(screen[window.screen].geometry) + end +end + client.connect_signal("request::maximized_horizontal", maximized_horizontal) client.connect_signal("request::maximized_vertical", maximized_vertical) client.connect_signal("request::fullscreen", fullscreen) client.connect_signal("property::screen", screen_change) +client.connect_signal("property::border_width", border_change) -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80