[orca] Add option to control automatic focus mode during native navigation



commit 49dc924dc4fa932bf5fee8981c01040ba0d09b16
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Aug 19 12:13:23 2020 +0200

    Add option to control automatic focus mode during native navigation
    
    Orca already has options to automatically enter focus mode when caret
    navigation and/or structural navigation result in moving to a focus-mode
    widget. However, when native browser navigation (e.g. Tab) is used, we
    assumed the user wanted native browser commands (e.g. typing in the
    newly-focused input) to just work. Turns out we were wrong.
    
    This commit adds a new setting to the app-specific preferences for
    Gecko-based apps and Chrome/Chromium which makes it possible for users
    to turn off automatically entering focus mode for native navigation.
    Auto switching remains on by default so as not to change the user
    experience.

 help/C/introduction.page                           |  6 ++--
 help/C/preferences_text_attributes.page            |  2 +-
 ...preferences_gecko.page => preferences_web.page} | 37 ++++++++++++++++++----
 help/Makefile.am                                   |  2 +-
 src/orca/guilabels.py                              | 15 +++++++++
 src/orca/scripts/web/script.py                     | 20 ++++++++++--
 src/orca/settings.py                               |  2 ++
 7 files changed, 68 insertions(+), 16 deletions(-)
---
diff --git a/help/C/introduction.page b/help/C/introduction.page
index fb8aed040..79caf6fdf 100644
--- a/help/C/introduction.page
+++ b/help/C/introduction.page
@@ -24,10 +24,8 @@
     <app>Orca</app> works with applications and toolkits that support
     the Assistive Technology Service Provider Interface (AT-SPI), which
     is the primary assistive technology infrastructure for Linux and
-    Solaris. Applications and toolkits supporting the AT-SPI include the
-    GNOME Gtk+ toolkit, the Java platform's Swing toolkit, LibreOffice,
-    Gecko, and WebKitGtk. AT-SPI support for the KDE Qt toolkit is being
-    pursued.
+    Solaris. Applications and toolkits supporting the AT-SPI include
+    Gtk+, Qt, Java Swing, LibreOffice, Gecko, WebKitGtk, and Chrome/Chromium.
   </p>
   <section id="launching">
     <title>Launching <app>Orca</app></title>
diff --git a/help/C/preferences_text_attributes.page b/help/C/preferences_text_attributes.page
index aff84bfc2..517c1d0ce 100644
--- a/help/C/preferences_text_attributes.page
+++ b/help/C/preferences_text_attributes.page
@@ -2,7 +2,7 @@
       id="preferences_text_attributes">
   <info>
     <link type="guide" xref="preferences#orca" />
-    <link type="next" xref="preferences_gecko" />
+    <link type="next" xref="preferences_web" />
     <link type="seealso" xref="howto_text_attributes" />
     <title type="sort">8. Text Attributes</title>
     <title type="link">Text Attributes</title>
diff --git a/help/C/preferences_gecko.page b/help/C/preferences_web.page
similarity index 84%
rename from help/C/preferences_gecko.page
rename to help/C/preferences_web.page
index 20723bb69..6b9954850 100644
--- a/help/C/preferences_gecko.page
+++ b/help/C/preferences_web.page
@@ -1,12 +1,12 @@
-<page xmlns="http://projectmallard.org/1.0/"; type="topic" id="preferences_gecko">
+<page xmlns="http://projectmallard.org/1.0/"; type="topic" id="preferences_web">
   <info>
     <link type="guide" xref="preferences#application" />
     <link type="next" xref="preferences_table_navigation" />
-    <title type="sort">1. Gecko Navigation</title>
-    <title type="link">Gecko Navigation</title>
+    <title type="sort">1. Web Navigation</title>
+    <title type="link">Web Navigation</title>
     <desc>
-      Configuring <app>Orca</app>'s support for <app>Firefox</app> and
-      <app>Thunderbird</app>
+      Configuring <app>Orca</app>'s support for <app>Firefox</app>,
+      <app>Thunderbird</app>, and <app>Chrome</app>/<app>Chromium</app>
     </desc>
     <credit type="author">
       <name>Joanmarie Diggs</name>
@@ -16,7 +16,7 @@
       <p>Creative Commons Share Alike 3.0</p>
     </license>
   </info>
