From 031ebc6d98d6bc8c62bae0a417963b10a536001f Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 11 Mar 2009 19:04:12 +0100 Subject: [PATCH] naughty: add support for hints.icon_data Signed-off-by: Julien Danjou --- lib/naughty.lua.in | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/naughty.lua.in b/lib/naughty.lua.in index 4d179f05..d84f3058 100644 --- a/lib/naughty.lua.in +++ b/lib/naughty.lua.in @@ -429,6 +429,26 @@ if awful.hooks.dbus then args.preset.callback(data, appname, replaces_id, icon, title, text, actions, hints, expire)) then if icon ~= "" then args.icon = icon + elseif hints.icon_data then + -- icon_data is an array: + -- 1 -> width, 2 -> height, 3 -> rowstride, 4 -> has alpha + -- 5 -> bits per sample, 6 -> channels, 7 -> data + + local imgdata + -- If has alpha (ARGB32) + if hints.icon_data[6] == 4 then + imgdata = hints.icon_data[7] + -- If has not alpha (RGB24) + elseif hints.icon_data[6] == 3 then + imgdata = "" + 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 + end + end + if imgdata then + args.icon = image.argb32(hints.icon_data[1], hints.icon_data[2], imgdata) + end end if replaces_id and replaces_id ~= "" and replaces_id ~= 0 then args.replaces_id = replaces_id