Skip to content

Commit

Permalink
Fix context menu focus for Edge downloads (#15300)
Browse files Browse the repository at this point in the history
Fixes #14916

Summary of the issue:
When opening the context menu from the Edge downloads window, NVDA doesn't reflect this.

Description of user facing changes
Context menu is read again.

Description of development approach
It looks like the context menu items aren't direct children of the foreground window, therefore we compare the root of the foreground and the root of the focus window instead.
Fixed a typo in a UIAHandler debug string
Ensured that UIAHandler.getNearestWindowHandle returns when a cached window handle couldn't be fetched from an UIAElement due to a COMError.
  • Loading branch information
LeonarddeR authored Aug 21, 2023
1 parent 7bbf168 commit 9e8e419
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
8 changes: 6 additions & 2 deletions source/UIAHandler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ def getNearestWindowHandle(self, UIAElement):
return windowHandle
if _isDebug():
log.debug(
" locating nearest ancestor windowHandle "
"Locating nearest ancestor windowHandle "
f"for element {self.getUIAElementDebugString(UIAElement)}"
)
try:
Expand Down Expand Up @@ -1232,7 +1232,11 @@ def getNearestWindowHandle(self, UIAElement):
try:
window = new.cachedNativeWindowHandle
except COMError:
window = None
if _isDebug():
log.debugWarning(
"Unable to get cachedNativeWindowHandle from found ancestor element", exc_info=True
)
return None
if _isDebug():
log.debug(
"Found ancestor element "
Expand Down
13 changes: 10 additions & 3 deletions source/eventHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,18 @@ def shouldAcceptEvent(eventName, windowHandle=None):

fg = winUser.getForegroundWindow()
fgClassName=winUser.getClassName(fg)
if wClass == "NetUIHWND" and fgClassName in ("Net UI Tool Window Layered","Net UI Tool Window"):
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,
# so our foreground application checks fail.
# 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_")
)
):
# 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
Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ What's New in NVDA
- NVDA will no longer jump back to the last browse mode position when opening the context menu in Microsoft Edge. (#15309)
- Fixed support for System List view (``SysListView32``) controls in Windows Forms applications. (#15283)
- NVDA will no longer be sluggish in rich edit controls when braille is enabled, such as in MemPad. (#14285)
- NVDA is once again able to read context menus of downloads in Microsoft Edge. (#14916)
-

== Changes for Developers ==
Expand Down

0 comments on commit 9e8e419

Please sign in to comment.