[gnome-shell] Better handle pushModal failing



commit cee7106cb1f4c58701c6bea5f59ac25786445999
Author: Colin Walters <walters verbum org>
Date:   Wed Sep 16 11:37:51 2009 -0400

    Better handle pushModal failing
    
    Previously we'd leave the focus on the stack, etc.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=595382

 js/ui/lookingGlass.js |    4 +++-
 js/ui/main.js         |   20 ++++++++++++--------
 js/ui/overview.js     |    3 ++-
 js/ui/runDialog.js    |    4 +++-
 4 files changed, 20 insertions(+), 11 deletions(-)
---
diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js
index 8641782..8bfd660 100644
--- a/js/ui/lookingGlass.js
+++ b/js/ui/lookingGlass.js
@@ -542,13 +542,15 @@ LookingGlass.prototype = {
         if (this._open)
             return;
 
+        if (!Main.pushModal(this.actor))
+            return;
+
         this.actor.show();
         this.actor.lower(Main.chrome.actor);
         this._open = true;
 
         Tweener.removeTweens(this.actor);
 
-        Main.pushModal(this.actor);
         global.stage.set_key_focus(this._entry);
 
         Tweener.addTween(this.actor, { time: 0.5,
diff --git a/js/ui/main.js b/js/ui/main.js
index 5251ce8..62eea85 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -205,10 +205,21 @@ function _findModal(actor) {
  * Next, record the current Clutter keyboard focus on a stack.  If the modal stack
  * returns to this actor, reset the focus to the actor which was focused
  * at the time pushModal() was invoked.
+ *
+ * Returns: true iff we successfully acquired a grab or already had one
  */
 function pushModal(actor) {
     let timestamp = global.screen.get_display().get_current_time();
 
+    if (modalCount == 0) {
+        if (!global.begin_modal(timestamp)) {
+            log("pushModal: invocation of begin_modal failed");
+            return false;
+        }
+    }
+
+    global.set_stage_input_mode(Shell.StageInputMode.FULLSCREEN);
+
     modalCount += 1;
     actor.connect('destroy', function() {
         let index = _findModal(actor);
@@ -225,14 +236,7 @@ function pushModal(actor) {
     }
     modalActorFocusStack.push([actor, curFocus]);
 
-    if (modalCount > 1)
-        return;
-
-    if (!global.begin_modal(timestamp)) {
-        log("pushModal: invocation of begin_modal failed");
-        return;
-    }
-    global.set_stage_input_mode(Shell.StageInputMode.FULLSCREEN);
+    return true;
 }
 
 /**
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 5a0b94a..cccf2e4 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -277,7 +277,8 @@ Overview.prototype = {
     show : function() {
         if (this.visible)
             return;
-        Main.pushModal(this._dash.actor);
+        if (!Main.pushModal(this._dash.actor))
+            return;
 
         this.visible = true;
         this.animationInProgress = true;
diff --git a/js/ui/runDialog.js b/js/ui/runDialog.js
index 53315b4..ca9f06e 100644
--- a/js/ui/runDialog.js
+++ b/js/ui/runDialog.js
@@ -186,10 +186,12 @@ RunDialog.prototype = {
         if (this._isOpen) // Already shown
             return;
 
+        if (!Main.pushModal(this._group))
+            return;
+
         this._isOpen = true;
         this._group.show();
 
-        Main.pushModal(this._group);
         global.stage.set_key_focus(this._entry);
     },
 



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