[gnome-shell] barLevel: Return when trying to set value to already used value
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] barLevel: Return when trying to set value to already used value
- Date: Sun, 28 Jul 2019 15:36:43 +0000 (UTC)
commit 86c3909908829216767690a4c53699fde25c6c8e
Author: verdre <verdre v0yd nl>
Date: Sat Feb 2 18:01:56 2019 +0100
barLevel: Return when trying to set value to already used value
There are some cases (for example when tweening value changes), where
the level will be set to the same value it already is at. Avoid those
unnecessary repaints by checking whether the value is already used and
returning if it is.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/385
js/ui/barLevel.js | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/barLevel.js b/js/ui/barLevel.js
index 78aa03048..ea295f1e8 100644
--- a/js/ui/barLevel.js
+++ b/js/ui/barLevel.js
@@ -42,7 +42,12 @@ var BarLevel = class {
if (isNaN(value))
throw TypeError('The bar level value must be a number');
- this._value = Math.max(Math.min(value, this._maxValue), 0);
+ value = Math.max(Math.min(value, this._maxValue), 0);
+
+ if (this._value == value)
+ return;
+
+ this._value = value;
this.actor.queue_repaint();
}
@@ -56,7 +61,12 @@ var BarLevel = class {
if (isNaN(value))
throw TypeError('The bar level max value must be a number');
- this._maxValue = Math.max(value, 1);
+ value = Math.max(value, 1);
+
+ if (this._maxValue == value)
+ return;
+
+ this._maxValue = value;
this._overdriveStart = Math.min(this._overdriveStart, this._maxValue);
this.actor.queue_repaint();
}
@@ -70,6 +80,10 @@ var BarLevel = class {
set overdrive_start(value) {
if (isNaN(value))
throw TypeError('The overdrive limit value must be a number');
+
+ if (this._overdriveStart == value)
+ return;
+
if (value > this._maxValue)
throw new Error(`Tried to set overdrive value to ${value}, ` +
`which is a number greater than the maximum allowed value ${this._maxValue}`);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]