Re: AT-SPI standard's management of text objects

Ksamak <[email protected]> Mon, 21 Nov 2016 16:00:05 +0100
Newsgroups gmane.comp.gnome.accessibility.general
Message-ID <[email protected]>
Edit: of course, i forgot the attachment script.
My bad.

On Mon, Nov 21, 2016 at 03:57:16PM +0100, Ksamak wrote:
> 
> I have made a script, relying on python-pyatspi, that can demonstrate an
> example case of what i'm trying to describe.
> This script is based on magfocustracker.py from the examples in pyatspi
> project. It simply outputs the caret position and size, from atspi
> events "object:text-caret-moved"
> 
> I'll describe a couple use cases that in my opinion are faulty:
> - open firefox, type alt-d to go in address bar, then delete all text
>   in the field (backspace should suffice)
>       what happens =>  an event with 0,0 0x0 (no width/height, no position)
>       what should happen => an event with the caret size, placed at the
>       screen position of the caret.
>       note: behaviour is the same for any textarea, or entry in HTML
>       forms
> 
> - open a new, empty libreoffice-writer document, the caret is at start
>   of document.
>       what happens => an event with 0,0 0x0
>       what should happen => an event with the caret size, placed at the screen position of the caret.
> 
> - open a libreoffice-writer document, press return
>       what happens => an event with -1,-1,-1,-1 (it's the whole widget's position, we can ignore it)
>                       an event with 0,0 0x0
>                       another event with 0,0 0x0
>       what should happen => an event with the caret size, placed at the screen position of the caret.
>       note: one can write a paragraph, then press enter, the same
>       will happen
> 
> Tests have been made under debian mate jessie.
> I think one can easily understand how a magnifier, tracked with this
> would jump at random places of the screen, and be really confusing and
> annoying for visually disabled people.
> 
> I'd be glad for any help you can think of to resolve this issue.
> -- 
> Ksamak
> Free software hacktivist



-- 
Ksamak
Free software hacktivist

_______________________________________________
gnome-accessibility-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gnome-accessibility-list
buggy_caret_tracking_demo_script.py (text/plain, 1.3 KB)
#!/usr/bin/python

import pyatspi
import sys

def magnifyAccessible(event, obj=None, extents=None):
    if event.source and event.source.getRole() == pyatspi.ROLE_TERMINAL: # protection against parasite events from terminals
        return

    if event.type.startswith("object:state-changed") and not event.detail1:
        # This object just became unselected or unfocused, and we're not
        # big on nostalgia.
        return

    obj = obj or event.source

    x, y, width, height = -1,-1,-1,-1
    if event and event.type.startswith("object:text-caret-moved"):
        try:
            text = obj.queryText()
            if text and (text.caretOffset >= 0):
                offset = text.caretOffset
                if offset == text.characterCount:
                    offset -= 1
                [x, y, width, height] = text.getCharacterExtents(offset, 0)
        except:
            pass

        print "position: %i,%i size %i:%s" %(x, y, width, height)

def startTracking():
    pyatspi.Registry.registerEventListener(magnifyAccessible, "object:text-caret-moved")

def stopTracking():
    pyatspi.Registry.deregisterEventListener(magnifyAccessible, "object:text-caret-moved")

def main():
    startTracking()
    pyatspi.Registry.start()
    return 0

if __name__ == "__main__":
    sys.exit(main())
signature.asc (application/pgp-signature, 801 B)
-----BEGIN PGP SIGNATURE-----

iQIcBAEBCgAGBQJYMwv0AAoJEBTZQpGAfVCWCSgQAOPuCJjRB48WRhKXfFvw82Nz
o0CrsDneGxyjsOtAcup65cO6UTdl2wk7Lt0Fd0BKWyL2kW7G74vcQCqT7pCL6/7S
ajClJ8oafeVGeTZnetHzjX1CqomPB2iPS457cytEhTXOVcqjFcTd7YiMqrhrSLYh
jCXXRMfmTWuHBoEkyX/+xsTvAfGRBHcZXt4MAKel9MnSOWvGhc2+OMbeiJgPtKm9
yZx4RxxzZlvSvnPEH+wOOxbJ/NUi8Kn8Fs0i2tLJxWiO7ZIYIVYGLvVZK0ei1VtS
/5E1B8t6tQ9zYDJP4cjJ5HXuxEUSc5jFfIuqYRpqccccbUrV0Nr3u7Vd16Zhhenq
EErOpp/64+goPILNTfYyEmYi/vbgJiY2G4SggM13pKf/LA39oL33IVMiluD9NlhH
KaVJk/pc5M1Utdb35cIFXK1I/0pvUqk9zeVQtyNMhT5XcQoK30dLHhpplXMmVv1b
3SFPiydsrmXCDJ+3kwzOpW40QSQ22pPuFIysg22z9HWAKbbUD4cC3OG88nVCTkKp
bQDA3BUH3mqCqw1iDnn0fRd4TR6MRWBk1ZSfEakDqrLnEI4BwvDsdGTHY5T5vjYY
KHZGx3/ujI+UMiXsCSv760th22/YhF0LS6cf+lcsAcbb9j6H2jwNnPXL78kKmSyd
Gi5Ker2dAnYclnku34Tn
=dgV6
-----END PGP SIGNATURE-----