vcl/source/window/dockmgr.cxx |    8 ++++++++
 1 file changed, 8 insertions(+)

New commits:
commit 0008ff3597e9d89481d5fccb5cefa7f058400a43
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Aug 18 15:32:12 2023 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Aug 18 20:13:55 2023 +0200

    tdf#141101 a11y: Ensure focused event after showing popup content
    
    If the `FloatWinPopupFlags::GrabFocus` flag is set,
    don't only pass it to `FloatingWindow::StartPopupMode`,
    but explicitly grab focus again after showing the
    docking window (client window of the floating window).
    
    At least proper handling for accessible focus/focused
    events depends on the window being visible at the point
    it receives focus.
    
    For winaccessibility, the a11y event listener only
    gets registered once the window gets shown
    (`VCLXAccessibleComponent::ProcessWindowChildEvent`
    forwards a `VclEventId::WindowShow` as
    `accessibility::AccessibleEventId::CHILD` event, which
    winaccessibility then processes and registers an
    event listener for the new child).
    
    This makes NVDA on Windows announce focus for the
    "Automatic" button in the color popup in Writer's
    character style dialog also when the popup shows
    for the first time.
    
    Change-Id: I2e4028eb4ec68a8b586cbd1a0dc5351d1453937e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155843
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx
index ba9aa2aa9450..7cde1910fed3 100644
--- a/vcl/source/window/dockmgr.cxx
+++ b/vcl/source/window/dockmgr.cxx
@@ -823,6 +823,10 @@ void ImplDockingWindowWrapper::StartPopupMode( ToolBox 
*pParentToolBox, FloatWin
 
     mpFloatWin->StartPopupMode( pParentToolBox, nFlags );
     GetWindow()->Show();
+    // grab focus (again) after showing docking window, as e.g. a11y focus
+    // events require window to be visible first
+    if (nFlags & FloatWinPopupFlags::GrabFocus)
+        mpFloatWin->GrabFocus();
 
     if( pParentToolBox->IsKeyEvent() )
     {
@@ -841,6 +845,10 @@ void ImplDockingWindowWrapper::StartPopupMode( const 
tools::Rectangle& rRect, Fl
     ImplPreparePopupMode();
     mpFloatWin->StartPopupMode( rRect, nFlags );
     GetWindow()->Show();
+    // grab focus (again) after showing docking window, as e.g. a11y focus
+    // events require window to be visible first
+    if (nFlags & FloatWinPopupFlags::GrabFocus)
+        mpFloatWin->GrabFocus();
 }
 
 IMPL_LINK_NOARG(ImplDockingWindowWrapper, PopupModeEnd, FloatingWindow*, void)

Reply via email to