[orca] Event Manager: Don't switch scripts for activate on already-active window



commit 04be36dedac21fe7d8a058bfc8fd9b1e69f2bd60
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Jun 14 12:44:38 2021 +0200

    Event Manager: Don't switch scripts for activate on already-active window
    
    If we receive a window:activate and/or state-changed:active event on a
    window after we've received a focus event (or figured out focus on our
    own), we don't want to switch scripts. While in most cases doing so has
    no impact, there are times when the script for the window is not the
    same as the script for the focused object. This is true for apps which
    embed WebKitGtk and terminal applications.
    
    Therefore, only switch applications when we get window activation for
    a window which is not already the active window. This solves a recent
    regression introduced by d261ce21e and should also solve a similar
    problem which users report has been around a while.

 src/orca/event_manager.py           | 14 ++++++++++----
 src/orca/scripts/terminal/script.py |  2 ++
 2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/orca/event_manager.py b/src/orca/event_manager.py
index e1f81cee8..43ced69cc 100644
--- a/src/orca/event_manager.py
+++ b/src/orca/event_manager.py
@@ -704,12 +704,18 @@ class EventManager:
             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"
+            windowActivation = True
+        else:
+            windowActivation = eType.startswith('object:state-changed:active') \
+                and event.detail1 and role == pyatspi.ROLE_FRAME
 
-        if eType.startswith('object:state-changed:active') and event.detail1 \
-           and role == pyatspi.ROLE_FRAME:
-            return True, "Window is becoming active."
+        if windowActivation:
+            if event.source != orca_state.activeWindow:
+                return True, "Window activation"
+            else:
+                return False, "Window activation for already-active window"
 
         if eType.startswith('focus') \
            or (eType.startswith('object:state-changed:focused')
diff --git a/src/orca/scripts/terminal/script.py b/src/orca/scripts/terminal/script.py
index 3a4896b0c..a4d2bd9ee 100644
--- a/src/orca/scripts/terminal/script.py
+++ b/src/orca/scripts/terminal/script.py
@@ -82,6 +82,8 @@ class Script(default.Script):
         """Callback for object:text-changed:insert accessibility events."""
 
         if not self.utilities.treatEventAsCommand(event):
+            msg = "TERMINAL: Passing along event to default script."
+            debug.println(debug.LEVEL_INFO, msg, True)
             super().onTextInserted(event)
             return
 


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