diff --git a/lib/awful/_compat.lua b/lib/awful/_compat.lua index c25714f0..496b090b 100644 --- a/lib/awful/_compat.lua +++ b/lib/awful/_compat.lua @@ -58,6 +58,28 @@ do assert(root.object == root_object) 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 -- 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 diff --git a/lib/gears/wallpaper.lua b/lib/gears/wallpaper.lua index 8b3f796a..b65cdf85 100644 --- a/lib/gears/wallpaper.lua +++ b/lib/gears/wallpaper.lua @@ -121,7 +121,7 @@ function wallpaper.set(pattern) if not cairo.Pattern:is_type_of(pattern) then error("wallpaper.set() called with an invalid argument") end - root.wallpaper(pattern._native) + root.wallpaper(pattern) end --- Set a centered wallpaper.