Skip to content

Commit 8fe411e

Browse files
authored
Merge a43ecda into 5b70588
2 parents 5b70588 + a43ecda commit 8fe411e

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

source/watchdog.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# A part of NonVisual Desktop Access (NVDA)
2-
# Copyright (C) 2008-2021 NV Access Limited
2+
# Copyright (C) 2008-2024 NV Access Limited, Cyrille Bougot
33
# This file is covered by the GNU General Public License.
44
# See the file COPYING for more details.
55

@@ -25,6 +25,7 @@
2525
import exceptions
2626
import NVDAHelper
2727
import NVDAState
28+
from NVDAObjects.window import Window
2829

2930

3031
def __getattr__(attrName: str) -> Any:
@@ -205,12 +206,13 @@ def _shouldRecoverAfterMinTimeout():
205206
return True
206207
if winUser.getClassName(info.hwndFocus) in safeWindowClassSet:
207208
return False
208-
if not winUser.isDescendantWindow(info.hwndActive, api.getFocusObject().windowHandle):
209+
focus = api.getFocusObject()
210+
if (not isinstance(focus, Window)) or (not winUser.isDescendantWindow(info.hwndActive, focus.windowHandle)):
209211
# The foreground window has changed.
210212
return True
211213
newHwnd=info.hwndFocus
212214
newThreadID=winUser.getWindowThreadProcessID(newHwnd)[1]
213-
return newThreadID!=api.getFocusObject().windowThreadID
215+
return newThreadID != focus.windowThreadID
214216

215217
def _recoverAttempt():
216218
try:

0 commit comments

Comments
 (0)