Hello, 
I learned of a weird user habit on IRC, which led me to a problem (so 
it's not as useless as I think :).

This is how some people like to setup their wibox:

  wibox[s] = awful.wibox({ screen = s, position = "some position" })
  -- add widgets

  wibox[s].height = XY
  -- other properties


Now let's suppose that position was set to "bottom" and later height set 
to 14. The user ends up with a wibox that is on the bottom but has a 2px 
gap between the bottom edge of the screen. The user wonders why is this?

Changing the width or height of a (right or bottom positioned)wibox, 
after it was initialized, to a value different than used when it was 
created would leave the wibox in a wrong position. Position was off by 
as many pixels as the difference between the two values - creating a 
gap, or positioning it offscreen.


The attached patch calls call_wibox_position_hook_on_prop_update() 
function to reposition each wibox on width/height property changes.

It could seem wasteful to update position of all wibox (since at the 
moment we don't update sizes of other wibox when one changes visibility 
or size), and we could call set_position() only for that wibox from 
wibox_update_strut() which is already attached to property::width and 
height. But then that function would not longer be the "update_strut" 
function but a wibox_update_strut_and_position() one :)

-- 
Adrian C. (anrxc) | anrxc..sysphere.org | PGP ID: D20A0618
PGP FP: 02A5 628A D8EE 2A93 996E  929F D5CB 31B7 D20A 0618

Attachment: signature.asc
Description: PGP signature

From f6a26b5f3ef485bacfff08ec7cafa158fe451fb4 Mon Sep 17 00:00:00 2001
From: Adrian C. (anrxc) <[email protected]>
Date: Thu, 4 Mar 2010 02:19:53 +0100
Subject: [PATCH] awful.wibox: update position on height/width property change

Changing the width or height of a (right or bottom positioned)wibox,
after it was initialized, to a value different than used when it was
created would leave the wibox in a wrong position. Position was off by
as many pixels as the difference between the old and the new
value. Now every wibox is repositioned to reflect this new setup.

Signed-off-by: Adrian C. (anrxc) <[email protected]>
---
 lib/awful/wibox.lua.in |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/lib/awful/wibox.lua.in b/lib/awful/wibox.lua.in
index 68a0743..cbc86dc 100644
--- a/lib/awful/wibox.lua.in
+++ b/lib/awful/wibox.lua.in
@@ -133,6 +133,8 @@ function attach(wibox, position)
     wibox:add_signal("property::visible", wibox_update_strut)
 
     wibox:add_signal("property::screen", 
call_wibox_position_hook_on_prop_update)
+    wibox:add_signal("property::width", 
call_wibox_position_hook_on_prop_update)
+    wibox:add_signal("property::height", 
call_wibox_position_hook_on_prop_update)
     wibox:add_signal("property::visible", 
call_wibox_position_hook_on_prop_update)
     wibox:add_signal("property::border_width", 
call_wibox_position_hook_on_prop_update)
 end
-- 
1.7.0.1

Reply via email to