[gnome-shell] dialog: Fix setting buttons as initial key focus
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] dialog: Fix setting buttons as initial key focus
- Date: Wed, 4 Oct 2017 16:27:35 +0000 (UTC)
commit 0b02f757f862d0d292e57f68179440f2a0bd572c
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Sep 28 12:38:33 2017 +0200
dialog: Fix setting buttons as initial key focus
Commit 1c7a3ee61b1892 broke setting the initial key focus for default
buttons added via addButton(). Fix this by allowing the dialog class
to provide a different default widget to ModalDialog than the entire
dialog itself.
https://bugzilla.gnome.org/show_bug.cgi?id=788282
js/ui/dialog.js | 7 ++++++-
js/ui/modalDialog.js | 7 ++++---
2 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/dialog.js b/js/ui/dialog.js
index 3fdc3ef..781fe0a 100644
--- a/js/ui/dialog.js
+++ b/js/ui/dialog.js
@@ -15,6 +15,7 @@ var Dialog = new Lang.Class({
this.parent({ layout_manager: new Clutter.BinLayout() });
this.connect('destroy', Lang.bind(this, this._onDestroy));
+ this._initialKeyFocus = null;
this._pressedKey = null;
this._buttonKeys = {};
this._createDialog();
@@ -86,6 +87,10 @@ var Dialog = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
+ get initialKeyFocus() {
+ return this._initialKeyFocus || this;
+ },
+
addContent: function (actor) {
this.contentLayout.add (actor, { expand: true });
},
@@ -116,7 +121,7 @@ var Dialog = new Lang.Class({
if (isDefault)
button.add_style_pseudo_class('default');
- if (!this._initialKeyFocusDestroyId)
+ if (this._initialKeyFocus == null || isDefault)
this._initialKeyFocus = button;
for (let i in keys)
diff --git a/js/ui/modalDialog.js b/js/ui/modalDialog.js
index 1547b89..0e66e03 100644
--- a/js/ui/modalDialog.js
+++ b/js/ui/modalDialog.js
@@ -84,7 +84,7 @@ var ModalDialog = new Lang.Class({
}
global.focus_manager.add_group(this.dialogLayout);
- this._initialKeyFocus = this.dialogLayout;
+ this._initialKeyFocus = null;
this._initialKeyFocusDestroyId = 0;
this._savedKeyFocus = null;
},
@@ -157,7 +157,7 @@ var ModalDialog = new Lang.Class({
this._initialKeyFocus = actor;
this._initialKeyFocusDestroyId = actor.connect('destroy', Lang.bind(this, function() {
- this._initialKeyFocus = this.dialogLayout;
+ this._initialKeyFocus = null;
this._initialKeyFocusDestroyId = 0;
}));
},
@@ -237,7 +237,8 @@ var ModalDialog = new Lang.Class({
this._savedKeyFocus.grab_key_focus();
this._savedKeyFocus = null;
} else {
- this._initialKeyFocus.grab_key_focus();
+ let focus = this._initialKeyFocus || this.dialogLayout.initialKeyFocus;
+ focus.grab_key_focus();
}
if (!this._shellReactive)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]