1 ---------------------------------------------------------------------------
2 -- @author Uli Schlachter
3 -- @copyright 2012 Uli Schlachter
4 -- @release @AWESOME_VERSION@
5 ---------------------------------------------------------------------------
7 local setmetatable
= setmetatable
9 local capi
= { awesome
= awesome
}
10 local cairo
= require("lgi").cairo
12 -- This checks for '<= 0.5' because there are git versions after 0.6 which still
13 -- identify themselves as 0.6 but already have the needed cairo support
14 if tonumber(string.match(require('lgi.version'), '(%d%.%d)')) <= 0.5 then
15 error("lgi too old, need at least version 0.6.1")
19 local surface
= { mt
= {} }
21 --- Try to convert the argument into an lgi cairo surface.
22 -- This is usually needed for loading images by file name.
23 function surface
.load(_surface
)
28 -- lgi cairo surfaces don't get changed either
29 if cairo
.Surface
:is_type_of(_surface
) then
32 -- Strings are assumed to be file names and get loaded
33 if type(_surface
) == "string" then
34 _surface
= capi
.awesome
.load_image(_surface
)
36 -- Everything else gets forced into a surface
37 return cairo
.Surface(_surface
, true)
40 function surface
.mt
:__call(...)
41 return surface
.load(...)
44 return setmetatable(surface
, surface
.mt
)
46 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80