[orca: 1/2] Make double-orca work only within 0.5s



commit bd2a9fdaf111087fb613d6ebe3dc1dd859a16fa5
Author: Samuel Thibault <samuel thibault ens-lyon org>
Date:   Mon Jul 16 12:07:15 2018 +0200

    Make double-orca work only within 0.5s
    
    So that isolated orca presses are just ignored.

 src/orca/input_event.py | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/src/orca/input_event.py b/src/orca/input_event.py
index 5e6f0ea48..fe8892ba8 100644
--- a/src/orca/input_event.py
+++ b/src/orca/input_event.py
@@ -70,8 +70,12 @@ class KeyboardEvent(InputEvent):
 
     # Whether last press of the Orca modifier was alone
     lastOrcaModifierAlone = False
+    lastOrcaModifierAloneTime = None
     # Whether the current press of the Orca modifier is alone
     currentOrcaModifierAlone = False
+    currentOrcaModifierAloneTime = None
+    # When the second orca press happened
+    secondOrcaModifierTime = None
 
     TYPE_UNKNOWN          = "unknown"
     TYPE_PRINTABLE        = "printable"
@@ -154,8 +158,10 @@ class KeyboardEvent(InputEvent):
         if not self.isOrcaModifier():
             if KeyboardEvent.orcaModifierPressed:
                 KeyboardEvent.currentOrcaModifierAlone = False
+                KeyboardEvent.currentOrcaModifierAloneTime = None
             else:
                 KeyboardEvent.lastOrcaModifierAlone = False
+                KeyboardEvent.lastOrcaModifierAloneTime = None
 
         if self.isNavigationKey():
             self.keyType = KeyboardEvent.TYPE_NAVIGATION
@@ -167,17 +173,24 @@ class KeyboardEvent(InputEvent):
             self.keyType = KeyboardEvent.TYPE_MODIFIER
             self.shouldEcho = _mayEcho and settings.enableModifierKeys
             if self.isOrcaModifier():
+                now = time.time()
                 if KeyboardEvent.lastOrcaModifierAlone:
-                    # double-orca, let the real action happen
-                    self._bypassOrca = True
+                    if _isPressed:
+                        KeyboardEvent.secondOrcaModifierTime = now
+                    if KeyboardEvent.secondOrcaModifierTime < KeyboardEvent.lastOrcaModifierAloneTime + 0.5:
+                        # double-orca, let the real action happen
+                        self._bypassOrca = True
                     if not _isPressed:
                         KeyboardEvent.lastOrcaModifierAlone = False
+                        KeyboardEvent.lastOrcaModifierAloneTime = False
                 else:
                     KeyboardEvent.orcaModifierPressed = _isPressed
                     if _isPressed:
                         KeyboardEvent.currentOrcaModifierAlone = True
+                        KeyboardEvent.currentOrcaModifierAloneTime = now
                     else:
                         KeyboardEvent.lastOrcaModifierAlone = KeyboardEvent.currentOrcaModifierAlone
+                        KeyboardEvent.lastOrcaModifierAloneTime = KeyboardEvent.currentOrcaModifierAloneTime
         elif self.isFunctionKey():
             self.keyType = KeyboardEvent.TYPE_FUNCTION
             self.shouldEcho = _mayEcho and settings.enableFunctionKeys


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