[gnome-shell] [AppDisplay] Popup the menu on left-click/hold



commit d9f43e27a03bfb812c45ee85561e96e2e44ddf7f
Author: Florian Müllner <fmuellner src gnome org>
Date:   Wed Mar 10 14:52:28 2010 +0100

    [AppDisplay] Popup the menu on left-click/hold
    
    Left-clicking an app icon and holding the button used to pop up the
    app menu, but regressed when rewriting appDisplay.
    Restore the previous behavior.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=609013

 js/ui/appDisplay.js |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 6b88232..0b979d6 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -23,6 +23,7 @@ const Workspace = imports.ui.workspace;
 
 const APPICON_SIZE = 48;
 const WELL_MAX_COLUMNS = 8;
+const MENU_POPUP_TIMEOUT = 600;
 
 function AllAppView() {
     this._init();
@@ -416,6 +417,7 @@ AppWellIcon.prototype = {
         this.actor.connect('destroy', Lang.bind(this, this._onHideDestroy));
 
         this._appWindowChangedId = 0;
+        this._menuTimeoutId = 0;
     },
 
     _onShow: function() {
@@ -428,6 +430,14 @@ AppWellIcon.prototype = {
     _onHideDestroy: function() {
         if (this._appWindowChangedId > 0)
             this.app.disconnect(this._appWindowChangedId);
+        this._removeMenuTimeout();
+    },
+
+    _removeMenuTimeout: function() {
+        if (this._menuTimeoutId > 0) {
+            Mainloop.source_remove(this._menuTimeoutId);
+            this._menuTimeoutId = 0;
+        }
     },
 
     _updateStyleClass: function() {
@@ -446,6 +456,15 @@ AppWellIcon.prototype = {
         let [stageX, stageY] = event.get_coords();
         this._dragStartX = stageX;
         this._dragStartY = stageY;
+
+        let button = event.get_button();
+        if (button == 1) {
+            this._removeMenuTimeout();
+            this._menuTimeoutId = Mainloop.timeout_add(MENU_POPUP_TIMEOUT,
+                Lang.bind(this, function() {
+                    this.popupMenu(button);
+                }));
+        }
     },
 
     _onHoverChange: function(actor) {
@@ -453,6 +472,7 @@ AppWellIcon.prototype = {
         if (!hover) {
             if (this.actor.held && this._dragStartX != null) {
                 this.actor.fake_release();
+                this._removeMenuTimeout();
                 this._draggable.startDrag(this._dragStartX, this._dragStartY,
                                           global.get_current_time());
             } else {
@@ -463,6 +483,8 @@ AppWellIcon.prototype = {
     },
 
     _onClicked: function(actor, event) {
+        this._removeMenuTimeout();
+
         let button = event.get_button();
         if (button == 1) {
             this._onActivate(event);
@@ -479,6 +501,9 @@ AppWellIcon.prototype = {
     },
 
     popupMenu: function(activatingButton) {
+        this._removeMenuTimeout();
+        this.actor.fake_release();
+
         if (!this._menu) {
             this._menu = new AppIconMenu(this);
             this._menu.connect('highlight-window', Lang.bind(this, function (menu, window) {



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