-  <title>Gecko Navigation Preferences</title>
+  <title>Web Navigation Preferences</title>
   <section id="page_navigation">
     <title>Page Navigation</title>
     <p>
@@ -29,7 +29,7 @@
       <p>
         This checkbox toggles <app>Orca</app>'s caret navigation on and off.
         When it is on, <app>Orca</app> takes control of the caret as you arrow
-        around within a page; when it is off, Gecko's native caret navigation is
+        around within a page; when it is off, the browser's native caret navigation is
         active.
       </p>
       <p>
@@ -109,6 +109,29 @@
         </p>
        </note>
     </section>
+    <section id="page_navigation_focus_native">
+      <title>Automatic focus mode during native navigation</title>
+      <p>
+        If this checkbox is checked, <app>Orca</app> will automatically turn on
+        focus mode when you use native browser navigation commands to navigate to a
+        form field. For example, pressing <key>Tab</key> to move to the next entry
+        would move focus there and also turn focus mode on so that your next press
+        of <key>E</key> would type an "e" into that entry. If this checkbox is not
+        checked, then <app>Orca</app> will leave you in browse mode and your next
+        press of <key>E</key> would move you to the next entry on the page.
+      </p>
+      <p>
+        Default value: checked
+      </p>
+      <note style="tip">
+        <title>Manually switching between browse mode and focus mode</title>
+        <p>
+          In order to start or stop interacting with the focused form field,
+          use <keyseq><key>Orca Modifier</key><key>A</key></keyseq> to switch
+          between browse mode and focus mode.
+        </p>
+       </note>
+    </section>
     <section id="page_navigation_speak">
       <title>Automatically start speaking a page when it is first loaded</title>
       <p>
diff --git a/help/Makefile.am b/help/Makefile.am
index 259e0c7df..7a975dfb2 100644
--- a/help/Makefile.am
+++ b/help/Makefile.am
@@ -45,7 +45,7 @@ HELP_FILES = \
        introduction.page \
        preferences_braille.page \
        preferences_chat.page \
-       preferences_gecko.page \
+       preferences_web.page \
        preferences_general.page \
        preferences_introduction.page \
        preferences_key_bindings.page \
