Skip to content

Commit 08177c1

Browse files
authored
Merge 0f2f46b into 6fc6637
2 parents 6fc6637 + 0f2f46b commit 08177c1

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

source/appModules/explorer.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,21 @@ def _get_TextInfo(cls):
195195
return cls.TextInfo
196196

197197

198+
class WorkerW(IAccessible):
199+
def event_gainFocus(self):
200+
# #6671: Normally we do not allow WorkerW thread to send gain focus event,
201+
# as it causes 'pane" to be announced when minimizing windows or moving to desktop.
202+
# However when closing Windows 7 Start Menu in some cases
203+
# focus lands on it instead of the focused desktop item.
204+
# Therefore redirect it to the child which is a desktop in this case.
205+
if eventHandler.isPendingEvents("gainFocus"):
206+
return
207+
if self.firstChild:
208+
self.firstChild.setFocus()
209+
return
210+
super().event_gainFocus()
211+
212+
198213
class AppModule(appModuleHandler.AppModule):
199214

200215
def chooseNVDAObjectOverlayClasses(self, obj, clsList):
@@ -247,6 +262,10 @@ def chooseNVDAObjectOverlayClasses(self, obj, clsList):
247262
clsList.insert(0, MetadataEditField)
248263
return # Optimization: return early to avoid comparing class names and roles that will never match.
249264

265+
if windowClass== "WorkerW" and role == controlTypes.ROLE_PANE and obj.name is None:
266+
clsList.insert(0, WorkerW)
267+
return # Optimization: return early to avoid comparing class names and roles that will never match.
268+
250269
if isinstance(obj, UIA):
251270
uiaClassName = obj.UIAElement.cachedClassName
252271
if uiaClassName == "GridTileElement":
@@ -330,10 +349,6 @@ def event_gainFocus(self, obj, nextHandler):
330349
# #8137: also seen when opening quick link menu (Windows+X) on Windows 8 and later.
331350
return
332351

333-
if wClass == "WorkerW" and obj.role == controlTypes.ROLE_PANE and obj.name is None:
334-
# #6671: Never allow WorkerW thread to send gain focus event, as it causes 'pane" to be announced when minimizing windows or moving to desktop.
335-
return
336-
337352
nextHandler()
338353

339354
def isGoodUIAWindow(self, hwnd):

0 commit comments

Comments
 (0)