shims: Add a wallpaper setter.
This commit is contained in:
parent
b9971a5acc
commit
8481af90c5
|
@ -1,6 +1,8 @@
|
|||
local root = {_tags={}}
|
||||
|
||||
local gtable = require("gears.table")
|
||||
local cairo = require( "lgi" ).cairo
|
||||
|
||||
|
||||
function root:tags()
|
||||
return root._tags
|
||||
|
@ -169,6 +171,24 @@ function root._write_string(string, c)
|
|||
end
|
||||
end
|
||||
|
||||
function root._wallpaper(pattern)
|
||||
if not pattern then return root._wallpaper_surface end
|
||||
|
||||
-- Make a copy because `:finish()` is called by `root.wallpaper` to avoid
|
||||
-- a memory leak in the "real" backend.
|
||||
local target = cairo.ImageSurface(cairo.Format.RGB32, root.size())
|
||||
local cr = cairo.Context(target)
|
||||
|
||||
cr:set_source(pattern)
|
||||
cr:rectangle(0, 0, root.size())
|
||||
cr:fill()
|
||||
|
||||
root._wallpaper_pattern = cairo.Pattern.create_for_surface(target)
|
||||
root._wallpaper_surface = target
|
||||
|
||||
return target
|
||||
end
|
||||
|
||||
|
||||
function root.set_newindex_miss_handler(h)
|
||||
rawset(root, "_ni_handler", h)
|
||||
|
|
Loading…
Reference in New Issue