[gnome-shell] shellEntry: Don't use a ClutterClickAction to pop up a menu



commit 9dfd1bfa41c674cfdc35c0d002e561a2c8724a2a
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Sep 6 16:14:32 2012 -0300

    shellEntry: Don't use a ClutterClickAction to pop up a menu
    
    This removes support for long press, but fixes the brokenness of
    other types of event handling.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=683509

 js/ui/shellEntry.js |   43 ++++++++++---------------------------------
 1 files changed, 10 insertions(+), 33 deletions(-)
---
diff --git a/js/ui/shellEntry.js b/js/ui/shellEntry.js
index 90b313f..b82bc46 100644
--- a/js/ui/shellEntry.js
+++ b/js/ui/shellEntry.js
@@ -126,34 +126,20 @@ function _setMenuAlignment(entry, stageX) {
         entry.menu.setSourceAlignment(entryX / entry.width);
 };
 
-function _onClicked(action, actor) {
-    let entry = actor.menu ? actor : actor.get_parent();
-
+function _onButtonPressEvent(actor, event, entry) {
     if (entry.menu.isOpen) {
         entry.menu.close();
-    } else if (action.get_button() == 3) {
-        let [stageX, stageY] = action.get_coords();
-        _setMenuAlignment(entry, stageX);
-        entry.menu.open();
-    }
-};
-
-function _onLongPress(action, actor, state) {
-    let entry = actor.menu ? actor : actor.get_parent();
-
-    if (state == Clutter.LongPressState.QUERY)
-        return action.get_button() == 1 && !entry.menu.isOpen;
-
-    if (state == Clutter.LongPressState.ACTIVATE) {
-        let [stageX, stageY] = action.get_coords();
+        return true;
+    } else if (event.get_button() == 3) {
+        let [stageX, stageY] = event.get_coords();
         _setMenuAlignment(entry, stageX);
         entry.menu.open();
+        return true;
     }
     return false;
 };
 
-function _onPopup(actor) {
-    let entry = actor.menu ? actor : actor.get_parent();
+function _onPopup(actor, entry) {
     let [success, textX, textY, lineHeight] = entry.clutter_text.position_to_coords(-1);
     if (success)
         entry.menu.setSourceAlignment(textX / entry.width);
@@ -168,20 +154,11 @@ function addContextMenu(entry, params) {
     entry._menuManager = new PopupMenu.PopupMenuManager({ actor: entry });
     entry._menuManager.addMenu(entry.menu);
 
-    let clickAction;
-
-    // Add a click action to both the entry and its clutter_text; the former
+    // Add an event handler to both the entry and its clutter_text; the former
     // so padding is included in the clickable area, the latter because the
     // event processing of ClutterText prevents event-bubbling.
-    clickAction = new Clutter.ClickAction();
-    clickAction.connect('clicked', _onClicked);
-    clickAction.connect('long-press', _onLongPress);
-    entry.clutter_text.add_action(clickAction);
-
-    clickAction = new Clutter.ClickAction();
-    clickAction.connect('clicked', _onClicked);
-    clickAction.connect('long-press', _onLongPress);
-    entry.add_action(clickAction);
+    entry.clutter_text.connect('button-press-event', Lang.bind(null, _onButtonPressEvent, entry));
+    entry.connect('button-press-event', Lang.bind(null, _onButtonPressEvent, entry));
 
-    entry.connect('popup-menu', _onPopup);
+    entry.connect('popup-menu', Lang.bind(null, _onPopup, entry));
 }



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