wibox.drawable: Cache the wallpaper
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
c6365fa2f6
commit
91cc8519b5
|
@ -17,6 +17,7 @@ local sort = require("gears.sort")
|
||||||
local surface = require("gears.surface")
|
local surface = require("gears.surface")
|
||||||
|
|
||||||
local drawables = setmetatable({}, { __mode = 'k' })
|
local drawables = setmetatable({}, { __mode = 'k' })
|
||||||
|
local wallpaper = nil
|
||||||
|
|
||||||
local function do_redraw(self)
|
local function do_redraw(self)
|
||||||
local surf = surface(self.drawable.surface)
|
local surf = surface(self.drawable.surface)
|
||||||
|
@ -31,7 +32,9 @@ local function do_redraw(self)
|
||||||
|
|
||||||
if not capi.awesome.composite_manager_running then
|
if not capi.awesome.composite_manager_running then
|
||||||
-- This is pseudo-transparency: We draw the wallpaper in the background
|
-- This is pseudo-transparency: We draw the wallpaper in the background
|
||||||
local wallpaper = surface(capi.root.wallpaper())
|
if not wallpaper then
|
||||||
|
wallpaper = surface(capi.root.wallpaper())
|
||||||
|
end
|
||||||
if wallpaper then
|
if wallpaper then
|
||||||
cr.operator = cairo.Operator.SOURCE
|
cr.operator = cairo.Operator.SOURCE
|
||||||
cr:set_source_surface(wallpaper, -x, -y)
|
cr:set_source_surface(wallpaper, -x, -y)
|
||||||
|
@ -39,6 +42,7 @@ local function do_redraw(self)
|
||||||
end
|
end
|
||||||
cr.operator = cairo.Operator.OVER
|
cr.operator = cairo.Operator.OVER
|
||||||
else
|
else
|
||||||
|
-- This is true transparency: We draw a translucent background
|
||||||
cr.operator = cairo.Operator.SOURCE
|
cr.operator = cairo.Operator.SOURCE
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -269,6 +273,7 @@ end
|
||||||
-- Redraw all drawables when the wallpaper changes
|
-- Redraw all drawables when the wallpaper changes
|
||||||
capi.awesome.connect_signal("wallpaper_changed", function()
|
capi.awesome.connect_signal("wallpaper_changed", function()
|
||||||
local k
|
local k
|
||||||
|
wallpaper = nil
|
||||||
for k in pairs(drawables) do
|
for k in pairs(drawables) do
|
||||||
k()
|
k()
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue