[gnome-shell] barLevel: Don't show border radius if the value is 0



commit 5be61bbb6851a291c179320b1fdfad388216ac90
Author: verdre <verdre v0yd nl>
Date:   Sat Feb 2 17:01:29 2019 +0100

    barLevel: Don't show border radius if the value is 0
    
    Work around a known regression from [1] that caused the volume bar in
    the OSD window to never be hidden, even if the volume is set to 0. This
    happened because the border radius of the barLevel is always drawn
    without ensuring that the actual bar is visible.
    
    So simply check if the value to draw is 0, and if it is, don't draw the
    border radius of the bar at all. This will still result in incorrect
    representation of values that have a width smaller than 2*border-radius,
    but at least the bar looks right for a width of 0 now.
    
    [1] https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/2
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/384

 js/ui/barLevel.js | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/js/ui/barLevel.js b/js/ui/barLevel.js
index d8d37369d..c4072e2cf 100644
--- a/js/ui/barLevel.js
+++ b/js/ui/barLevel.js
@@ -121,7 +121,8 @@ var BarLevel = class {
         cr.lineTo(x, (height - barLevelHeight) / 2);
         cr.lineTo(x, (height + barLevelHeight) / 2);
         cr.lineTo(barLevelBorderRadius + barLevelBorderWidth, (height + barLevelHeight) / 2);
-        Clutter.cairo_set_source_color(cr, barLevelActiveColor);
+        if (this._value > 0)
+          Clutter.cairo_set_source_color(cr, barLevelActiveColor);
         cr.fillPreserve();
         Clutter.cairo_set_source_color(cr, barLevelActiveBorderColor);
         cr.setLineWidth(barLevelBorderWidth);
@@ -143,17 +144,19 @@ var BarLevel = class {
         }
 
         /* end progress bar arc */
-        if (this._value <= this._overdriveStart)
-            Clutter.cairo_set_source_color(cr, barLevelActiveColor);
-        else
-            Clutter.cairo_set_source_color(cr, barLevelOverdriveColor);
-        cr.arc(endX, height / 2, barLevelBorderRadius, TAU * 3 / 4, TAU * 1 / 4);
-        cr.lineTo(Math.floor(endX), (height + barLevelHeight) / 2);
-        cr.lineTo(Math.floor(endX), (height - barLevelHeight) / 2);
-        cr.lineTo(endX, (height - barLevelHeight) / 2);
-        cr.fillPreserve();
-        cr.setLineWidth(barLevelBorderWidth);
-        cr.stroke();
+        if (this._value > 0) {
+          if (this._value <= this._overdriveStart)
+              Clutter.cairo_set_source_color(cr, barLevelActiveColor);
+          else
+              Clutter.cairo_set_source_color(cr, barLevelOverdriveColor);
+          cr.arc(endX, height / 2, barLevelBorderRadius, TAU * 3 / 4, TAU * 1 / 4);
+          cr.lineTo(Math.floor(endX), (height + barLevelHeight) / 2);
+          cr.lineTo(Math.floor(endX), (height - barLevelHeight) / 2);
+          cr.lineTo(endX, (height - barLevelHeight) / 2);
+          cr.fillPreserve();
+          cr.setLineWidth(barLevelBorderWidth);
+          cr.stroke();
+        }
 
         /* draw overdrive separator */
         if (overdriveActive) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]