gestures: Restrict actions based on keybindingMode
Just like keybindings and the message tray pointer barrier, gestures don't always make sense - for instance, swiping up the screen shield should not trigger the message tray just as the SelectArea action around the left edge should not open the overview. To avoid this, restrict gestures based on the current keybinding mode. https://bugzilla.gnome.org/show_bug.cgi?id=740237
This commit is contained in:
parent
c568b44997
commit
7e7eab2bea
@ -6,6 +6,8 @@ const Meta = imports.gi.Meta;
|
|||||||
const Clutter = imports.gi.Clutter;
|
const Clutter = imports.gi.Clutter;
|
||||||
const St = imports.gi.St;
|
const St = imports.gi.St;
|
||||||
|
|
||||||
|
const Main = imports.ui.main;
|
||||||
|
|
||||||
const EDGE_THRESHOLD = 20;
|
const EDGE_THRESHOLD = 20;
|
||||||
const DRAG_DISTANCE = 80;
|
const DRAG_DISTANCE = 80;
|
||||||
|
|
||||||
@ -13,9 +15,10 @@ const EdgeDragAction = new Lang.Class({
|
|||||||
Name: 'EdgeDragAction',
|
Name: 'EdgeDragAction',
|
||||||
Extends: Clutter.GestureAction,
|
Extends: Clutter.GestureAction,
|
||||||
|
|
||||||
_init : function(side) {
|
_init : function(side, allowedModes) {
|
||||||
this.parent();
|
this.parent();
|
||||||
this._side = side;
|
this._side = side;
|
||||||
|
this._allowedModes = allowedModes;
|
||||||
this.set_n_touch_points(1);
|
this.set_n_touch_points(1);
|
||||||
|
|
||||||
global.display.connect('grab-op-begin', Lang.bind(this, function() {
|
global.display.connect('grab-op-begin', Lang.bind(this, function() {
|
||||||
@ -34,6 +37,9 @@ const EdgeDragAction = new Lang.Class({
|
|||||||
if (this.get_n_current_points() == 0)
|
if (this.get_n_current_points() == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!(this._allowedModes & Main.keybindingMode))
|
||||||
|
return false;
|
||||||
|
|
||||||
let [x, y] = this.get_press_coords(0);
|
let [x, y] = this.get_press_coords(0);
|
||||||
let monitorRect = this._getMonitorRect(x, y);
|
let monitorRect = this._getMonitorRect(x, y);
|
||||||
|
|
||||||
|
@ -1951,7 +1951,9 @@ const MessageTray = new Lang.Class({
|
|||||||
this._messageTrayMenuButton.actor.connect('key-press-event',
|
this._messageTrayMenuButton.actor.connect('key-press-event',
|
||||||
Lang.bind(this, this._onTrayButtonKeyPress));
|
Lang.bind(this, this._onTrayButtonKeyPress));
|
||||||
|
|
||||||
let gesture = new EdgeDragAction.EdgeDragAction(St.Side.BOTTOM);
|
let gesture = new EdgeDragAction.EdgeDragAction(St.Side.BOTTOM,
|
||||||
|
Shell.KeyBindingMode.NORMAL |
|
||||||
|
Shell.KeyBindingMode.OVERVIEW);
|
||||||
gesture.connect('activated', Lang.bind(this, this.toggle));
|
gesture.connect('activated', Lang.bind(this, this.toggle));
|
||||||
global.stage.add_action(gesture);
|
global.stage.add_action(gesture);
|
||||||
},
|
},
|
||||||
|
@ -65,7 +65,8 @@ const ShowOverviewAction = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
vfunc_gesture_prepare : function(action, actor) {
|
vfunc_gesture_prepare : function(action, actor) {
|
||||||
return this.get_n_current_points() == this.get_n_touch_points();
|
return Main.keybindingMode == Shell.KeyBindingMode.NORMAL &&
|
||||||
|
this.get_n_current_points() == this.get_n_touch_points();
|
||||||
},
|
},
|
||||||
|
|
||||||
_getBoundingRect : function(motion) {
|
_getBoundingRect : function(motion) {
|
||||||
@ -215,7 +216,8 @@ const ViewSelector = new Lang.Class({
|
|||||||
|
|
||||||
let gesture;
|
let gesture;
|
||||||
|
|
||||||
gesture = new EdgeDragAction.EdgeDragAction(St.Side.LEFT);
|
gesture = new EdgeDragAction.EdgeDragAction(St.Side.LEFT,
|
||||||
|
Shell.KeyBindingMode.NORMAL);
|
||||||
gesture.connect('activated', Lang.bind(this, function() {
|
gesture.connect('activated', Lang.bind(this, function() {
|
||||||
if (Main.overview.visible)
|
if (Main.overview.visible)
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
|
@ -478,7 +478,9 @@ const WorkspaceSwitchAction = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
vfunc_gesture_prepare : function(action, actor) {
|
vfunc_gesture_prepare : function(action, actor) {
|
||||||
return this.get_n_current_points() == this.get_n_touch_points();
|
let allowedModes = Shell.KeyBindingMode.NORMAL | Shell.KeyBindingMode.OVERVIEW;
|
||||||
|
return this.get_n_current_points() == this.get_n_touch_points() &&
|
||||||
|
(allowedModes & Main.keybindingMode);
|
||||||
},
|
},
|
||||||
|
|
||||||
vfunc_gesture_end : function(action, actor) {
|
vfunc_gesture_end : function(action, actor) {
|
||||||
@ -526,7 +528,7 @@ const AppSwitchAction = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
vfunc_gesture_prepare : function(action, actor) {
|
vfunc_gesture_prepare : function(action, actor) {
|
||||||
if (Main.overview.visible) {
|
if (Main.keybindingMode != Shell.KeyBindingMode.NORMAL) {
|
||||||
this.cancel();
|
this.cancel();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user