Skip to content

Commit 07fe7f0

Browse files
authored
Merge 2f40832 into c4d6fb5
2 parents c4d6fb5 + 2f40832 commit 07fe7f0

19 files changed

Lines changed: 264 additions & 78 deletions

source/COMRegistrationFixes/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def fixCOMRegistrations():
6060
Registers most common COM proxies, in case they had accidentally been unregistered or overwritten by 3rd party software installs/uninstalls.
6161
"""
6262
is64bit=os.environ.get("PROCESSOR_ARCHITEW6432","").endswith('64')
63-
OSMajorMinor=winVersion.winVersion[:2]
63+
winVer = winVersion.getWinVer()
64+
OSMajorMinor = (winVer.major, winVer.minor)
6465
log.debug("Fixing COM registration for Windows %s.%s, %s"%(OSMajorMinor[0],OSMajorMinor[1],"64 bit" if is64bit else "32 bit"))
6566
# Commands taken from NVDA issue #2807 comment https://github.com/nvaccess/nvda/issues/2807#issuecomment-320149243
6667
# OLEACC (MSAA) proxies

source/NVDAObjects/IAccessible/winConsole.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import config
77

88
from NVDAObjects.behaviors import KeyboardHandlerBasedTypedCharSupport
9-
from winVersion import isWin10
9+
from winVersion import getWinVer, WIN10_1607
1010

1111
from . import IAccessible
1212
from ..window import winConsole
@@ -39,7 +39,7 @@ def _get_diffAlgo(self):
3939

4040

4141
def findExtraOverlayClasses(obj, clsList):
42-
if isWin10(1607) and config.conf['terminals']['keyboardSupportInLegacy']:
42+
if getWinVer() >= WIN10_1607 and config.conf['terminals']['keyboardSupportInLegacy']:
4343
clsList.append(EnhancedLegacyWinConsole)
4444
else:
4545
clsList.append(LegacyWinConsole)

source/NVDAObjects/UIA/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def __init__(self,obj,position,_rangeObj=None):
334334
# sometimes rangeFromChild can return a NULL range
335335
if not self._rangeObj: raise LookupError
336336
elif isinstance(position,locationHelper.Point):
337-
if (winVersion.winVersion.major, winVersion.winVersion.minor) == (6, 1):
337+
if winVersion.getWinVer() <= winVersion.WIN7_SP1:
338338
# #9435: RangeFromPoint causes a freeze in UIA client library in the Windows 7 start menu!
339339
raise NotImplementedError("RangeFromPoint not supported on Windows 7")
340340
self._rangeObj=self.obj.UIATextPattern.RangeFromPoint(position.toPOINT())

source/NVDAObjects/UIA/edge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def _getTextWithFieldsForUIARange(self,rootElement,textRange,formatConfig,includ
419419

420420
class EdgeNode(UIA):
421421

422-
_edgeIsPreGapRemoval=winVersion.winVersion.build<15048
422+
_edgeIsPreGapRemoval = winVersion.getWinVer().build < 15048
423423

424424
_TextInfo=EdgeTextInfo_preGapRemoval if _edgeIsPreGapRemoval else EdgeTextInfo
425425

source/_UIAHandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
localEventHandlerGroupUIAEventIds = set()
189189

190190
autoSelectDetectionAvailable = False
191-
if winVersion.isWin10():
191+
if winVersion.getWinVer() >= winVersion.WIN10:
192192
UIAEventIdsToNVDAEventNames.update({
193193
UIA.UIA_Text_TextChangedEventId: "textChange",
194194
UIA.UIA_Text_TextSelectionChangedEventId: "caret",

source/appModuleHandler.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,7 @@ def _setProductInfo(self):
389389
if not self.processHandle:
390390
raise RuntimeError("processHandle is 0")
391391
# No need to worry about immersive (hosted) apps and friends until Windows 8.
392-
# Python 3.7 introduces platform_version to sys.getwindowsversion tuple,
393-
# which returns major, minor, build.
394-
if winVersion.winVersion.platform_version >= (6, 2, 9200):
392+
if winVersion.getWinVer() >= winVersion.WIN8:
395393
# Some apps such as File Explorer says it is an immersive process but error 15700 is shown.
396394
# Therefore resort to file version info behavior because it is not a hosted app.
397395
# Others such as Store version of Office are not truly hosted apps,
@@ -501,7 +499,7 @@ def _get_isWindowsStoreApp(self):
501499
e.g. File Explorer reports itself as immersive when it is not.
502500
@rtype: bool
503501
"""
504-
if winVersion.winVersion.platform_version < (6, 2, 9200):
502+
if winVersion.getWinVer() < winVersion.WIN8:
505503
# Windows Store/UWP apps were introduced in Windows 8.
506504
self.isWindowsStoreApp = False
507505
return False

