From 9efcf9df877f5bc08b98dc19a406bb9d21b68dba Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 26 Jan 2019 10:50:43 -0500 Subject: [PATCH 1/3] shape.arc: Prevent an angle underflow when rounded edges are enabled. Fixes #2604 --- lib/gears/shape.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/gears/shape.lua b/lib/gears/shape.lua index b89563c6..6c6bf223 100644 --- a/lib/gears/shape.lua +++ b/lib/gears/shape.lua @@ -472,8 +472,11 @@ function module.arc(cr, width, height, thickness, start_angle, end_angle, start_ if end_rounded then arc_length = arc_length - thickness/2 - -- And back to angles - end_angle = start_angle + (arc_length/(radius - thickness/2)) + -- And back to angles. Also make sure to avoid underflowing when the + -- rounded edge radius is greater than the angle delta. + end_angle = start_angle + math.max( + 0, arc_length/(radius - thickness/2) + ) end -- The path is a curcular arc joining 4 points From 090f80d173cd27b33cb7689f6b507e05c728db96 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 26 Jan 2019 10:57:26 -0500 Subject: [PATCH 2/3] arcchart: Place the rounded edge in the right side of the arc. --- lib/wibox/container/arcchart.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/wibox/container/arcchart.lua b/lib/wibox/container/arcchart.lua index 8efe4df2..301ce128 100644 --- a/lib/wibox/container/arcchart.lua +++ b/lib/wibox/container/arcchart.lua @@ -131,7 +131,7 @@ function arcchart:after_draw_children(_, cr, width, height) shape.arc(cr, wa.width-border_width, wa.height-border_width, thickness+border_width, math.pi-end_angle, math.pi-start_angle, - (use_rounded_edges and k == 1), (use_rounded_edges and k == #values) + (use_rounded_edges and k == #values), (use_rounded_edges and k == 1) ) cr:fill() From dbb552097c51a7b961012880525ccb787a09eaac Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 26 Jan 2019 11:03:39 -0500 Subject: [PATCH 3/3] arcchart: Also compute the sum when the limits are provided. The result was used even when it wasn't computed. --- lib/wibox/container/arcchart.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/wibox/container/arcchart.lua b/lib/wibox/container/arcchart.lua index 301ce128..f2754146 100644 --- a/lib/wibox/container/arcchart.lua +++ b/lib/wibox/container/arcchart.lua @@ -104,10 +104,11 @@ function arcchart:after_draw_children(_, cr, width, height) local max_val = self:get_max_value() local sum = 0 + for _, v in ipairs(values) do + sum = sum + v + end + if not max_val then - for _, v in ipairs(values) do - sum = sum + v - end max_val = sum end