[gnome-shell] osdWindow: Fix level bar width



commit 775187b2e49ee39405148c214aa4bb9c3bc8f50e
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Jun 4 01:29:07 2016 +0200

    osdWindow: Fix level bar width
    
    Commit 9b07ce1d0d changed the OSD window's level bar to be a regular
    actor instead of a custom drawn bar. The bar actor's width depends on
    both the configured level (e.g. 40%) and the available width, however
    the width is currently only updated when the configured level changes.
    Fix that by properly considering changes to the parent's width as well.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768317

 js/ui/osdWindow.js |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/js/ui/osdWindow.js b/js/ui/osdWindow.js
index 53ccc97..c33e937 100644
--- a/js/ui/osdWindow.js
+++ b/js/ui/osdWindow.js
@@ -27,6 +27,8 @@ const LevelBar = new Lang.Class({
         this._bar = new St.Widget({ style_class: 'level-bar' });
 
         this.actor.set_child(this._bar);
+
+        this.actor.connect('notify::width', () => { this.level = this.level; });
     },
 
     get level() {
@@ -34,14 +36,12 @@ const LevelBar = new Lang.Class({
     },
 
     set level(value) {
-        let newValue = Math.max(0, Math.min(value, 100));
-        if (newValue == this._level)
-            return;
-        this._level = newValue;
+        this._level = Math.max(0, Math.min(value, 100));
 
-        let width = this.actor.width;
-        width *= (this._level / 100.);
-        this._bar.width = width;
+        let alloc = this.actor.get_allocation_box();
+        let newWidth = (alloc.x2 - alloc.x1) * this._level / 100;
+        if (newWidth != this._bar.width)
+            this._bar.width = newWidth;
     }
 });
 


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