[gnome-shell/gnome-3-6] modalDialog: Fix auto-completion of prompts immediately upon display



commit ee6f60bc936743db364cd1562f58b195fcb491da
Author: Atri <badshah400 gmail com>
Date:   Sun Feb 24 18:55:53 2013 +0530

    modalDialog: Fix auto-completion of prompts immediately upon display
    
    Shell modal dialogs can take their action on a certain key's
    key-release-event. For example on <enter> the affirmative action is
    usually run.
    
    Make sure that the key was also pressed on the dialog and we're not
    seeing a spurious key-release-event from a key that was pressed before
    the dialog was displayed. Rebased original patch for master by Stef
    Walter to version 3.6.3.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=692937

 js/ui/modalDialog.js |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/modalDialog.js b/js/ui/modalDialog.js
index 71fbfc7..a7d6ae7 100644
--- a/js/ui/modalDialog.js
+++ b/js/ui/modalDialog.js
@@ -57,7 +57,9 @@ const ModalDialog = new Lang.Class({
 
         this._group.connect('destroy', Lang.bind(this, this._onGroupDestroy));
 
+        this._pressedKey = null;
         this._actionKeys = {};
+        this._group.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
         this._group.connect('key-release-event', Lang.bind(this, this._onKeyReleaseEvent));
 
         this._backgroundBin = new St.Bin();
@@ -186,8 +188,18 @@ const ModalDialog = new Lang.Class({
 
     },
 
+    _onKeyPressEvent: function(object, event) {
+        this._pressedKey = event.get_key_symbol();
+    },
+
     _onKeyReleaseEvent: function(object, event) {
+        let pressedKey = this._pressedKey;
+        this._pressedKey = null;
+
         let symbol = event.get_key_symbol();
+        if (symbol != pressedKey)
+            return false;
+
         let action = this._actionKeys[symbol];
 
         if (action) {


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