[gnome-shell] dialog: Reset initial focus on destroy



commit 100d6a7fa7aa28ded1a1a1d89f34061ea3084703
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Oct 5 10:06:10 2017 +0200

    dialog: Reset initial focus on destroy
    
    Since 0b02f757f862 we track the button that should have key focus
    when the dialog is opened. However when the dialog is reused, the
    button may get destroyed - clear the initial focus in that case to
    allow setButton() to set a new one.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788542

 js/ui/dialog.js |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/dialog.js b/js/ui/dialog.js
index 781fe0a..090ef2f 100644
--- a/js/ui/dialog.js
+++ b/js/ui/dialog.js
@@ -16,6 +16,7 @@ var Dialog = new Lang.Class({
         this.connect('destroy', Lang.bind(this, this._onDestroy));
 
         this._initialKeyFocus = null;
+        this._initialKeyFocusDestroyId = 0;
         this._pressedKey = null;
         this._buttonKeys = {};
         this._createDialog();
@@ -87,6 +88,18 @@ var Dialog = new Lang.Class({
         return Clutter.EVENT_PROPAGATE;
     },
 
+    _setInitialKeyFocus: function(actor) {
+        if (this._initialKeyFocus)
+            this._initialKeyFocus.disconnect(this._initialKeyFocusDestroyId);
+
+        this._initialKeyFocus = actor;
+
+        this._initialKeyFocusDestroyId = actor.connect('destroy', () => {
+            this._initialKeyFocus = null;
+            this._initialKeyFocusDestroyId = 0;
+        });
+    },
+
     get initialKeyFocus() {
         return this._initialKeyFocus || this;
     },
@@ -122,7 +135,7 @@ var Dialog = new Lang.Class({
             button.add_style_pseudo_class('default');
 
         if (this._initialKeyFocus == null || isDefault)
-            this._initialKeyFocus = button;
+            this._setInitialKeyFocus(button);
 
         for (let i in keys)
             this._buttonKeys[keys[i]] = buttonInfo;


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