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 local ver_major
,ver_minor
= string.match(require('lgi.version'),'(%d)%.(%d)')
15 if ( (tonumber(ver_major
)<=0) and (tonumber(ver_minor
)<=5) ) then
16 error("lgi too old, need at least version 0.6.1")
20 local surface
= { mt
= {} }
22 --- Try to convert the argument into an lgi cairo surface.
23 -- This is usually needed for loading images by file name.
24 function surface
.load(_surface
)
29 -- lgi cairo surfaces don't get changed either
30 if cairo
.Surface
:is_type_of(_surface
) then
33 -- Strings are assumed to be file names and get loaded
34 if type(_surface
) == "string" then
35 _surface
= capi
.awesome
.load_image(_surface
)
37 -- Everything else gets forced into a surface
38 return cairo
.Surface(_surface
, true)
41 function surface
.mt
:__call(...)
42 return surface
.load(...)
45 return setmetatable(surface
, surface
.mt
)
47 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80