[polari/wip/fmuellner/server-password: 1/4] entryArea: Don't grab focus unconditionally when becoming sensitive
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/server-password: 1/4] entryArea: Don't grab focus unconditionally when becoming sensitive
- Date: Tue, 2 Feb 2016 22:55:36 +0000 (UTC)
commit e141af165657e2a0ff2423b6a9967a5db14889be
Author: Florian Müllner <fmuellner gnome org>
Date: Tue Feb 2 22:05:15 2016 +0100
entryArea: Don't grab focus unconditionally when becoming sensitive
Our current idea for supporting server passwords is to allow users to
enter a password on authentication errors using the header popovers in
the room list. As this may happen while the active room is connecting,
we should make sure to not steal the focus while the user is typing
her password.
https://bugzilla.gnome.org/show_bug.cgi?id=709824
src/entryArea.js | 29 +++++++++++------------------
1 files changed, 11 insertions(+), 18 deletions(-)
---
diff --git a/src/entryArea.js b/src/entryArea.js
index a8377de..fab010c 100644
--- a/src/entryArea.js
+++ b/src/entryArea.js
@@ -155,17 +155,16 @@ const EntryArea = new Lang.Class({
this._completion.setCompletions(nicks);
},
- _onKeyPressEvent: function(w, event) {
- if (!this._chatEntry.get_mapped())
- return Gdk.EVENT_PROPAGATE;
-
- if (!this.sensitive)
- return Gdk.EVENT_PROPAGATE;
-
- if (this._chatEntry.has_focus)
- return Gdk.EVENT_PROPAGATE;
+ _canFocusChatEntry: function() {
+ let toplevelFocus = this._chatEntry.get_toplevel().get_focus();
+ return this.sensitive &&
+ this._chatEntry.get_mapped() &&
+ !this._chatEntry.has_focus &&
+ !(toplevelFocus instanceof Gtk.Entry);
+ },
- if (this._chatEntry.get_toplevel().get_focus() instanceof Gtk.Entry)
+ _onKeyPressEvent: function(w, event) {
+ if (!this._canFocusChatEntry())
return Gdk.EVENT_PROPAGATE;
let [, keyval] = event.get_keyval();
@@ -210,14 +209,8 @@ const EntryArea = new Lang.Class({
},
_onSensitiveChanged: function() {
- if (!this.sensitive)
- return;
-
- Mainloop.idle_add(Lang.bind(this,
- function() {
- this._chatEntry.grab_focus();
- return GLib.SOURCE_REMOVE;
- }));
+ if (this._canFocusChatEntry())
+ this._chatEntry.grab_focus();
},
_onChannelChanged: function(room) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]