[gnome-shell] Revert "[AppWell] Allow popup menu to be persistent, and support direct window selection"



commit dfe16f4af6a042bf7635ee9f59b088082a3615ff
Author: Colin Walters <walters verbum org>
Date:   Fri Sep 11 18:58:30 2009 -0400

    Revert "[AppWell] Allow popup menu to be persistent, and support direct window selection"
    
    This reverts commit 6e31e59b57ad60186b41944b175907ec7d90647c.

 js/ui/appDisplay.js |  102 +++++++-------------------------------------------
 js/ui/overview.js   |   11 -----
 js/ui/workspaces.js |    4 +-
 src/shell-menu.c    |   65 ++------------------------------
 src/shell-menu.h    |    2 -
 5 files changed, 22 insertions(+), 162 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 92bfb70..fe5b432 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -489,12 +489,6 @@ WellMenu.prototype = {
     _init: function(source) {
         this._source = source;
 
-        // Holds the WindowClone objects for our windows, used in the button release
-        // callback to find the window actor we released over
-        this._cachedWindowClones = [];
-
-        // Whether or not we successfully picked a window
-        this.didActivateWindow = false;
 
         this.actor = new Shell.GenericContainer({ reactive: true });
         this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
@@ -514,14 +508,6 @@ WellMenu.prototype = {
         this._windowContainer.connect('activate', Lang.bind(this, this._onWindowActivate));
         this.actor.add_actor(this._windowContainer);
 
-        // Stay popped up on release over application icon
-        this._windowContainer.set_persistent_source(this._source.actor);
-
-        // Intercept events while the menu has the pointer grab to do window-related effects
-        this._windowContainer.connect('enter-event', Lang.bind(this, this._onMenuEnter));
-        this._windowContainer.connect('leave-event', Lang.bind(this, this._onMenuLeave));
-        this._windowContainer.connect('button-release-event', Lang.bind(this, this._onMenuRelease));
-
         this._arrow = new Shell.DrawingArea();
         this._arrow.connect('redraw', Lang.bind(this, function (area, texture) {
             Shell.draw_box_pointer(texture, WELL_MENU_BORDER_COLOR, WELL_MENU_BACKGROUND_COLOR);
@@ -573,8 +559,6 @@ WellMenu.prototype = {
     _redisplay: function() {
         this._windowContainer.remove_all();
 
-        this.didActivateWindow = false;
-
         let windows = this._source.windows;
 
         this._windowContainer.show();
@@ -611,10 +595,7 @@ WellMenu.prototype = {
 
     _appendWindows: function (windows, iconsDiffer) {
         for (let i = 0; i < windows.length; i++) {
-            let metaWindow = windows[i];
-
-            this._cachedWindowClones.push(Main.overview.lookupCloneForWindow(metaWindow));
-
+            let window = windows[i];
             /* Use padding here rather than spacing in the box above so that
              * we have a larger reactive area.
              */
@@ -623,16 +604,16 @@ WellMenu.prototype = {
                                     padding_bottom: 4,
                                     spacing: 4,
                                     reactive: true });
-            box._window = metaWindow;
+            box._window = window;
             let vCenter;
             if (iconsDiffer) {
                 vCenter = new Big.Box({ y_align: Big.BoxAlignment.CENTER });
-                let icon = Shell.TextureCache.get_default().bind_pixbuf_property(metaWindow, "mini-icon");
+                let icon = Shell.TextureCache.get_default().bind_pixbuf_property(window, "mini-icon");
                 vCenter.append(icon, Big.BoxPackFlags.NONE);
                 box.append(vCenter, Big.BoxPackFlags.NONE);
             }
             vCenter = new Big.Box({ y_align: Big.BoxAlignment.CENTER });
-            let label = new Clutter.Text({ text: metaWindow.title,
+            let label = new Clutter.Text({ text: window.title,
                                            font_name: WELL_MENU_FONT,
                                            ellipsize: Pango.EllipsizeMode.END,
                                            color: WELL_MENU_COLOR });
@@ -658,68 +639,22 @@ WellMenu.prototype = {
         this.actor.show();
     },
 
-    _findWindowCloneForActor: function (actor) {
-        for (let i = 0; i < this._cachedWindowClones.length; i++) {
-            let clone = this._cachedWindowClones[i];
-            if (clone.actor == actor) {
-                return clone;
-            }
-        }
-        return null;
-    },
-
-    // This function is called while the menu has a pointer grab; what we want
-    // to do is see if the mouse was released over a window clone actor
-    _onMenuRelease: function (actor, event) {
-        let clone = this._findWindowCloneForActor(event.get_source());
-        if (clone) {
-            this.didActivateWindow = true;
-            Main.overview.activateWindow(clone.metaWindow, event.get_time());
-        }
-    },
-
-    _setHighlightWindow: function (metaWindow) {
-        let children = this._windowContainer.get_children();
-        for (let i = 0; i < children.length; i++) {
-            let child = children[i];
-            let menuMetaWindow = child._window;
-            if (metaWindow != null && menuMetaWindow == metaWindow) {
-                child.background_color = WELL_MENU_SELECTED_COLOR;
-            } else {
-                child.background_color = TRANSPARENT_COLOR;
-            }
-        }
-        this.emit('highlight-window', metaWindow);
-    },
-
-    // Called while menu has a pointer grab
-    _onMenuEnter: function (actor, event) {
-        let clone = this._findWindowCloneForActor(event.get_source());
-        if (clone) {
-            this._setHighlightWindow(clone.metaWindow);
-        }
-    },
-
-    // Called while menu has a pointer grab
-    _onMenuLeave: function (actor, event) {
-        let clone = this._findWindowCloneForActor(event.get_source());
-        if (clone) {
-            this._setHighlightWindow(null);
-        }
-    },
-
     _onWindowUnselected: function (actor, child) {
-        this._setHighlightWindow(null);
+        child.background_color = TRANSPARENT_COLOR;
+
+        this.emit('highlight-window', null);
     },
 
     _onWindowSelected: function (actor, child) {
-        this._setHighlightWindow(child._window);
+        child.background_color = WELL_MENU_SELECTED_COLOR;
+
+        let window = child._window;
+        this.emit('highlight-window', window);
     },
 
     _onWindowActivate: function (actor, child) {
-        let metaWindow = child._window;
-        this.didActivateWindow = true;
-        Main.overview.activateWindow(metaWindow, Clutter.get_current_event_time());
+        let window = child._window;
+        Main.overview.activateWindow(window, Clutter.get_current_event_time());
     },
 
     _onPopdown: function () {
@@ -858,22 +793,15 @@ RunningWellItem.prototype = {
 
         if (this._menu == null) {
             this._menu = new WellMenu(this);
-            this._menu.connect('highlight-window', Lang.bind(this, function (menu, metaWindow) {
-                Main.overview.setHighlightWindow(metaWindow);
+            this._menu.connect('highlight-window', Lang.bind(this, function (menu, window) {
+                Main.overview.setHighlightWindow(window);
             }));
             this._menu.connect('popup', Lang.bind(this, function (menu, isPoppedUp) {
                 let id;
-
-                // If we successfully picked a window, don't reset the workspace
-                // state, since that causes visual noise.  The workspace gets
-                // recreated each time we enter the overview
-                if (!isPoppedUp && menu.didActivateWindow)
-                    return;
                 if (isPoppedUp)
                     id = this.appInfo.get_id();
                 else
                     id = null;
-
                 Main.overview.setApplicationWindowSelection(id);
             }));
         }
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 4a78db9..4f50e6f 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -372,17 +372,6 @@ Overview.prototype = {
     },
 
     /**
-     * lookupCloneForWindow:
-     * @metaWindow: A #MetaWindow
-     *
-     * Given a #MetaWindow instance, find the WindowClone object
-     * which represents it in the workspaces display.
-     */
-    lookupCloneForWindow: function (metaWindow) {
-        return this._workspaces.lookupCloneForMetaWindow(metaWindow);
-    },
-
-    /**
      * activateWindow:
      * @metaWindow: A #MetaWindow
      * @time: Event timestamp integer
diff --git a/js/ui/workspaces.js b/js/ui/workspaces.js
index be208f9..39c48b5 100644
--- a/js/ui/workspaces.js
+++ b/js/ui/workspaces.js
@@ -1134,7 +1134,7 @@ Workspaces.prototype = {
         return null;
     },
 
-    lookupCloneForMetaWindow: function (metaWindow) {
+    _lookupCloneForMetaWindow: function (metaWindow) {
         for (let i = 0; i < this._workspaces.length; i++) {
             let clone = this._workspaces[i].lookupCloneForMetaWindow(metaWindow);
             if (clone)
@@ -1181,7 +1181,7 @@ Workspaces.prototype = {
         let activeWorkspaceNum = global.screen.get_active_workspace_index();
         let windowWorkspaceNum = metaWindow.get_workspace().index();
 
-        let clone = this.lookupCloneForMetaWindow (metaWindow);
+        let clone = this._lookupCloneForMetaWindow (metaWindow);
         clone.actor.raise_top();
 
         if (windowWorkspaceNum != activeWorkspaceNum) {
diff --git a/src/shell-menu.c b/src/shell-menu.c
index d09f6a0..6debaf8 100644
--- a/src/shell-menu.c
+++ b/src/shell-menu.c
@@ -15,9 +15,6 @@ G_DEFINE_TYPE(ShellMenu, shell_menu, BIG_TYPE_BOX);
 struct _ShellMenuPrivate {
   gboolean have_grab;
 
-  gboolean released_on_source;
-  ClutterActor *source_actor;
-
   ClutterActor *selected;
 };
 
@@ -34,10 +31,10 @@ enum
 static guint shell_menu_signals [LAST_SIGNAL] = { 0 };
 
 static gboolean
-shell_menu_contains (ClutterContainer *container,
-                     ClutterActor     *actor)
+shell_menu_contains (ShellMenu     *box,
+                     ClutterActor  *actor)
 {
-  while (actor != NULL && actor != (ClutterActor*)container)
+  while (actor != NULL && actor != (ClutterActor*)box)
     {
       actor = clutter_actor_get_parent (actor);
     }
@@ -76,7 +73,7 @@ shell_menu_enter_event (ClutterActor         *actor,
 {
   ShellMenu *box = SHELL_MENU (actor);
 
-  if (!shell_menu_contains (CLUTTER_CONTAINER (box), event->source))
+  if (!shell_menu_contains (box, event->source))
     return TRUE;
 
   if (event->source == (ClutterActor*)box)
@@ -110,21 +107,9 @@ shell_menu_button_release_event (ClutterActor       *actor,
   if (event->button != 1)
     return FALSE;
 
-  if (box->priv->source_actor && !box->priv->released_on_source)
-    {
-      if (box->priv->source_actor == event->source ||
-          (CLUTTER_IS_CONTAINER (box->priv->source_actor) &&
-           shell_menu_contains (CLUTTER_CONTAINER (box->priv->source_actor), event->source)))
-        {
-          /* On the next release, we want to pop down the menu regardless */
-          box->priv->released_on_source = TRUE;
-          return TRUE;
-        }
-    }
-
   shell_menu_popdown (box);
 
-  if (!shell_menu_contains (CLUTTER_CONTAINER (box), event->source))
+  if (!shell_menu_contains (box, event->source))
     return FALSE;
 
   if (box->priv->selected == NULL)
@@ -141,7 +126,6 @@ shell_menu_popup (ShellMenu         *box,
                   guint32            activate_time)
 {
   box->priv->have_grab = TRUE;
-  box->priv->released_on_source = FALSE;
   clutter_grab_pointer (CLUTTER_ACTOR (box));
 }
 
@@ -154,45 +138,6 @@ shell_menu_popdown (ShellMenu *box)
   g_signal_emit (G_OBJECT (box), shell_menu_signals[POPDOWN], 0);
 }
 
-static void
-on_source_destroyed (ClutterActor *actor,
-                     ShellMenu    *box)
-{
-  box->priv->source_actor = NULL;
-}
-
-/**
- * shell_menu_set_persistent_source:
- * @box:
- * @source: Actor to use as menu origin
- *
- * This function changes the menu behavior on button release.  Normally
- * when the mouse is released anywhere, the menu "pops down"; when this
- * function is called, if the mouse is released over the source actor,
- * the menu stays.
- *
- * The given @source actor must be reactive for this function to work.
- */
-void
-shell_menu_set_persistent_source (ShellMenu    *box,
-                                  ClutterActor *source)
-{
-  if (box->priv->source_actor)
-    {
-      g_signal_handlers_disconnect_by_func (G_OBJECT (box->priv->source_actor),
-                                            G_CALLBACK (on_source_destroyed),
-                                            box);
-    }
-  box->priv->source_actor = source;
-  if (box->priv->source_actor)
-    {
-      g_signal_connect (G_OBJECT (box->priv->source_actor),
-                        "destroy",
-                        G_CALLBACK (on_source_destroyed),
-                        box);
-    }
-}
-
 /**
  * shell_menu_append_separator:
  * @box:
diff --git a/src/shell-menu.h b/src/shell-menu.h
index bfe909a..1d0c571 100644
--- a/src/shell-menu.h
+++ b/src/shell-menu.h
@@ -32,8 +32,6 @@ GType shell_menu_get_type (void) G_GNUC_CONST;
 
 void shell_menu_popup (ShellMenu *behavior, guint button, guint32 activate_time);
 
-void shell_menu_set_persistent_source (ShellMenu *behavior, ClutterActor *source);
-
 void shell_menu_append_separator (ShellMenu *behavior, ClutterActor *separator, BigBoxPackFlags flags);
 
 void shell_menu_popdown (ShellMenu *behavior);



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