legacyTray: add a pointer barrier to activate the tray

Allows easier access to the tray by just pushing the cursor against the
edge.

https://bugzilla.gnome.org/show_bug.cgi?id=746026
This commit is contained in:
Cosimo Cecchi 2015-03-13 15:47:49 -07:00
parent d165295c83
commit a5b7eaec1a

View File

@ -1,5 +1,6 @@
const Clutter = imports.gi.Clutter; const Clutter = imports.gi.Clutter;
const GObject = imports.gi.GObject; const GObject = imports.gi.GObject;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const St = imports.gi.St; const St = imports.gi.St;
@ -30,6 +31,9 @@ const STANDARD_TRAY_ICON_IMPLEMENTATIONS = {
const CONCEALED_VISIBLE_FRACTION = 0.2; const CONCEALED_VISIBLE_FRACTION = 0.2;
const REVEAL_ANIMATION_TIME = 0.2; const REVEAL_ANIMATION_TIME = 0.2;
const BARRIER_THRESHOLD = 70;
const BARRIER_TIMEOUT = 1000;
const LegacyTray = new Lang.Class({ const LegacyTray = new Lang.Class({
Name: 'LegacyTray', Name: 'LegacyTray',
@ -50,6 +54,7 @@ const LegacyTray = new Lang.Class({
y_align: Clutter.ActorAlign.END, y_align: Clutter.ActorAlign.END,
layout_manager: this._slideLayout }); layout_manager: this._slideLayout });
this.actor.add_actor(this._slider); this.actor.add_actor(this._slider);
this._slider.connect('notify::allocation', Lang.bind(this, this._syncBarrier));
this._box = new St.BoxLayout(); this._box = new St.BoxLayout();
this._slider.add_actor(this._box); this._slider.add_actor(this._box);
@ -85,6 +90,14 @@ const LegacyTray = new Lang.Class({
this._revealHandle.show(); this._revealHandle.show();
})); }));
this._horizontalBarrier = null;
this._pressureBarrier = new Layout.PressureBarrier(BARRIER_THRESHOLD,
BARRIER_TIMEOUT,
Shell.ActionMode.NORMAL);
this._pressureBarrier.connect('trigger', Lang.bind(this, function() {
this._concealHandle.show();
}));
Main.layoutManager.addChrome(this.actor, { affectsInputRegion: false }); Main.layoutManager.addChrome(this.actor, { affectsInputRegion: false });
Main.layoutManager.trackChrome(this._slider, { affectsInputRegion: true }); Main.layoutManager.trackChrome(this._slider, { affectsInputRegion: true });
Main.ctrlAltTabManager.addGroup(this.actor, Main.ctrlAltTabManager.addGroup(this.actor,
@ -155,6 +168,40 @@ const LegacyTray = new Lang.Class({
this._sync(); this._sync();
}, },
_syncBarrier: function() {
let rtl = (this._slider.get_text_direction() == Clutter.TextDirection.RTL);
let [x, y] = this._slider.get_transformed_position();
let [w, h] = this._slider.get_transformed_size();
let x1 = Math.round(x);
if (rtl)
x1 += Math.round(w);
let x2 = x1;
let y1 = Math.round(y);
let y2 = y1 + Math.round(h);
if (this._horizontalBarrier &&
this._horizontalBarrier.x1 == x1 &&
this._horizontalBarrier.y1 == y1 &&
this._horizontalBarrier.x2 == x2 &&
this._horizontalBarrier.y2 == y2)
return;
if (this._horizontalBarrier) {
this._pressureBarrier.removeBarrier(this._horizontalBarrier);
this._horizontalBarrier.destroy();
this._horizontalBarrier = null;
}
let directions = (rtl ? Meta.BarrierDirection.NEGATIVE_X : Meta.BarrierDirection.POSITIVE_X);
this._horizontalBarrier = new Meta.Barrier({ display: global.display,
x1: x1, x2: x2,
y1: y1, y2: y2,
directions: directions });
this._pressureBarrier.addBarrier(this._horizontalBarrier);
},
_sync: function() { _sync: function() {
// FIXME: we no longer treat tray icons as notifications // FIXME: we no longer treat tray icons as notifications
let allowed = Main.sessionMode.hasNotifications; let allowed = Main.sessionMode.hasNotifications;