Skip to content

Commit 24fab6b

Browse files
authored
Merge dc51c4e into 87f7870
2 parents 87f7870 + dc51c4e commit 24fab6b

4 files changed

Lines changed: 27 additions & 13 deletions

File tree

source/NVDAObjects/__init__.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,17 +1481,20 @@ def _get_devInfo(self) -> typing.List[str]: # noqa: C901
14811481
info.extend(self.appModule.devInfo)
14821482
return info
14831483

1484-
def _get_sleepMode(self):
1484+
# Typing information for auto property _get_sleepMode
1485+
sleepMode: bool
1486+
1487+
# Don't cache sleepMode, as it is derived from a property which might change
1488+
# and we want the changed value immediately.
1489+
_cache_sleepMode = False
1490+
1491+
def _get_sleepMode(self) -> bool:
14851492
"""Whether NVDA should sleep for this object (e.g. it is self-voicing).
14861493
If C{True}, all events and script requests for this object are silently dropped.
1487-
@rtype: bool
14881494
"""
14891495
if self.appModule:
14901496
return self.appModule.sleepMode
14911497
return False
1492-
# Don't cache sleepMode, as it is derived from a property which might change
1493-
# and we want the changed value immediately.
1494-
_cache_sleepMode = False
14951498

14961499
def _get_mathMl(self):
14971500
"""Obtain the MathML markup for an object containing math content.

source/api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"""
1010

1111
import typing
12+
from NVDAObjects.window import Window
1213

1314
import config
1415
import textInfos
@@ -111,7 +112,8 @@ def setFocusObject(obj: NVDAObjects.NVDAObject) -> bool: # noqa: C901
111112
log.error(
112113
"Never ending focus ancestry:"
113114
f" last object: {tempObj.name}, {controlTypes.Role(tempObj.role).displayString},"
114-
f" window class {tempObj.windowClassName}, application name {tempObj.appModule.appName}"
115+
f" window class {tempObj.windowClassName if isinstance(tempObj, Window) else type(tempObj)}, "
116+
f"application name {tempObj.appModule.appName}"
115117
)
116118
except:
117119
pass

source/eventHandler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,10 @@ def executeEvent(
309309
sleepMode = obj.sleepMode
310310
# Handle possible virtual desktop name change event.
311311
# More effective in Windows 10 Version 1903 and later.
312+
from NVDAObjects.window import Window
312313
if (
313314
eventName == "nameChange"
315+
and isinstance(obj, Window)
314316
and obj.windowClassName == "#32769"
315317
and _canAnnounceVirtualDesktopNames
316318
):

source/keyboardHandler.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# -*- coding: UTF-8 -*-
2-
# keyboardHandler.py
32
# A part of NonVisual Desktop Access (NVDA)
43
# This file is covered by the GNU General Public License.
54
# See the file COPYING for more details.
@@ -8,7 +7,6 @@
87
"""Keyboard support"""
98

109
import ctypes
11-
import sys
1210
import time
1311
import re
1412
import typing
@@ -19,7 +17,6 @@
1917
Any,
2018
)
2119

22-
import wx
2320
import winVersion
2421
import winUser
2522
import vkCodes
@@ -28,7 +25,6 @@
2825
import ui
2926
from keyLabels import localizedKeyLabels
3027
from logHandler import log
31-
import queueHandler
3228
import config
3329
from config.configFlags import NVDAKey
3430
import api
@@ -41,6 +37,7 @@
4137
import threading
4238

4339
if typing.TYPE_CHECKING:
40+
from NVDAObjects import NVDAObject # noqa: F401
4441
from watchdog import WatchdogObserver
4542

4643
_watchdogObserver: typing.Optional["WatchdogObserver"] = None
@@ -136,20 +133,30 @@ def getNVDAModifierKeys() -> List[Tuple[int, Optional[bool]]]:
136133
return keys
137134

138135

139-
def shouldUseToUnicodeEx(focus=None):
136+
def shouldUseToUnicodeEx(focus: Optional["NVDAObject"] = None):
140137
"Returns whether to use ToUnicodeEx to determine typed characters."
141138
if not focus:
142139
focus = api.getFocusObject()
140+
from NVDAObjects.window import Window
143141
from NVDAObjects.behaviors import KeyboardHandlerBasedTypedCharSupport
144142
return (
145143
# This is only possible in Windows 10 1607 and above
146144
winVersion.getWinVer() >= winVersion.WIN10_1607
147145
and ( # Either of
148146
# We couldn't inject in-process, and its not a legacy console window without keyboard support.
149147
# console windows have their own specific typed character support.
150-
(not focus.appModule.helperLocalBindingHandle and focus.windowClassName != 'ConsoleWindowClass')
148+
(
149+
not focus.appModule.helperLocalBindingHandle
150+
and (
151+
not isinstance(focus, Window)
152+
or focus.windowClassName != 'ConsoleWindowClass'
153+
)
154+
)
151155
# or the focus is within a UWP app, where WM_CHAR never gets sent
152-
or focus.windowClassName.startswith('Windows.UI.Core')
156+
or (
157+
not isinstance(focus, Window)
158+
or focus.windowClassName.startswith('Windows.UI.Core')
159+
)
153160
# Or this is a console with keyboard support, where WM_CHAR messages are doubled
154161
or isinstance(focus, KeyboardHandlerBasedTypedCharSupport)
155162
)

0 commit comments

Comments
 (0)