svx/source/accessibility/charmapacc.cxx |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 790730a9b7651a1883d887f5b628f8f2b1e5e3a0
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Feb 24 15:54:51 2023 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Feb 24 22:29:27 2023 +0000

    a11y: Fix focused state for special char dialog item
    
    As mentioned/worked around in Colomban's pending Gerrit change
    to implement an a11y test for the "Special Characters" dialog [1],
    the selected item in the character table was incorrectly still
    reporting the "focused" state even if keyboard focus already
    moved on from the parent widget to another one.
    
    Fix this by checking the item is not only selected, but its
    parent also has child focus.
    
    Tested by running this pyatspi script after a sleep and using
    the time before the script actually runs to interact with the
    dialog to test the different scenarios for the focused state,
    using the "!" character in the dialog):
    
        #!/usr/bin/python3
        import pyatspi
        def get_soffice_app():
            registry = pyatspi.registry.Registry()
            apps = list(registry.getDesktop(0))
            for app in apps:
                if app.name == 'soffice' or app.name == 'soffice.bin':
                    return app
            print("soffice app not found")
            exit(1)
        def get_exclamation_mark_button(acc):
            i = 0
            while i < acc.get_child_count():
                child = acc.get_child_at_index(i)
                try:
                    if child.name == '!':
                        return child
                except NotImplementedError:
                    pass
                recursive_child = get_exclamation_mark_button(child)
                if recursive_child:
                    return recursive_child
                i = i + 1
            return None
        app = get_soffice_app()
        obj = get_exclamation_mark_button(app)
        assert obj
        states = obj.get_state_set().get_states()
        print("states:")
        print(states)
    
    [1] 
https://gerrit.libreoffice.org/c/core/+/142260/22/sw/qa/extras/accessibility/dialogs.cxx
    
    Change-Id: I277890105e3ff84ed35100b7cd7dc2ff40510921
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147660
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/svx/source/accessibility/charmapacc.cxx 
b/svx/source/accessibility/charmapacc.cxx
index d6c8b4b49216..61cf9ca853e1 100644
--- a/svx/source/accessibility/charmapacc.cxx
+++ b/svx/source/accessibility/charmapacc.cxx
@@ -483,7 +483,8 @@ sal_Int64 SAL_CALL 
SvxShowCharSetItemAcc::getAccessibleStateSet()
         if( mpParent->mrParent.GetSelectIndexId() == mpParent->mnId )
         {
             nStateSet |= css::accessibility::AccessibleStateType::SELECTED;
-            nStateSet |= css::accessibility::AccessibleStateType::FOCUSED;
+            if (mpParent->mrParent.HasChildFocus())
+                nStateSet |= css::accessibility::AccessibleStateType::FOCUSED;
         }
         if ( mpParent->mnId >= mpParent->mrParent.FirstInView() && 
mpParent->mnId <= mpParent->mrParent.LastInView() )
         {

Reply via email to