Wibox: Set the drawin's background color if possible

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2010-12-12 21:18:32 +01:00
parent 1076a6ea47
commit 07bbe14d02
1 changed files with 10 additions and 0 deletions

View File

@ -20,6 +20,7 @@ local color = require("gears.color")
local object = require("gears.object")
local sort = require("gears.sort")
local beautiful = require("beautiful")
local string_format = string.format
module("wibox")
@ -116,9 +117,18 @@ end
-- nil or a string that gears.color() understands.
function set_bg(wibox, c)
local c = c
local colstr = "#000000" -- Default if we can't figure out the color
if type(c) == "string" then
c = color(c)
end
-- If this is a solid color, propagate the background color to the capi drawin
if c:get_type() == "solid" then
local r, g, b, a = c:get_rgba()
r, g, b, a = r * 255, g * 255, b * 255, a * 255
-- Alpha isn't supported for backgrounds
colstr = string_format("#%02x%02x%02x", r, g, b)
end
wibox.drawin.bg_color = colstr
wibox.background_color = c
wibox.draw()
end