[gnome-shell/wip/pressure: 3/14] messageTray: Trigger the tray by downward pressure
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/pressure: 3/14] messageTray: Trigger the tray by downward pressure
- Date: Mon, 30 Jul 2012 23:48:05 +0000 (UTC)
commit b55d2c620a2ad05537cae5491614a5da83462242
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Jul 30 16:25:07 2012 -0300
messageTray: Trigger the tray by downward pressure
https://bugzilla.gnome.org/show_bug.cgi?id=677215
js/ui/layout.js | 79 ++++++++++++++++++++++++++++++++++++++++++-------
js/ui/messageTray.js | 25 +++------------
2 files changed, 72 insertions(+), 32 deletions(-)
---
diff --git a/js/ui/layout.js b/js/ui/layout.js
index 9c436b5..97285de 100644
--- a/js/ui/layout.js
+++ b/js/ui/layout.js
@@ -28,7 +28,8 @@ const LayoutManager = new Lang.Class({
this._hotCorners = [];
this._leftPanelBarrier = null;
this._rightPanelBarrier = null;
- this._trayBarrier = null;
+ this._vertTrayBarrier = null;
+ this._horizTrayBarrier = null;
this._chrome = new Chrome(this);
@@ -48,7 +49,7 @@ const LayoutManager = new Lang.Class({
this.trayBox = new St.BoxLayout({ name: 'trayBox' });
this.addChrome(this.trayBox);
this.trayBox.connect('allocation-changed',
- Lang.bind(this, this._updateTrayBarrier));
+ Lang.bind(this, this._updateTrayBarriers));
this.keyboardBox = new St.BoxLayout({ name: 'keyboardBox',
reactive: true,
@@ -202,20 +203,37 @@ const LayoutManager = new Lang.Class({
}
},
- _updateTrayBarrier: function() {
+ _updateTrayBarriers: function() {
let monitor = this.bottomMonitor;
- if (this._trayBarrier)
- this._trayBarrier.deactivate();
+ if (this._vertTrayBarrier)
+ this._vertTrayBarrier.deactivate();
+ if (this._horizTrayBarrier)
+ this._horizTrayBarrier.deactivate();
+ if (this._horizTrayPressure)
+ this._horizTrayPressure.destroy();
if (Main.messageTray) {
- this._trayBarrier = new Meta.Barrier({ display: global.display,
- x1: monitor.x + monitor.width, y1: monitor.y + monitor.height - Main.messageTray.actor.height,
- x2: monitor.x + monitor.width, y2: monitor.y + monitor.height,
- directions: Meta.BarrierDirection.NEGATIVE_X });
- this._trayBarrier.activate();
+ this._vertTrayBarrier = new Meta.Barrier({ display: global.display,
+ x1: monitor.x + monitor.width, y1: monitor.y + monitor.height - Main.messageTray.actor.height,
+ x2: monitor.x + monitor.width, y2: monitor.y + monitor.height,
+ directions: Meta.BarrierDirection.NEGATIVE_X });
+
+ this._horizTrayBarrier = new Meta.Barrier({ display: global.display,
+ x1: monitor.x, x2: monitor.x + monitor.width,
+ y1: monitor.y + monitor.height, y2: monitor.y + monitor.height,
+ directions: Meta.BarrierDirection.NEGATIVE_Y });
+
+ this._horizTrayPressure = new PressureBarrier(this._horizTrayBarrier, 100);
+ this._horizTrayPressure.connect('trigger', function() {
+ Main.messageTray.openTray();
+ });
+
+ this._vertTrayBarrier.activate();
+ this._horizTrayBarrier.activate();
} else {
- this._trayBarrier = null;
+ this._horizTrayBarrier = null
+ this._vertTrayBarrier = null;
}
},
@@ -991,5 +1009,42 @@ const Chrome = new Lang.Class({
return false;
}
});
-
Signals.addSignalMethods(Chrome.prototype);
+
+const PressureBarrier = new Lang.Class({
+ Name: 'TrayPressure',
+
+ _init: function(barrier, threshold) {
+ this._barrier = barrier;
+ this._threshold = threshold;
+
+ this._lastEventID = 0;
+ this._pressure = 0;
+
+ this._barrier.connect('hit', Lang.bind(this, this._onBarrierHit));
+ },
+
+ _getVelocity: function(event, barrier) {
+ if (barrier.y1 === barrier.y2)
+ return Math.abs(event.dx);
+ else
+ return Math.abs(event.dy);
+ },
+
+ _onBarrierHit: function(barrier, event) {
+ // Event IDs are incremented every time the user stops
+ // hitting the barrier. So, if the event ID switches,
+ // reset the current pressure counter.
+ if (this._lastEventId != event.event_id) {
+ this._pressure = 0;
+ this._lastEventId = event.event_id;
+ } else {
+ this._pressure += this._getVelocity(event, this._barrier);
+ if (this._pressure >= this._threshold) {
+ this.emit('trigger');
+ this._pressure = 0;
+ }
+ }
+ }
+});
+Signals.addSignalMethods(PressureBarrier.prototype);
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 964401d..37e56a2 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -1504,14 +1504,6 @@ const MessageTray = new Lang.Class({
this._tweening = 0;
this._windowsShifted = 0;
- this._corner = new Clutter.Rectangle({ width: 1,
- height: 1,
- opacity: 0,
- reactive: true });
- this._corner.connect('enter-event', Lang.bind(this, this._onCornerEnter));
- Main.layoutManager.trayBox.add_actor(this._corner);
- Main.layoutManager.trackChrome(this._corner);
-
Main.layoutManager.trayBox.add_actor(this.actor);
this.actor.y = 0;
Main.layoutManager.trackChrome(this.actor);
@@ -1560,24 +1552,12 @@ const MessageTray = new Lang.Class({
this._chatSummaryItemsCount = 0;
},
- _onCornerEnter: function(actor, event) {
- this._pointerInSummary = true;
- this._updateState();
- },
-
_setSizePosition: function() {
let monitor = Main.layoutManager.bottomMonitor;
this._notificationBin.x = 0;
this._notificationBin.width = monitor.width;
this._summaryBin.x = 0;
this._summaryBin.width = monitor.width;
-
- if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL)
- this._corner.x = 0;
- else
- this._corner.x = Main.layoutManager.trayBox.width - 1;
-
- this._corner.y = Main.layoutManager.trayBox.height - 1;
},
contains: function(source) {
@@ -1720,6 +1700,11 @@ const MessageTray = new Lang.Class({
this._updateState();
},
+ openTray: function(actor, event) {
+ this._traySummoned = true;
+ this._updateState();
+ },
+
toggle: function() {
this._traySummoned = !this._traySummoned;
Main.layoutManager.togglePanelStruts();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]