naughty: Correctly handle rowstride on icons
Thanks to dadrc for reporting that gmusicbrowser's notifications didn't work and for testing this patch. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
c891beffdf
commit
ec714276ec
|
@ -501,24 +501,23 @@ if capi.dbus then
|
|||
-- icon_data is an array:
|
||||
-- 1 -> width, 2 -> height, 3 -> rowstride, 4 -> has alpha
|
||||
-- 5 -> bits per sample, 6 -> channels, 7 -> data
|
||||
local width, height, rowstride = hints.icon_data[1], hints.icon_data[2], hints.icon_data[3]
|
||||
|
||||
local imgdata = ""
|
||||
-- If has alpha (ARGB32)
|
||||
if hints.icon_data[6] == 4 then
|
||||
for i = 1, #hints.icon_data[7], 4 do
|
||||
local bpp = hints.icon_data[6]
|
||||
local offset = 0
|
||||
for y = 1, height do
|
||||
for i = 1 + offset, width * bpp + offset, bpp do
|
||||
imgdata = imgdata .. hints.icon_data[7]:sub(i, i + 2):reverse()
|
||||
imgdata = imgdata .. hints.icon_data[7]:sub(i + 3, i + 3)
|
||||
end
|
||||
-- If has not alpha (RGB24)
|
||||
elseif hints.icon_data[6] == 3 then
|
||||
for i = 1, #hints.icon_data[7], 3 do
|
||||
imgdata = imgdata .. hints.icon_data[7]:sub(i , i + 2):reverse()
|
||||
imgdata = imgdata .. string.format("%c", 255) -- alpha is 255
|
||||
if bpp == 4 then
|
||||
imgdata = imgdata .. hints.icon_data[7]:sub(i + 3, i + 3)
|
||||
else
|
||||
imgdata = imgdata .. string.format("%c", 255)
|
||||
end
|
||||
end
|
||||
offset = offset + rowstride
|
||||
end
|
||||
if imgdata then
|
||||
args.icon = capi.image.argb32(hints.icon_data[1], hints.icon_data[2], imgdata)
|
||||
end
|
||||
args.icon = capi.image.argb32(width, height, imgdata)
|
||||
end
|
||||
if replaces_id and replaces_id ~= "" and replaces_id ~= 0 then
|
||||
args.replaces_id = replaces_id
|
||||
|
|
Loading…
Reference in New Issue