mate-desktop / marco

MATE default window manager
https://mate-desktop.org
GNU General Public License v2.0
192 stars 85 forks source link

Marco window lacks accessible "active" state, makes Orca laggy in Alt+Tab #771

Closed joanmarie closed 1 month ago

joanmarie commented 4 months ago

Steps to reproduce:

  1. Open several windows
  2. Put the following accessible-event listener script in a file, then launch it in a terminal:
#!/usr/bin/python3

import pyatspi

def listener(e):
    try:
        if e.source.getApplication().name.lower() != "marco":
            return
    except:
        return

    window = pyatspi.findAncestor(e.source, lambda x: x and x.getRole() == pyatspi.ROLE_WINDOW)
    if window:
        isActive = f"container {window} is active: {bool(window.getState().contains(pyatspi.STATE_ACTIVE))}"
    else:
        isActive = "containing window not found"
    print(f"'{e.any_data}' {isActive}")

pyatspi.Registry.registerEventListener(listener, "object:text-changed:insert")
pyatspi.Registry.start()
  1. Alt+Tab to switch among the open windows

Expected results: As the listener prints out the current switcher item, it would state that the switcher window is active.

Actual results: As the listener prints out the current switcher item, it would state that the switcher window is not active.

Sample output:

$ ./marco.py 
'jd@builder:~/Desktop' container [window | ] is active: False
'marco.py (~/Desktop) - gedit' container [window | ] is active: False
'debug.out (~) - gedit' container [window | ] is active: False
'Synergy 3 RC3 - v3.0.77.2-rc3' container [window | ] is active: False
'Unsaved Document 1 - Pluma' container [window | ] is active: False
'marco.py (~/Desktop) - gedit' container [window | ] is active: False
'debug.out (~) - gedit' container [window | ] is active: False
'Synergy 3 RC3 - v3.0.77.2-rc3' container [window | ] is active: False
'Unsaved Document 1 - Pluma' container [window | ] is active: False
'jd@builder:~/Desktop' container [window | ] is active: False
'marco.py (~/Desktop) - gedit' container [window | ] is active: False
'debug.out (~) - gedit' container [window | ] is active: False
'Synergy 3 RC3 - v3.0.77.2-rc3' container [window | ] is active: False
'Unsaved Document 1 - Pluma' container [window | ] is active: False
'jd@builder:~/Desktop' container [window | ] is active: False
'marco.py (~/Desktop) - gedit' container [window | ] is active: False
'debug.out (~) - gedit' container [window | ] is active: False
'Synergy 3 RC3 - v3.0.77.2-rc3' container [window | ] is active: False

Impact: Orca is laggy when users press Alt+Tab. The reason why is that Orca checks (and if need be, searches for) the active window. It does this in order to ensure the correct script is being applied to the accessible event. Unfortunately, when using MATE + Marco, the active window is the switcher. But it lacks the active state. So Orca checks every single open window to find the active one. It fails because none of the other windows are active; the Marco window is. But Orca doesn't know that.

It would be great if this could be fixed in Marco. I (the Orca maintainer) am removing hacks/workarounds from Orca and don't plan to add new ones.

@cwendling: Could you please verify -- and ideally fix -- this issue? Thanks in advance!!

cwendling commented 4 months ago

@joanmarie I can confirm the behavior, and I trust you that it's a problem for Orca :) FWIW, the underlying reason is that the window doesn't actually have keyboard focus, as it's all done through grabs.

Anyhow, could you give #773 a try to see if I'm actually going something useful? If so, I'll clean it up at tad, but I'd rather do that on something that actually works :) FWIW (again) your sample listener is happy now (for me), but I didn't check with the latest Orca to see if there's anything actually visible in that regard, and I trust you'd see it a lot more reliably than I could without spending a lot more time understanding the Orca issue more deeply.