[orca/gnome-3-28] Release device when braille is deactivated for some applications



commit 6e38ac8aaf1a46fbfa9c8342735e996df0408a9c
Author: Samuel Thibault <samuel thibault ens-lyon org>
Date:   Tue Apr 3 14:34:32 2018 -0400

    Release device when braille is deactivated for some applications
    
    https://bugzilla.gnome.org/show_bug.cgi?id=794937

 src/orca/braille.py |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/braille.py b/src/orca/braille.py
index 7920f7b..2974108 100644
--- a/src/orca/braille.py
+++ b/src/orca/braille.py
@@ -54,6 +54,8 @@ except:
     _brlAPIRunning = False
 
 from . import settings
+from . import settings_manager
+_settingsManager = settings_manager.getManager()
 
 try:
     # This can fail due to gtk not being available.  We want to
@@ -1091,6 +1093,19 @@ def refresh(panToCursor=True,
     if stopFlash:
         killFlash(restoreSaved=False)
 
+    if not _settingsManager.getSetting('enableBraille'):
+        if _brlAPIRunning:
+            try:
+                _brlAPI.writeText("", 0)
+            except:
+                debug.println(debug.LEVEL_WARNING,
+                              "BrlTTY seems to have disappeared:")
+                debug.printException(debug.LEVEL_WARNING)
+            # In this case we always shut it down
+            shutdown()
+        _lastTextInfo = (None, 0, 0, 0)
+        return
+
     if len(_lines) == 0:
         if not _brlAPIRunning:
             init(_callback, settings.tty)
@@ -1102,6 +1117,7 @@ def refresh(panToCursor=True,
                               "BrlTTY seems to have disappeared:")
                 debug.printException(debug.LEVEL_WARNING)
                 shutdown()
+            # In this case we just leave the display with empty text
         _lastTextInfo = (None, 0, 0, 0)
         return
 
@@ -1688,6 +1704,7 @@ def shutdown():
     was run.
     """
 
+    global _brlAPI
     global _brlAPIRunning
     global _brlAPISourceId
     global _monitor
@@ -1701,6 +1718,11 @@ def shutdown():
             _brlAPI.leaveTtyMode()
         except:
             pass
+        try:
+            _brlAPI.closeConnection()
+        except:
+            pass
+        _brlAPI = None
         if _monitor:
             _monitor.destroy()
             _monitor = None


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