[orca] Make triggering of focus mode by structural navigation optional



commit 81a1c8cc5a178a402744956b5187c5182fb14c90
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Aug 11 08:09:32 2014 -0400

    Make triggering of focus mode by structural navigation optional

 src/orca/scripts/toolkits/Gecko/script.py |   27 +++++++++++++++++++++++----
 src/orca/settings.py                      |    4 ++++
 2 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index bc9482b..1ae42a3 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -236,6 +236,9 @@ class Script(default.Script):
 
         self._inFocusMode = False
 
+        self._lastCommandWasCaretNav = False
+        self._lastCommandWasStructNav = False
+
         # See bug 665522 - comment 5
         app.setCacheMask(pyatspi.cache.DEFAULT ^ pyatspi.cache.CHILDREN)
 
@@ -654,23 +657,35 @@ class Script(default.Script):
         if user_bindings:
             handler = user_bindings.getInputHandler(keyboardEvent)
             if handler and handler.function in self._caretNavigationFunctions:
-                return self.useCaretNavigationModel(keyboardEvent)
+                consumes = self.useCaretNavigationModel(keyboardEvent)
+                self._lastCommandWasCaretNav = consumes
+                self._lastCommandWasStructNav = False
             elif handler \
                  and (handler.function in self.structuralNavigation.functions \
                       or handler.function in self._liveRegionFunctions):
-                return self.useStructuralNavigationModel()
+                consumes = self.useStructuralNavigationModel()
+                self._lastCommandWasCaretNav = False
+                self._lastCommandWasStructNav = consumes
             else:
                 consumes = handler != None
+                self._lastCommandWasCaretNav = False
+                self._lastCommandWasStructNav = False
         if not consumes:
             handler = self.keyBindings.getInputHandler(keyboardEvent)
             if handler and handler.function in self._caretNavigationFunctions:
-                return self.useCaretNavigationModel(keyboardEvent)
+                consumes = self.useCaretNavigationModel(keyboardEvent)
+                self._lastCommandWasCaretNav = consumes
+                self._lastCommandWasStructNav = False
             elif handler \
                  and (handler.function in self.structuralNavigation.functions \
                       or handler.function in self._liveRegionFunctions):
-                return self.useStructuralNavigationModel()
+                consumes = self.useStructuralNavigationModel()
+                self._lastCommandWasCaretNav = False
+                self._lastCommandWasStructNav = consumes
             else:
                 consumes = handler != None
+                self._lastCommandWasCaretNav = False
+                self._lastCommandWasStructNav = False
         return consumes
 
     def textLines(self, obj):
@@ -1223,6 +1238,10 @@ class Script(default.Script):
             default.Script.handleProgressBarUpdate(self, event, obj)
 
     def _useFocusMode(self, obj):
+        if not orca.settings.structNavTriggersFocusMode \
+           and self._lastCommandWasStructNav:
+            return False
+
         try:
             role = obj.getRole()
             state = obj.getState()
diff --git a/src/orca/settings.py b/src/orca/settings.py
index dde127f..d4502bd 100644
--- a/src/orca/settings.py
+++ b/src/orca/settings.py
@@ -356,3 +356,7 @@ sounds = {}
 # TODO - JD: Is this still needed now that AT-SPI has its own timeout?
 timeoutTime             = 10   # a value of 0 means don't do hang checking
 timeoutCallback         = None # Set by orca.py:init to orca.timeout
+
+# NOTE: At the moment items here are experimental and may be changed or
+# replaced or removed.
+structNavTriggersFocusMode = True


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