From 262b27cb80ecc501d06ae6a8a8e6eca45866f151 Mon Sep 17 00:00:00 2001 From: Leonard de Ruijter Date: Wed, 20 Sep 2023 07:36:25 +0200 Subject: [PATCH] Fix more cases of grand child window focus failures (#15455) Closes #15432 Summary of the issue: Some events for grand child windows in applications seem to be ignored. Description of user facing changes Focus changes are reported in these cases. Description of development approach Generalize the workaround that was expanded for Edge in #15300 --- source/eventHandler.py | 20 ++++++-------------- user_docs/en/changes.t2t | 2 +- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/source/eventHandler.py b/source/eventHandler.py index 7ac85b04deb..6dbed8fc3c2 100755 --- a/source/eventHandler.py +++ b/source/eventHandler.py @@ -498,22 +498,14 @@ def shouldAcceptEvent(eventName, windowHandle=None): return True fg = winUser.getForegroundWindow() - fgClassName=winUser.getClassName(fg) + # #5504, #14916, #15432 : Some windows, such as in the Office ribbon or Edge downloads window + # aren't directly beneath the foreground window, so our foreground application checks fail. + # However, they share the same root owner and events for them should be allowed. if ( - # #5504: In Office >= 2013 with the ribbon showing only tabs, - # when a tab is expanded, the window we get from the focus object is incorrect. - # This window isn't beneath the foreground window. - wClass == "NetUIHWND" and fgClassName in ("Net UI Tool Window Layered", "Net UI Tool Window") - or ( - # #14916: The context menu in the Edge download window isn't beneath the foreground window. - wClass == fgClassName - and wClass.startswith("Chrome_WidgetWin_") and fgClassName.startswith("Chrome_WidgetWin_") - ) + winUser.getAncestor(windowHandle, winUser.GA_ROOTOWNER) + == winUser.getAncestor(fg, winUser.GA_ROOTOWNER) ): - # Our foreground application checks fail. - # Just compare the root owners. - if winUser.getAncestor(windowHandle, winUser.GA_ROOTOWNER) == winUser.getAncestor(fg, winUser.GA_ROOTOWNER): - return True + return True if (winUser.isDescendantWindow(fg, windowHandle) # #3899, #3905: Covers cases such as the Firefox Page Bookmarked window and OpenOffice/LibreOffice context menus. or winUser.isDescendantWindow(fg, winUser.getAncestor(windowHandle, winUser.GA_ROOTOWNER))): diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index 0d91287c987..c58c7c96d23 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -58,7 +58,6 @@ There's also been bug fixes for the Add-on Store, Microsoft Office, Microsoft Ed - Some shortcut keys have been updated in the NVDA menu. (#15364) - - == Bug Fixes == - Microsoft Office: - Fixed crash in Microsoft Word when Document formatting options "report headings" and "report comments and notes" were not enabled. (#15019) @@ -82,6 +81,7 @@ There's also been bug fixes for the Add-on Store, Microsoft Office, Microsoft Ed - - Fixed support for System List view (``SysListView32``) controls in Windows Forms applications. (#15283) - NVDA once again announces calculation results in the Windows 32bit calculator on Server, LTSC and LTSB versions of Windows. (#15230) +- NVDA no longer ignores focus changes when a nested window (grand child window) gets focus. (#15432) - == Changes for Developers ==