layout: Move the keybinding mode to the user of PressureBarrier

For the hot corner case, we want to have the pressure apply both in
and outside of the overview, so we need to move this to the user. At
the same time, use keybinding mode math that's more like what's used
in filterKeybinding.

While it may seem like an abuse of the KeyBindingMode API, it may
become more reasonable if one thinks of the pressure barrier as a
binding of sorts, just applied to the mouse. If a ButtonBinding API
was added to mutter, I think we'd use the existing KeyBindingMode
infastructure there as well.
This commit is contained in:
Jasper St. Pierre 2013-03-01 15:45:56 -05:00
parent 0cc1615252
commit df848aa084

View File

@ -441,7 +441,11 @@ const LayoutManager = new Lang.Class({
y1: monitor.y + monitor.height, y2: monitor.y + monitor.height,
directions: Meta.BarrierDirection.NEGATIVE_Y });
this._trayPressure = new PressureBarrier(this._trayBarrier, MESSAGE_TRAY_PRESSURE_THRESHOLD, MESSAGE_TRAY_PRESSURE_TIMEOUT);
this._trayPressure = new PressureBarrier(this._trayBarrier,
MESSAGE_TRAY_PRESSURE_THRESHOLD,
MESSAGE_TRAY_PRESSURE_TIMEOUT,
Shell.KeyBindingMode.NORMAL |
Shell.KeyBindingMode.OVERVIEW);
this._trayPressure.connect('trigger', function(barrier) {
Main.messageTray.openTray();
});
@ -1258,10 +1262,11 @@ const HotCorner = new Lang.Class({
const PressureBarrier = new Lang.Class({
Name: 'PressureBarrier',
_init: function(barrier, threshold, timeout) {
_init: function(barrier, threshold, timeout, keybindingMode) {
this._barrier = barrier;
this._threshold = threshold;
this._timeout = timeout;
this._keybindingMode = keybindingMode;
this._orientation = (barrier.y1 == barrier.y2) ? Clutter.Orientation.HORIZONTAL : Clutter.Orientation.VERTICAL;
this._isTriggered = false;
@ -1344,11 +1349,8 @@ const PressureBarrier = new Lang.Class({
if (event.grabbed && Main.modalCount == 0)
return;
let isOverview = ((Main.keybindingMode & (Shell.KeyBindingMode.OVERVIEW)) != 0);
// Throw out events where the grab is taken by something that's
// not the overview (modal dialogs, etc.)
if (event.grabbed && !isOverview)
// Throw out all events not in the proper keybinding mode
if (!(this._keybindingMode & Main.keybindingMode))
return;
let slide = this._getDistanceAlongBarrier(event);