vcl/source/window/accessibility.cxx |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

New commits:
commit ef1eedc76bf8ad0d34a76645e46823d70dd9f59b
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Aug 13 14:52:47 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Aug 13 21:31:24 2024 +0200

    vcl a11y: Report "top-level"'s frame again
    
    If a top-level windows has a border window that's
    a frame as parent, report that again as the a11y parent,
    which was no longer the case after
    
        commit 97d3baf3f92c4ab3e5dbd5a9c585dd1a1ad2b3d5
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Fri Aug 9 15:59:28 2024 +0200
    
            vcl a11y: Don't report parent window for top-levels
    
    Other than the "Save document?" case described in
    the commit message of that commit, where the dialog
    parent is actually a completely different window
    (the LO Writer main window), the "top-level" window's
    frame actually contains the top-level (i.e. they do belong
    to the same window on the platform level), and the frame
    does report the top level as an accessible child, so
    it's consistent to report the parent the other way
    around, too.
    
    This e.g. makes Accerciser's "Inspect under mouse" feature
    work again on Wayland with Accerciser's "kwin" backend
    for e.g. the "Format" -> "Paragraph" dialog in Writer,
    while still working for the "Save Document?" dialog case
    the above-mentioned commit addressed.
    
    It still seems a little odd that the "Paragraph" object
    in the a11y tree with "dialogue" role still has a parent
    of the same name with a "frame" role when using the qt6
    VCL plugin, as can be seen in Accerciser.
    (The "dialogue" AT-SPI role is meant to be an actual
    top-level with no additional parents, and that's the
    way it actually is for the same dialog when using the
    gtk3 VCL plugin using native GTK widgets.)
    
    That's a different story, however. For now,
    report the parent again to have a consistent a11y
    hierarchy.
    
    Change-Id: I07cf287aaf3effbcda0bb4982aafb0fa4bf4f22f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171825
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/source/window/accessibility.cxx 
b/vcl/source/window/accessibility.cxx
index c61c9e7e9ab7..fb18ed81986e 100644
--- a/vcl/source/window/accessibility.cxx
+++ b/vcl/source/window/accessibility.cxx
@@ -100,9 +100,20 @@ bool Window::ImplIsAccessibleCandidate() const
 
 vcl::Window* Window::GetAccessibleParentWindow() const
 {
-    if (!mpWindowImpl || IsNativeFrame() || IsTopWindow())
+    if (!mpWindowImpl || IsNativeFrame())
         return nullptr;
 
+    if (IsTopWindow())
+    {
+        // if "top-level" has native border window parent, report it;
+        // but don't report parent otherwise (which could e.g. be
+        // a dialog's parent window that's otherwise a separate window and
+        // doesn't consider the top level its a11y child either)
+        if (mpWindowImpl->mpBorderWindow && 
mpWindowImpl->mpBorderWindow->IsNativeFrame())
+            return mpWindowImpl->mpBorderWindow;
+        return nullptr;
+    }
+
     vcl::Window* pParent = mpWindowImpl->mpParent;
     if( GetType() == WindowType::MENUBARWINDOW )
     {

Reply via email to