diff --git a/src/orca/guilabels.py b/src/orca/guilabels.py
index e19e78ab0..cd78dd6d9 100644
--- a/src/orca/guilabels.py
+++ b/src/orca/guilabels.py
@@ -75,6 +75,21 @@ AUTO_FOCUS_MODE_STRUCT_NAV = _("Automatic focus mode during structural navigatio
 # of the entry.
 AUTO_FOCUS_MODE_CARET_NAV = _("Automatic focus mode during caret navigation")
 
+# Translators: Orca has a number of commands that override the default behavior
+# within an application. For instance, if you are at the bottom of an entry and
+# press Down arrow, should you leave the entry? It depends on if you want to
+# resume reading content or if you are editing the text in the entry. Because
+# Orca doesn't know what you want to do, it has two modes: In browse mode, Orca
+# treats key presses as commands to read the content; in focus mode, Orca treats
+# key presses as something that should be handled by the focused widget. Orca
+# optionally can attempt to detect which mode is appropriate for the current
+# situation and switch automatically. This string is a label for a GUI option to
+# enable such automatic switching when native navigation commands are used.
+# Here "native" means "not Orca"; it could be a browser navigation command such
+# as the Tab key, or it might be a web page behavior, such as the search field
+# automatically gaining focus when the page loads.
+AUTO_FOCUS_MODE_NATIVE_NAV = _("Automatic focus mode during native navigation")
+
 # Translators: A single braille cell on a refreshable braille display consists
 # of 8 dots. Dot 7 is the dot in the bottom left corner. If the user selects 
 # this option, Dot 7 will be used to 'underline' text of interest, e.g. when
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index 83afb0594..90f0c57af 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -103,6 +103,7 @@ class Script(default.Script):
         self._structuralNavigationCheckButton = None
         self._autoFocusModeStructNavCheckButton = None
         self._autoFocusModeCaretNavCheckButton = None
+        self._autoFocusModeNativeNavCheckButton = None
         self._layoutModeCheckButton = None
 
         self.attributeNamesDict["invalid"] = "text-spelling"
@@ -359,23 +360,29 @@ class Script(default.Script):
         self._autoFocusModeStructNavCheckButton.set_active(value)
         generalGrid.attach(self._autoFocusModeStructNavCheckButton, 0, 3, 1, 1)
 
+        label = guilabels.AUTO_FOCUS_MODE_NATIVE_NAV
+        value = _settingsManager.getSetting('nativeNavTriggersFocusMode')
+        self._autoFocusModeNativeNavCheckButton = Gtk.CheckButton.new_with_mnemonic(label)
+        self._autoFocusModeNativeNavCheckButton.set_active(value)
+        generalGrid.attach(self._autoFocusModeNativeNavCheckButton, 0, 4, 1, 1)
+
         label = guilabels.READ_PAGE_UPON_LOAD
         value = _settingsManager.getSetting('sayAllOnLoad')
         self._sayAllOnLoadCheckButton = Gtk.CheckButton.new_with_mnemonic(label)
         self._sayAllOnLoadCheckButton.set_active(value)
-        generalGrid.attach(self._sayAllOnLoadCheckButton, 0, 4, 1, 1)
+        generalGrid.attach(self._sayAllOnLoadCheckButton, 0, 5, 1, 1)
 
         label = guilabels.PAGE_SUMMARY_UPON_LOAD
         value = _settingsManager.getSetting('pageSummaryOnLoad')
         self._pageSummaryOnLoadCheckButton = Gtk.CheckButton.new_with_mnemonic(label)
         self._pageSummaryOnLoadCheckButton.set_active(value)
-        generalGrid.attach(self._pageSummaryOnLoadCheckButton, 0, 5, 1, 1)
+        generalGrid.attach(self._pageSummaryOnLoadCheckButton, 0, 6, 1, 1)
 
         label = guilabels.CONTENT_LAYOUT_MODE
         value = _settingsManager.getSetting('layoutMode')
         self._layoutModeCheckButton = Gtk.CheckButton.new_with_mnemonic(label)
         self._layoutModeCheckButton.set_active(value)
-        generalGrid.attach(self._layoutModeCheckButton, 0, 6, 1, 1)
+        generalGrid.attach(self._layoutModeCheckButton, 0, 7, 1, 1)
 
         tableFrame = Gtk.Frame()
         grid.attach(tableFrame, 0, 1, 1, 1)
@@ -487,6 +494,7 @@ class Script(default.Script):
             'structNavTriggersFocusMode': self._autoFocusModeStructNavCheckButton.get_active(),
             'caretNavigationEnabled': self._controlCaretNavigationCheckButton.get_active(),
             'caretNavTriggersFocusMode': self._autoFocusModeCaretNavCheckButton.get_active(),
+            'nativeNavTriggersFocusMode': self._autoFocusModeNativeNavCheckButton.get_active(),
             'speakCellCoordinates': self._speakCellCoordinatesCheckButton.get_active(),
             'layoutMode': self._layoutModeCheckButton.get_active(),
             'speakCellSpan': self._speakCellSpanCheckButton.get_active(),
@@ -822,6 +830,12 @@ class Script(default.Script):
             debug.println(debug.LEVEL_INFO, msg, True)
             return False
 
+        if not _settingsManager.getSetting('nativeNavTriggersFocusMode') \
+           and not (self._lastCommandWasStructNav or self._lastCommandWasCaretNav):
+            msg = "WEB: Not using focus mode due to native nav settings"
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return False
+
         if self.utilities.isFocusModeWidget(obj):
             msg = "WEB: Using focus mode because %s is a focus mode widget" % obj
             debug.println(debug.LEVEL_INFO, msg, True)
diff --git a/src/orca/settings.py b/src/orca/settings.py
index 691346cb3..e930893c7 100644
--- a/src/orca/settings.py
+++ b/src/orca/settings.py
@@ -128,6 +128,7 @@ userCustomizableSettings = [
     "structNavTriggersFocusMode",
     "caretNavTriggersFocusMode",
     "layoutMode",
+    "nativeNavTriggersFocusMode",
     "rewindAndFastForwardInSayAll",
     "structNavInSayAll",
     "speakDescription",
@@ -391,6 +392,7 @@ timeoutCallback         = None # Set by orca.py:init to orca.timeout
 
 structNavTriggersFocusMode = False
 caretNavTriggersFocusMode = False
+nativeNavTriggersFocusMode = True
 
 layoutMode = True
 


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