From acb1497f4fe2a155dd1020ba0bd7d69e680e1a92 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 22 Jul 2014 12:34:56 +0200 Subject: [PATCH] backgroundMenu: Allow for long presses on touch devices These don't have a button set. Also, popup the menu relative to gesture reported coordinates, and not relative to the pointer position everytime. https://bugzilla.gnome.org/show_bug.cgi?id=733633 --- js/ui/backgroundMenu.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/js/ui/backgroundMenu.js b/js/ui/backgroundMenu.js index d9341f576..446559f3e 100644 --- a/js/ui/backgroundMenu.js +++ b/js/ui/backgroundMenu.js @@ -33,8 +33,7 @@ function addBackgroundMenu(actor, layoutManager) { actor._backgroundManager = new PopupMenu.PopupMenuManager({ actor: actor }); actor._backgroundManager.addMenu(actor._backgroundMenu); - function openMenu() { - let [x, y] = global.get_pointer(); + function openMenu(x, y) { Main.layoutManager.setDummyCursorGeometry(x, y, 0, 0); actor._backgroundMenu.open(BoxPointer.PopupAnimation.NONE); } @@ -42,16 +41,21 @@ function addBackgroundMenu(actor, layoutManager) { let clickAction = new Clutter.ClickAction(); clickAction.connect('long-press', function(action, actor, state) { if (state == Clutter.LongPressState.QUERY) - return action.get_button() == 1 && !actor._backgroundMenu.isOpen; + return ((action.get_button() == 0 || + action.get_button() == 1) && + !actor._backgroundMenu.isOpen); if (state == Clutter.LongPressState.ACTIVATE) { - openMenu(); + let [x, y] = action.get_coords(); + openMenu(x, y); actor._backgroundManager.ignoreRelease(); } return true; }); clickAction.connect('clicked', function(action) { - if (action.get_button() == 3) - openMenu(); + if (action.get_button() == 3) { + let [x, y] = action.get_coords(); + openMenu(x, y); + } }); actor.add_action(clickAction);