wibox: Add pseudo-transparency support
If you now set a wibox' background to e.g. "#00000080", the wibox will do fake transparency and draw the wallpaper as its background. This should cover 90% of uses of wibox transparency. For the remaining 10% I'll wait for bug reports. :-) Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
2bd29f2ab4
commit
5c7a3501d0
|
@ -10,6 +10,7 @@ require("wibox.widget")
|
||||||
local capi = {
|
local capi = {
|
||||||
drawin = drawin,
|
drawin = drawin,
|
||||||
oocairo = oocairo,
|
oocairo = oocairo,
|
||||||
|
root = root,
|
||||||
awesome = awesome
|
awesome = awesome
|
||||||
}
|
}
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
|
@ -34,9 +35,17 @@ local function do_redraw(wibox)
|
||||||
local geom = wibox.drawin:geometry()
|
local geom = wibox.drawin:geometry()
|
||||||
local cr = capi.oocairo.context_create(wibox.drawin.surface)
|
local cr = capi.oocairo.context_create(wibox.drawin.surface)
|
||||||
|
|
||||||
-- Clear the drawin
|
-- Draw the background
|
||||||
cr:save()
|
cr:save()
|
||||||
cr:set_operator("source")
|
-- This is pseudo-transparency: We draw the wallpaper in the background
|
||||||
|
local wallpaper = capi.root.wallpaper()
|
||||||
|
if wallpaper then
|
||||||
|
cr:set_operator("source")
|
||||||
|
cr:set_source(wallpaper, -wibox.drawin.x, -wibox.drawin.y)
|
||||||
|
cr:paint()
|
||||||
|
end
|
||||||
|
|
||||||
|
cr:set_operator("over")
|
||||||
cr:set_source(wibox.background_color)
|
cr:set_source(wibox.background_color)
|
||||||
cr:paint()
|
cr:paint()
|
||||||
cr:restore()
|
cr:restore()
|
||||||
|
@ -234,7 +243,14 @@ local function setup_signals(wibox)
|
||||||
-- Update the wibox when its geometry changes
|
-- Update the wibox when its geometry changes
|
||||||
w:connect_signal("property::height", wibox.draw)
|
w:connect_signal("property::height", wibox.draw)
|
||||||
w:connect_signal("property::width", wibox.draw)
|
w:connect_signal("property::width", wibox.draw)
|
||||||
w:connect_signal("property::visible", wibox.draw)
|
w:connect_signal("property::visible", function()
|
||||||
|
if w.visible then
|
||||||
|
capi.awesome.connect_signal("wallpaper_changed", wibox.draw)
|
||||||
|
wibox.draw()
|
||||||
|
else
|
||||||
|
capi.awesome.disconnect_signal("wallpaper_changed", wibox.draw)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
local function button_signal(name)
|
local function button_signal(name)
|
||||||
w:connect_signal(name, function(w, x, y, ...)
|
w:connect_signal(name, function(w, x, y, ...)
|
||||||
|
|
Loading…
Reference in New Issue