[gnome-shell] modalDialog: Fix setting the initial key focus after the 1st time



commit b58425d7d7503d882e638e39ee9bbef4183fc196
Author: Rui Matos <tiagomatos gmail com>
Date:   Sun Feb 12 19:55:59 2012 +0100

    modalDialog: Fix setting the initial key focus after the 1st time
    
    Checking if _buttonLayout contains _initialKeyFocus always fails since we
    destroy all children before. Instead, use a signal handler id when explicitly
    setting the initial key focus which is zeroed if/when the actor is destroyed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=663437

 js/ui/modalDialog.js |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/modalDialog.js b/js/ui/modalDialog.js
index f731f57..6109b32 100644
--- a/js/ui/modalDialog.js
+++ b/js/ui/modalDialog.js
@@ -98,6 +98,7 @@ const ModalDialog = new Lang.Class({
 
         global.focus_manager.add_group(this._dialogLayout);
         this._initialKeyFocus = this._dialogLayout;
+        this._initialKeyFocusDestroyId = 0;
         this._savedKeyFocus = null;
     },
 
@@ -134,8 +135,7 @@ const ModalDialog = new Lang.Class({
             else
                 x_alignment = St.Align.MIDDLE;
 
-            if (this._initialKeyFocus == this._dialogLayout ||
-                this._buttonLayout.contains(this._initialKeyFocus))
+            if (!this._initialKeyFocusDestroyId)
                 this._initialKeyFocus = buttonInfo.button;
             this._buttonLayout.add(buttonInfo.button,
                                    { expand: true,
@@ -205,7 +205,15 @@ const ModalDialog = new Lang.Class({
     },
 
     setInitialKeyFocus: function(actor) {
+        if (this._initialKeyFocusDestroyId)
+            this._initialKeyFocus.disconnect(this._initialKeyFocusDestroyId);
+
         this._initialKeyFocus = actor;
+
+        this._initialKeyFocusDestroyId = actor.connect('destroy', Lang.bind(this, function() {
+            this._initialKeyFocus = this._dialogLayout;
+            this._initialKeyFocusDestroyId = 0;
+        }));
     },
 
     open: function(timestamp) {



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