source/appModules/explorer.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ class MetadataEditField(RichEdit50):
242242
but to avoid Windows Explorer crashes we need to use EditTextInfo here. """
243243
@classmethod
244244
def _get_TextInfo(cls):
245-
if ((winVersion.winVersion.major, winVersion.winVersion.minor) == (6, 1)):
245+
if winVersion.getWinVer() <= winVersion.WIN7_SP1:
246246
cls.TextInfo = EditTextInfo
247247
else:
248248
cls.TextInfo = super().TextInfo
@@ -255,8 +255,8 @@ def event_gainFocus(self):
255255
# as it causes 'pane" to be announced when minimizing windows or moving to desktop.
256256
# However when closing Windows 7 Start Menu in some cases
257257
# focus lands on it instead of the focused desktop item.
258-
# Simply ignore the event if running on anything never than Win 7.
259-
if ((winVersion.winVersion.major, winVersion.winVersion.minor) != (6, 1)):
258+
# Simply ignore the event if running on anything other than Win 7.
259+
if winVersion.getWinVer() > winVersion.WIN7_SP1:
260260
return
261261
if eventHandler.isPendingEvents("gainFocus"):
262262
return
@@ -416,7 +416,10 @@ def event_gainFocus(self, obj, nextHandler):
416416

417417
def isGoodUIAWindow(self, hwnd):
418418
# #9204: shell raises window open event for emoji panel in build 18305 and later.
419-
if winVersion.isWin10(version=1903) and winUser.getClassName(hwnd) == "ApplicationFrameWindow":
419+
if (
420+
winVersion.getWinVer() >= winVersion.WIN10_1903
421+
and winUser.getClassName(hwnd) == "ApplicationFrameWindow"
422+
):
420423
return True
421424
return False
422425

source/appModules/putty.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from NVDAObjects.window import DisplayModelEditableText, DisplayModelLiveText
1313
import appModuleHandler
1414
from NVDAObjects.IAccessible import IAccessible
15-
from winVersion import isWin10
15+
from winVersion import getWinVer, WIN10_1607
1616

1717
class AppModule(appModuleHandler.AppModule):
1818
# Allow this to be overridden for derived applications.
@@ -24,7 +24,7 @@ def chooseNVDAObjectOverlayClasses(self, obj, clsList):
2424
clsList.remove(DisplayModelEditableText)
2525
except ValueError:
2626
pass
27-
if isWin10(1607):
27+
if getWinVer() >= WIN10_1607:
2828
clsList[0:0] = (KeyboardHandlerBasedTypedCharSupport, DisplayModelLiveText)
2929
else:
3030
clsList[0:0] = (Terminal, DisplayModelLiveText)

source/appModules/windowsinternal_composableshell_experiences_textinput_inputapp.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# App module for Composable Shell (CShell) input panel
2-
#A part of NonVisual Desktop Access (NVDA)
3-
#Copyright (C) 2017-2018 NV Access Limited, Joseph Lee
4-
#This file is covered by the GNU General Public License.
5-
#See the file COPYING for more details.
2+
# A part of NonVisual Desktop Access (NVDA)
3+
# Copyright (C) 2017-2021 NV Access Limited, Joseph Lee
4+
# This file is covered by the GNU General Public License.
5+
# See the file COPYING for more details.
66

77
"""App module for Windows 10 Modern Keyboard aka new touch keyboard panel.
88
The chief feature is allowing NVDA to announce selected emoji when using the keyboard to search for and select one.
@@ -175,7 +175,13 @@ def event_UIA_window_windowOpen(self, obj, nextHandler):
175175
childAutomationID = obj.firstChild.UIAElement.cachedAutomationID
176176
# Emoji panel for build 16299 and 17134.
177177
# This event is properly raised in build 17134.
178-
if winVersion.winVersion.build <= 17134 and childAutomationID in ("TEMPLATE_PART_ExpressiveInputFullViewFuntionBarItemControl", "TEMPLATE_PART_ExpressiveInputFullViewFuntionBarCloseButton"):
178+
if (
179+
winVersion.getWinVer().build <= 17134
180+
and childAutomationID in (
181+
"TEMPLATE_PART_ExpressiveInputFullViewFuntionBarItemControl",
182+
"TEMPLATE_PART_ExpressiveInputFullViewFuntionBarCloseButton"
183+
)
184+
):
179185
self.event_UIA_elementSelected(obj.lastChild.firstChild, nextHandler)
180186
# Handle hardware keyboard suggestions.
181187
# Treat it the same as CJK composition list - don't announce this if candidate announcement setting is off.
@@ -221,8 +227,9 @@ def event_nameChange(self, obj, nextHandler):
221227
or (self._recentlySelected is not None and self._recentlySelected in obj.name)):
222228
return
223229
# The word "blank" is kept announced, so suppress this on build 17666 and later.
224-
if winVersion.winVersion.build > 17134:
225-
# In build 17672 and later, return immediatley when element selected event on clipboard item was fired just prior to this.
230+
if winVersion.getWinVer().build > 17134:
231+
# In build 17672 and later,
232+
# return immediately when element selected event on clipboard item was fired just prior to this.
226233
# In some cases, parent will be None, as seen when emoji panel is closed in build 18267.
227234
try:
228235
if obj.UIAElement.cachedAutomationID == "TEMPLATE_PART_ClipboardItemIndex" or obj.parent.UIAElement.cachedAutomationID == "TEMPLATE_PART_ClipboardItemsList": return

source/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def main():
253253
languageHandler.setLanguage(lang)
254254
except:
255255
log.warning("Could not set language to %s"%lang)
256-
log.info("Using Windows version %s" % winVersion.winVersionText)
256+
log.info(f"Windows version: {winVersion.getWinVer()}")
257257
log.info("Using Python version %s"%sys.version)
258258
log.info("Using comtypes version %s"%comtypes.__version__)
259259
import configobj

0 commit comments

Comments
 (0)