compat: Do not require to pass pattern._native to the wallpaper.
It makes the shims impossible to implement without a double free, a memory leak or a crash. Using `capi` should not require to destroy the LGI wrappers. Another example, not fixed in this commit, are the client shapes.
This commit is contained in:
parent
82f54ab95c
commit
b0a2d82d8f
|
@ -58,6 +58,28 @@ do
|
||||||
assert(root.object == root_object)
|
assert(root.object == root_object)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- The old wallpaper only took native surfaces.
|
||||||
|
--
|
||||||
|
-- This was a problem for the test backend. The new function takes both
|
||||||
|
-- native surfaces and LGI-ified Cairo surfaces.
|
||||||
|
function root.wallpaper(pattern)
|
||||||
|
if not pattern then return root._wallpaper() end
|
||||||
|
|
||||||
|
-- Checking for type will either potentially `error()` or always
|
||||||
|
-- return `userdata`. This check will error() when the surface is
|
||||||
|
-- already native.
|
||||||
|
local err = pcall(function() return pattern._native end)
|
||||||
|
|
||||||
|
-- The presence of `root._write_string` means the test backend is
|
||||||
|
-- used. Avoid passing the native surface.
|
||||||
|
if err and not root._write_string then
|
||||||
|
return root._wallpaper(pattern._native)
|
||||||
|
else
|
||||||
|
return root._wallpaper(pattern)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- root.bottons() used to be a capi function. However this proved confusing
|
-- root.bottons() used to be a capi function. However this proved confusing
|
||||||
-- as rc.lua used `awful.button` and `root.buttons()` used capi.button. There
|
-- as rc.lua used `awful.button` and `root.buttons()` used capi.button. There
|
||||||
-- was a little documented hack to "flatten" awful.button into a pair of
|
-- was a little documented hack to "flatten" awful.button into a pair of
|
||||||
|
|
|
@ -121,7 +121,7 @@ function wallpaper.set(pattern)
|
||||||
if not cairo.Pattern:is_type_of(pattern) then
|
if not cairo.Pattern:is_type_of(pattern) then
|
||||||
error("wallpaper.set() called with an invalid argument")
|
error("wallpaper.set() called with an invalid argument")
|
||||||
end
|
end
|
||||||
root.wallpaper(pattern._native)
|
root.wallpaper(pattern)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set a centered wallpaper.
|
--- Set a centered wallpaper.
|
||||||
|
|
Loading…
Reference in New Issue