[orca] Give scripts ability to insist upon activation; use for switcher



commit 76260cdb664a113bed0c985e6b20c397f3d16aed
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Thu Mar 7 16:03:01 2019 +0100

    Give scripts ability to insist upon activation; use for switcher

 src/orca/event_manager.py           | 3 +++
 src/orca/script.py                  | 5 +++++
 src/orca/scripts/switcher/script.py | 6 +++---
 3 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/src/orca/event_manager.py b/src/orca/event_manager.py
index d621788f9..67cd06ee3 100644
--- a/src/orca/event_manager.py
+++ b/src/orca/event_manager.py
@@ -639,6 +639,9 @@ class EventManager:
         if not script.isActivatableEvent(event):
             return False, "The script says not to activate for this event."
 
+        if script.forceScriptActivation(event):
+            return True, "The script insists it should be activated for this event."
+
         eType = event.type
         if eType.startswith('window:activate'):
             return True, "window:activate event"
diff --git a/src/orca/script.py b/src/orca/script.py
index 7366be50c..2ebb6da3c 100644
--- a/src/orca/script.py
+++ b/src/orca/script.py
@@ -542,6 +542,11 @@ class Script:
         """
         return True
 
+    def forceScriptActivation(self, event):
+        """Allows scripts to insist that they should become active."""
+
+        return False
+
     def activate(self):
         """Called when this script is activated."""
         pass
diff --git a/src/orca/scripts/switcher/script.py b/src/orca/scripts/switcher/script.py
index ca6986080..f4680304d 100644
--- a/src/orca/scripts/switcher/script.py
+++ b/src/orca/scripts/switcher/script.py
@@ -46,13 +46,13 @@ class Script(default.Script):
 
         return Utilities(self)
 
-    def isActivatableEvent(self, event):
-        """Returns True if this event should activate this script."""
+    def forceScriptActivation(self, event):
+        """Allows scripts to insist that they should become active."""
 
         if self.utilities.isSwitcherSelectionChangeEventType(event):
             return True
 
-        return super().isActivatableEvent(event)
+        return super().forceScriptActivation(event)
 
     def _handleSwitcherEvent(self, event):
         """Presents the currently selected item, if appropriate."""


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