mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
41bc77d64c
Before commit 1b2826 in lgi, the get_rgba() function on cairo SolidPatterns was specified like this: get_rgba = { ret = cairo.Status, { ti.double, dir = 'out' }, { ti.double, dir = 'out' }, { ti.double, dir = 'out' } }, The above commit fixed this (without saying so) and the code became: get_rgba = { ret = cairo.Status, { ti.double, dir = 'out' }, { ti.double, dir = 'out' }, { ti.double, dir = 'out' }, { ti.double, dir = 'out' } }, The prototype for the corresponding cairo function is: cairo_public cairo_status_t cairo_pattern_get_rgba (cairo_pattern_t *pattern, double *red, double *green, double *blue, double *alpha); As you see, this functions gets four double* as arguments and it will save its result via those pointers. Old versions of lgi call this function with too few arguments and this will cause a segmentation fault when cairo dereferences an invalid pointer. Signed-off-by: Uli Schlachter <psychon@znc.in>
46 lines
1.4 KiB
Lua
46 lines
1.4 KiB
Lua
---------------------------------------------------------------------------
|
|
-- @author Uli Schlachter
|
|
-- @copyright 2012 Uli Schlachter
|
|
-- @release @AWESOME_VERSION@
|
|
---------------------------------------------------------------------------
|
|
|
|
local setmetatable = setmetatable
|
|
local type = type
|
|
local capi = { awesome = awesome }
|
|
local cairo = require("lgi").cairo
|
|
|
|
-- Keep this in sync with build-utils/lgi-check.sh!
|
|
local ver_major, ver_minor = string.match(require('lgi.version'), '(%d)%.(%d)')
|
|
if tonumber(ver_major) <= 0 and tonumber(ver_minor) < 7 then
|
|
error("lgi too old, need at least version 0.7.0")
|
|
end
|
|
|
|
-- gears.surface
|
|
local surface = { mt = {} }
|
|
|
|
--- Try to convert the argument into an lgi cairo surface.
|
|
-- This is usually needed for loading images by file name.
|
|
function surface.load(_surface)
|
|
-- Nil is not changed
|
|
if not _surface then
|
|
return nil
|
|
end
|
|
-- lgi cairo surfaces don't get changed either
|
|
if cairo.Surface:is_type_of(_surface) then
|
|
return _surface
|
|
end
|
|
-- Strings are assumed to be file names and get loaded
|
|
if type(_surface) == "string" then
|
|
_surface = capi.awesome.load_image(_surface)
|
|
end
|
|
-- Everything else gets forced into a surface
|
|
return cairo.Surface(_surface, true)
|
|
end
|
|
|
|
function surface.mt:__call(...)
|
|
return surface.load(...)
|
|
end
|
|
|
|
return setmetatable(surface, surface.mt)
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|