awful: strip alpha channel in pango colors

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-09-18 17:07:04 +02:00
parent 57a537e168
commit bc9196084a
1 changed files with 15 additions and 5 deletions

View File

@ -71,6 +71,16 @@ client.urgent = {}
client.urgent.stack = {}
client.urgent.stack.data = {}
--- Strip alpha part of color.
-- @param color The color.
-- @return The color without alpha channel.
local function color_strip_alpha(color)
if color:len() == 9 then
color = color:sub(1, 7)
end
return color
end
--- Make i cycle.
-- @param t A length.
-- @param i An absolute index to fit into #t.
@ -1058,7 +1068,7 @@ local function prompt_text_with_cursor(text, text_color, cursor_color, cursor_po
end
local text_start = escape(text:sub(1, cursor_pos - 1))
local text_end = escape(text:sub(cursor_pos + 1))
return text_start .. "<span background=\"" .. cursor_color .. "\" foreground=\"" .. text_color .. "\">" .. char .. "</span>" .. text_end
return text_start .. "<span background=\"" .. color_strip_alpha(cursor_color) .. "\" foreground=\"" .. color_strip_alpha(text_color) .. "\">" .. char .. "</span>" .. text_end
end
--- Run a prompt in a box.
@ -1328,7 +1338,7 @@ function widget.taglist.label.all(t, args)
end
end
if bg_color and fg_color then
text = "<bg "..background.." color='"..bg_color.."'/> <span color='"..fg_color.."'>"..escape(t.name).."</span> "
text = "<bg "..background.." color='"..bg_color.."'/> <span color='"..color_strip_alpha(fg_color).."'>"..escape(t.name).."</span> "
else
text = " <bg "..background.." />"..escape(t.name).." "
end
@ -1370,7 +1380,7 @@ function widget.taglist.label.noempty(t, args)
end
end
if fg_color and bg_color then
text = "<bg color='" .. bg_color .. "'/> <span color='" .. fg_color .. "'>" .. escape(t.name) .. "</span> "
text = "<bg color='" .. bg_color .. "'/> <span color='" .. color_strip_alpha(fg_color) .. "'>" .. escape(t.name) .. "</span> "
else
text = " " .. escape(t.name) .. " "
end
@ -1396,12 +1406,12 @@ local function widget_tasklist_label_common(c, args)
end
if capi.client.focus == c then
if bg_focus and fg_focus then
text = text .. " <bg color='"..bg_focus.."'/><span color='"..fg_focus.."'>"..name.."</span> "
text = text .. " <bg color='"..bg_focus.."'/><span color='"..color_strip_alpha(fg_focus).."'>"..name.."</span> "
else
text = text .. " "..name.." "
end
elseif c.urgent and bg_urgent and fg_urgent then
text = text .. " <bg color='"..bg_urgent.."'/><span color='"..fg_urgent.."'>"..name.."</span> "
text = text .. " <bg color='"..bg_urgent.."'/><span color='"..color_strip_alpha(fg_urgent).."'>"..name.."</span> "
else
text = text .. " "..name.." "
end