-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Hi list,
Evil_Bob complained about some wibox flickering in #awesome and I had to do
something about this. ;)
Wiboxes didn't have a bit gravity and where set to inherit their parent's pixmap
as background. This means that the X server filled the wibox with the wallpaper
after each resize step which was noticable as e.g. titlebar flicker.
By setting the proper background as BackPixel and a NorthWest bit gravity, this
flicker goes away.
Attached are the two patches and my test case (just for the lulz, but it did
work!)
Cheers,
Uli
- --
"Do you know that books smell like nutmeg or some spice from a foreign land?"
-- Faber in Fahrenheit 451
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iQEcBAEBCAAGBQJK9cakAAoJECLkKOvLj8sGUeIH/i/Amw0HMSkWObGHYBprxY1E
+PT4QTmwTUXuc5jXqRjzHQq2g29PfNZ9vt703J/lNNl5tnIQZt7mpm/C1eW6d+SI
cZOw0+ryCxfCORFRh6O2It1LcenVY+s1xlWyHgqsG5ylz6AeP20UjtoQiYyh1IMa
mAMiyS+AUsUBFQ5+l6ErzMtFT9NBdAQA7EaG6GA4wo3M6+AmBzYwtbtOA3OiUAyI
7GhjGmBIsuTbWLoaPlZYqBIH1TG6btRXsHhF7f5xUICquPGOndAIv5rMVZsIK86m
sbcKm8k6UhAFU28fw2z9ObTCnXvjfCnhEXeVBkm5r2bZqLRaP5Ygel8gUGlRg7w=
=r382
-----END PGP SIGNATURE-----
t = widget({type = "textbox"})
w = wibox({fg = "black", bg = "white", border_width = 4, border_color =
"green"})
w:geometry({ x = 50, y = 50, width = 200, height = 50 })
w.visible = false
w.screen = 1
w.widgets = { t }
w.visible = true
t.text = "Hi there"
w.bg = "blue"
max = 10000
state = max
function loop()
if state == 0 then
awesome.quit()
else
local dir
if state < max / 2 then
dir = -1
else
dir = 1
end
local g = w:geometry()
g.width = g.width + dir
w:geometry(g)
state = state - 1
end
end
t = timer({timeout = 0.0000000000001})
t:add_signal("timeout", loop)
t:start()
>From 7f4d8a296152e898489a7c2e18f8c5b95eea02d7 Mon Sep 17 00:00:00 2001
From: Uli Schlachter <[email protected]>
Date: Sat, 7 Nov 2009 20:02:22 +0100
Subject: [PATCH 1/2] wibox: Set a proper back pixel
Currently wiboxes have their background set to "inherit parent pixmap". That
means that each time a wibox is e.g. resized, the X server sets the wibox'
content to the wallpaper and then immediately awesome redraws the wibox with the
proper background. This causes flicker when you e.g. resize clients which have a
titlebar.
With this patch, wiboxes get their proper background color for their "back
pixel" value. Now, instead of showing the wallpaper, the X server will fill the
complete wibox with its background color.
With this patch, the actual widgets will still flicker. Also, if the wibox has a
background image, this image obviously won't be used by the X server and we get
some flicker again. My next patch will address these issues.
Signed-off-by: Uli Schlachter <[email protected]>
---
objects/wibox.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/objects/wibox.c b/objects/wibox.c
index 90db40f..1619593 100644
--- a/objects/wibox.c
+++ b/objects/wibox.c
@@ -193,11 +193,11 @@ wibox_init(wibox_t *w, int phys_screen)
w->geometry.x, w->geometry.y,
w->geometry.width, w->geometry.height,
w->border_width, XCB_COPY_FROM_PARENT, s->root_visual,
- XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL
+ XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL
| XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK,
(const uint32_t [])
{
- XCB_BACK_PIXMAP_PARENT_RELATIVE,
+ w->ctx.bg.pixel,
w->border_color.pixel,
1,
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT
@@ -1004,7 +1004,16 @@ luaA_wibox_set_bg(lua_State *L, wibox_t *wibox)
size_t len;
const char *buf = luaL_checklstring(L, -1, &len);
if(xcolor_init_reply(xcolor_init_unchecked(&wibox->ctx.bg, buf, len)))
+ {
+ uint32_t mask = XCB_CW_BACK_PIXEL;
+ uint32_t values[] = { wibox->ctx.bg.pixel };
+
wibox->need_update = true;
+ xcb_change_window_attributes(globalconf.connection,
+ wibox->window,
+ mask,
+ values);
+ }
luaA_object_emit_signal(L, -3, "property::bg", 0);
return 0;
}
--
1.6.5
>From 5cfdea77135fc38f701df9d67733e2af2cf86d6a Mon Sep 17 00:00:00 2001
From: Uli Schlachter <[email protected]>
Date: Sat, 7 Nov 2009 20:06:46 +0100
Subject: [PATCH 2/2] Set a wibox' bit gravity to NorthWest.
After the last patch, after each resize the X server fills the complete wibox
with its background color which means that the widgets will still flicker. This
patch fixes this by setting the wibox' bit gravity to NorthWest.
This means that if a wibox is enlarged, only the new, larger part will be filled
with the wibox' background color and the rest of the wibox' content will be left
intact. With this patch I couldn't see any flickering anymore.
Signed-off-by: Uli Schlachter <[email protected]>
---
objects/wibox.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/objects/wibox.c b/objects/wibox.c
index 1619593..159c603 100644
--- a/objects/wibox.c
+++ b/objects/wibox.c
@@ -193,12 +193,13 @@ wibox_init(wibox_t *w, int phys_screen)
w->geometry.x, w->geometry.y,
w->geometry.width, w->geometry.height,
w->border_width, XCB_COPY_FROM_PARENT, s->root_visual,
- XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL
+ XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY
| XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK,
(const uint32_t [])
{
w->ctx.bg.pixel,
w->border_color.pixel,
+ XCB_GRAVITY_NORTH_WEST,
1,
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT
| XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_ENTER_WINDOW
--
1.6.5