From 2eb085c263f097f21aecad041c140a288f77530b Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Mon, 21 Mar 2016 03:25:17 -0400 Subject: [PATCH] wibox.background: Add shape clip support --- lib/wibox/widget/background.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/wibox/widget/background.lua b/lib/wibox/widget/background.lua index 7d547124..db5a42f7 100644 --- a/lib/wibox/widget/background.lua +++ b/lib/wibox/widget/background.lua @@ -72,6 +72,12 @@ function background:before_draw_children(_, cr) if self.foreground then cr:set_source(self.foreground) end + + -- Clip the shape + if self._path and self._shape_clip then + cr:append_path(self._path) + cr:clip() + end end --- Layout this widget @@ -155,6 +161,13 @@ function background:set_shape_border_color(fg) self:emit_signal("widget::redraw_needed") end +--- When a `shape` is set, make sure nothing is drawn outside of it. +-- @tparam boolean value If the shape clip is enable +function background:set_shape_clip(value) + self._shape_clip = value + self:emit_signal("widget::redraw_needed") +end + --- Set the background image to use -- If `image` is a function, it will be called with `(context, cr, width, height)` -- as arguments. Any other arguments passed to this method will be appended.