messageTray: Allow opening the context menu on long press
Right click does not work for touch devices, so support opening the menu using long press as well. https://bugzilla.gnome.org/show_bug.cgi?id=693887
This commit is contained in:
parent
3628c81885
commit
186bd156dd
@ -1741,25 +1741,24 @@ const MessageTray = new Lang.Class({
|
|||||||
this._updateNoMessagesLabel();
|
this._updateNoMessagesLabel();
|
||||||
|
|
||||||
this._contextMenu = new MessageTrayContextMenu(this);
|
this._contextMenu = new MessageTrayContextMenu(this);
|
||||||
this._grabHelper.addActor(this._contextMenu.actor);
|
|
||||||
this.actor.connect('button-press-event', Lang.bind(this, function(actor, event) {
|
let clickAction = new Clutter.ClickAction();
|
||||||
let button = event.get_button();
|
this.actor.add_action(clickAction);
|
||||||
if (button == 3) {
|
|
||||||
let [stageX, stageY] = event.get_coords();
|
clickAction.connect('clicked', Lang.bind(this, function(action) {
|
||||||
this._lock();
|
let button = action.get_button();
|
||||||
this._contextMenu.setPosition(Math.round(stageX), Math.round(stageY));
|
if (button == 3)
|
||||||
this._grabHelper.grab({ actor: this._contextMenu.actor,
|
this._openContextMenu();
|
||||||
grabFocus: true,
|
}));
|
||||||
onUngrab: Lang.bind(this, function () {
|
|
||||||
this._unlock();
|
clickAction.connect('long-press', Lang.bind(this, function(action, actor, state) {
|
||||||
this._contextMenu.close();
|
switch (state) {
|
||||||
})
|
case Clutter.LongPressState.QUERY:
|
||||||
});
|
return true;
|
||||||
this._contextMenu.open();
|
case Clutter.LongPressState.ACTIVATE:
|
||||||
}
|
this._openContextMenu();
|
||||||
else {
|
|
||||||
this._grabHelper.ungrab({ actor: this._contextMenu.actor });
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this._contextMenu.actor.hide();
|
this._contextMenu.actor.hide();
|
||||||
@ -1767,6 +1766,20 @@ const MessageTray = new Lang.Class({
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_openContextMenu: function () {
|
||||||
|
let [x, y, mask] = global.get_pointer();
|
||||||
|
this._lock();
|
||||||
|
this._contextMenu.setPosition(Math.round(x), Math.round(y));
|
||||||
|
this._grabHelper.grab({ actor: this._contextMenu.actor,
|
||||||
|
grabFocus: true,
|
||||||
|
onUngrab: Lang.bind(this, function () {
|
||||||
|
this._contextMenu.close();
|
||||||
|
this._unlock();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
this._contextMenu.open();
|
||||||
|
},
|
||||||
|
|
||||||
close: function() {
|
close: function() {
|
||||||
this._escapeTray();
|
this._escapeTray();
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user