[gnome-shell] backgroundMenu: Allow for long presses on touch devices



commit acb1497f4fe2a155dd1020ba0bd7d69e680e1a92
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Jul 22 12:34:56 2014 +0200

    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 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/js/ui/backgroundMenu.js b/js/ui/backgroundMenu.js
index d9341f5..446559f 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);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]