shims: Add a wallpaper setter.

This commit is contained in:
Emmanuel Lepage Vallee 2021-06-07 01:42:47 -07:00
parent b9971a5acc
commit 8481af90c5
1 changed files with 20 additions and 0 deletions

View File

@ -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)