[orca] Move presentation of keyboard events to the script



commit 5fe35be0e85a9ff3886591e695bcc0a35777db87
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon May 26 12:56:30 2014 -0400

    Move presentation of keyboard events to the script

 src/orca/input_event.py     |   48 -------------------------------------------
 src/orca/orca.py            |   15 ++++++++-----
 src/orca/scripts/default.py |   37 +++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 54 deletions(-)
---
diff --git a/src/orca/input_event.py b/src/orca/input_event.py
index 49db46a..ebb9ce7 100644
--- a/src/orca/input_event.py
+++ b/src/orca/input_event.py
@@ -377,54 +377,6 @@ class KeyboardEvent(InputEvent):
 
         return False
 
-    def present(self):
-        """Presents the event via the appropriate medium/media. Returns True
-        if we presented the event. False if there was some reason the event
-        was not worthy of presentation."""
-
-        if not orca_state.learnModeEnabled:
-            if self.shouldEcho == False or self.isOrcaModified():
-                return False
-
-        try:
-            role = orca_state.locusOfFocus.getRole()
-        except:
-            return False
-
-        if role == pyatspi.ROLE_PASSWORD_TEXT:
-            return False
-
-        # Worst. Hack. EVER. We have no reliable way of knowing a password is
-        # being entered into a terminal -- other than the fact that the text
-        # typed ain't there. As a result, we have to do special things when
-        # not in special modes. :( See bgo 668025.
-        if role == pyatspi.ROLE_TERMINAL:
-            if not self.isPressedKey():
-                try:
-                    text = orca_state.locusOfFocus.queryText()
-                    o = text.caretOffset
-                    string = text.getText(o-1, o)
-                except:
-                    pass
-                else:
-                    if not self.event_string in [string, 'space']:
-                        return False
-            elif not (orca_state.learnModeEnabled or self.isLockingKey()):
-                return False
-
-        elif not self.isPressedKey():
-            return False
-
-        orca_state.lastKeyEchoTime = time.time()
-        debug.println(debug.LEVEL_FINEST,
-                      "KeyboardEvent.present: %s" % self.event_string)
-
-        script = orca_state.activeScript
-        if script:
-            return script.presentKeyboardEvent(self)
-
-        return False
-
 class BrailleEvent(InputEvent):
 
     def __init__(self, event):
diff --git a/src/orca/orca.py b/src/orca/orca.py
index ba1bbb9..0a15c63 100644
--- a/src/orca/orca.py
+++ b/src/orca/orca.py
@@ -240,12 +240,15 @@ def _processKeyboardEvent(event):
 
     # Echo it based on what it is and the user's settings.
     script = orca_state.activeScript
-    if script:
-        if isPressedEvent:
-            script.presentationInterrupt()
-        keyboardEvent.present()
-        if keyboardEvent.isModifierKey() and not isOrcaModifier:
-            return False
+    if not script:
+        debug.println(debug.LEVEL_FINE, "IGNORING EVENT DUE TO NO SCRIPT")
+        return False
+
+    if isPressedEvent:
+        script.presentationInterrupt()
+    script.presentKeyboardEvent(keyboardEvent)
+    if keyboardEvent.isModifierKey() and not isOrcaModifier:
+        return False
  
     # Special modes.
     if not isPressedEvent and keyboardEvent.event_string == "Escape":
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index a93e3e5..2d1ae54 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -4143,6 +4143,43 @@ class Script(script.Script):
         """Convenience method to present the KeyboardEvent event. Returns True
         if we fully present the event; False otherwise."""
 
+        if not orca_state.learnModeEnabled:
+            if event.shouldEcho == False or event.isOrcaModified():
+                return False
+
+        try:
+            role = orca_state.locusOfFocus.getRole()
+        except:
+            return False
+
+        if role == pyatspi.ROLE_PASSWORD_TEXT:
+            return False
+
+        # Worst. Hack. EVER. We have no reliable way of knowing a password is
+        # being entered into a terminal -- other than the fact that the text
+        # typed ain't there. As a result, we have to do special things when
+        # not in special modes. :( See bgo 668025.
+        if role == pyatspi.ROLE_TERMINAL:
+            if not event.isPressedKey():
+                try:
+                    text = orca_state.locusOfFocus.queryText()
+                    o = text.caretOffset
+                    string = text.getText(o-1, o)
+                except:
+                    pass
+                else:
+                    if not event.event_string in [string, 'space']:
+                        return False
+            elif not (orca_state.learnModeEnabled or event.isLockingKey()):
+                return False
+
+        elif not event.isPressedKey():
+            return False
+
+        orca_state.lastKeyEchoTime = time.time()
+        debug.println(debug.LEVEL_FINEST,
+                      "Script.presentKeyboardEvent: %s" % event.event_string)
+
         braille.displayKeyEvent(event)
         orcaModifierPressed = event.isOrcaModifier() and event.isPressedKey()
         if event.isCharacterEchoable() and not orcaModifierPressed:


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