Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore duplicate focus events emitted by Windows 7 desktop items #10419

Merged
merged 1 commit into from Oct 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 17 additions & 6 deletions source/appModules/explorer.py
Expand Up @@ -20,7 +20,7 @@
import eventHandler
import mouseHandler
from NVDAObjects.window import Window
from NVDAObjects.IAccessible import sysListView32, IAccessible, List
from NVDAObjects.IAccessible import IAccessible, List
from NVDAObjects.UIA import UIA
from NVDAObjects.window.edit import RichEdit50, EditTextInfo

Expand Down Expand Up @@ -55,16 +55,18 @@ class SearchBoxClient(IAccessible):


# Class for menu items for Windows Places and Frequently used Programs (in start menu)
class SysListView32MenuItem(sysListView32.ListItemWithoutColumnSupport):
# Also used for desktop items
class SysListView32EmittingDuplicateFocusEvents(IAccessible):

# #474: When focus moves to these items, an extra focus is fired on the parent
# However NVDA redirects it to the real focus.
# But this means double focus events on the item, so filter the second one out
# #2988: Also seen when coming back to the Windows 7 desktop from different applications.
def _get_shouldAllowIAccessibleFocusEvent(self):
res=super(SysListView32MenuItem,self).shouldAllowIAccessibleFocusEvent
res = super().shouldAllowIAccessibleFocusEvent
if not res:
return False
focus=eventHandler.lastQueuedFocusObject
focus = eventHandler.lastQueuedFocusObject
if type(focus)!=type(self) or (self.event_windowHandle,self.event_objectID,self.event_childID)!=(focus.event_windowHandle,focus.event_objectID,focus.event_childID):
return True
return False
Expand Down Expand Up @@ -221,8 +223,17 @@ def chooseNVDAObjectOverlayClasses(self, obj, clsList):
clsList.insert(0, ReadOnlyEditBox)
return # Optimization: return early to avoid comparing class names and roles that will never match.

if windowClass == "SysListView32" and role == controlTypes.ROLE_MENUITEM:
clsList.insert(0, SysListView32MenuItem)
if windowClass == "SysListView32":
if(
role == controlTypes.ROLE_MENUITEM
or(
role == controlTypes.ROLE_LISTITEM
and obj.simpleParent
and obj.simpleParent.simpleParent
and obj.simpleParent.simpleParent == api.getDesktopObject()
)
):
clsList.insert(0, SysListView32EmittingDuplicateFocusEvents)
return # Optimization: return early to avoid comparing class names and roles that will never match.

# #5178: Start button in Windows 8.1 and 10 should not have been a list in the first place.
Expand Down