[gnome-shell] layout: Prevent going into negatives with the pressure
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] layout: Prevent going into negatives with the pressure
- Date: Mon, 4 Mar 2013 20:51:00 +0000 (UTC)
commit d4259fa8aa272727096ab66748d0d8e3287ce7f8
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Mar 1 15:21:25 2013 -0500
layout: Prevent going into negatives with the pressure
We capped each event to 15px of travel, but we didn't do the same
cap when subtracting events that were too old.
js/ui/layout.js | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/js/ui/layout.js b/js/ui/layout.js
index b178b53..bcc0dda 100644
--- a/js/ui/layout.js
+++ b/js/ui/layout.js
@@ -1296,19 +1296,16 @@ const PressureBarrier = new Lang.Class({
return Math.abs(event.dy);
},
- _isBarrierEventTooOld: function(event) {
- // Ignore all events older than this time
- let threshold = this._lastTime - this._timeout;
- return event.time < threshold;
- },
-
_trimBarrierEvents: function() {
// Events are guaranteed to be sorted in time order from
// oldest to newest, so just look for the first old event,
// and then chop events after that off.
let i = 0;
+ let threshold = this._lastTime - this._timeout;
+
while (i < this._barrierEvents.length) {
- if (!this._isBarrierEventTooOld(this._barrierEvents[i]))
+ let [time, distance] = this._barrierEvents[i];
+ if (time >= threshold)
break;
i++;
}
@@ -1316,7 +1313,8 @@ const PressureBarrier = new Lang.Class({
let firstNewEvent = i;
for (i = 0; i < firstNewEvent; i++) {
- this._currentPressure -= this._getDistanceAcrossBarrier(this._barrierEvents[i]);
+ let [time, distance] = this._barrierEvents[i];
+ this._currentPressure -= distance;
}
this._barrierEvents = this._barrierEvents.slice(firstNewEvent);
@@ -1362,8 +1360,10 @@ const PressureBarrier = new Lang.Class({
this._lastTime = event.time;
this._trimBarrierEvents();
- this._barrierEvents.push(event);
- this._currentPressure += Math.min(15, distance);
+ distance = Math.min(15, distance);
+
+ this._barrierEvents.push([event.time, distance]);
+ this._currentPressure += distance;
if (this._currentPressure >= this._threshold)
this._trigger();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]