[gnome-shell/eos3.8: 64/255] Add an addBackgroundMenuForAction function for greater flexibility



commit 7940dec6d0c3e5f8e8468a7bef1e8d63d3cf14b8
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Fri Jun 9 13:10:03 2017 +0100

    Add an addBackgroundMenuForAction function for greater flexibility
    
    In some cases we want to have more control over the ClutterClickAction
    used to open the background menu, so that we can bind its 'enabled'
    property to the eventBlocker actor reactive state and to the mapped
    state of the overview, so add this alternative function for that.
    
    Also, disable the background menu when in initial-setup mode, otherwise
    it's possible to launch the App Center from it and, with some additional
    effort, ending up executing anything even before the FBE is finished.
    
    https://phabricator.endlessm.com/T20471

 js/ui/backgroundMenu.js | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/backgroundMenu.js b/js/ui/backgroundMenu.js
index 1a3eb6e383..0e94713527 100644
--- a/js/ui/backgroundMenu.js
+++ b/js/ui/backgroundMenu.js
@@ -1,5 +1,5 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
-/* exported addBackgroundMenu */
+/* exported addBackgroundMenu, addBackgroundMenuForAction */
 
 const { Clutter, Meta, Shell, St } = imports.gi;
 
@@ -32,7 +32,23 @@ var BackgroundMenu = class BackgroundMenu extends PopupMenu.PopupMenu {
     }
 };
 
-function addBackgroundMenu(actor, layoutManager) {
+function _addBackgroundMenuFull(actor, clickAction, layoutManager) {
+    // We don't want the background menu enabled on the desktop
+    // during the FBE, or in any mode without an overview, fwiw.
+    if (!Main.sessionMode.hasOverview)
+        return;
+
+    // Either the actor or the action has to be defined
+    if (!actor && !clickAction)
+        return;
+
+    if (actor) {
+        clickAction = new Clutter.ClickAction();
+        actor.add_action(clickAction);
+    } else {
+        actor = clickAction.get_actor();
+    }
+
     actor.reactive = true;
     actor._backgroundMenu = new BackgroundMenu(layoutManager);
     actor._backgroundManager = new PopupMenu.PopupMenuManager(actor);
@@ -43,7 +59,6 @@ function addBackgroundMenu(actor, layoutManager) {
         actor._backgroundMenu.open(BoxPointer.PopupAnimation.FULL);
     }
 
-    let clickAction = new Clutter.ClickAction();
     clickAction.connect('long-press', (action, theActor, state) => {
         if (state == Clutter.LongPressState.QUERY) {
             return (action.get_button() == 0 ||
@@ -63,7 +78,6 @@ function addBackgroundMenu(actor, layoutManager) {
             openMenu(x, y);
         }
     });
-    actor.add_action(clickAction);
 
     let grabOpBeginId = global.display.connect('grab-op-begin', () => {
         clickAction.release();
@@ -88,3 +102,11 @@ function addBackgroundMenu(actor, layoutManager) {
             clickAction.release();
     });
 }
+
+function addBackgroundMenu(actor, layoutManager) {
+    _addBackgroundMenuFull(actor, null, layoutManager);
+}
+
+function addBackgroundMenuForAction(clickAction, layoutManager) {
+    _addBackgroundMenuFull(null, clickAction, layoutManager);
+}


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