From e02bf587843e18f12cc696301fa6e55d4f2f5a89 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 15:34:27 -0600 Subject: [PATCH 01/18] Ease of Access: add an underscore to 'canConfigTerminateOnDesktopSwitch' and mark it as deprecated. Re #15662. Windows 8.1 is the mimimum OS, therefore config can termiante on desktop switch. --- source/easeOfAccess.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/easeOfAccess.py b/source/easeOfAccess.py index 6aae8c4a6d8..085d00eb0d9 100644 --- a/source/easeOfAccess.py +++ b/source/easeOfAccess.py @@ -17,7 +17,7 @@ # Windows >= 8 -canConfigTerminateOnDesktopSwitch: bool = winVersion.getWinVer() >= winVersion.WIN8 +_canConfigTerminateOnDesktopSwitch: bool = True _APP_KEY_NAME = "nvda_nvda_v1" From 9c6a6279a832a2a90b4d2ec83b85fc32334387e0 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 15:35:20 -0600 Subject: [PATCH 02/18] Ease of Access: provide a warning about deprecated 'canConfigTerminateOnDesktopSwitch'. Re #15662 --- source/easeOfAccess.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/easeOfAccess.py b/source/easeOfAccess.py index 085d00eb0d9..2b558e94489 100644 --- a/source/easeOfAccess.py +++ b/source/easeOfAccess.py @@ -32,6 +32,10 @@ def __getattr__(attrName: str) -> Any: if attrName == "APP_KEY_NAME" and NVDAState._allowDeprecatedAPI(): log.warning("APP_KEY_NAME is deprecated.") return _APP_KEY_NAME + # #15662: config can terminate on desktop switch (Windows 8.1 is minimum OS). + if attrName == "canConfigTerminateOnDesktopSwitch" and NVDAState._allowDeprecatedAPI(): + log.warning("canConfigTerminateOnDesktopSwitch is deprecated, Windos 8.1 is the minimum OS.") + return _canConfigTerminateOnDesktopSwitch raise AttributeError(f"module {repr(__name__)} has no attribute {repr(attrName)}") From f64a065cff68618a2255a1629c4af28d310abb77 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 15:40:33 -0600 Subject: [PATCH 03/18] Ease of Access: update copyright header --- source/easeOfAccess.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/easeOfAccess.py b/source/easeOfAccess.py index 2b558e94489..fa564ba5b6b 100644 --- a/source/easeOfAccess.py +++ b/source/easeOfAccess.py @@ -1,5 +1,5 @@ # A part of NonVisual Desktop Access (NVDA) -# Copyright (C) 2014-2022 NV Access Limited +# Copyright (C) 2014-2023 NV Access Limited # This file is covered by the GNU General Public License. # See the file COPYING for more details. From 33ee0598f5e95cef58d905759098b065309e66bf Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 15:42:02 -0600 Subject: [PATCH 04/18] Ease of Access: general lint. Re #15662 --- source/easeOfAccess.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source/easeOfAccess.py b/source/easeOfAccess.py index fa564ba5b6b..d20333d0b86 100644 --- a/source/easeOfAccess.py +++ b/source/easeOfAccess.py @@ -13,7 +13,6 @@ import NVDAState import winreg import winUser -import winVersion # Windows >= 8 @@ -77,8 +76,8 @@ def notify(signal): for vk in winUser.VK_SHIFT, winUser.VK_CONTROL, winUser.VK_MENU: if winUser.getAsyncKeyState(vk) & 32768: keys.append((vk, False)) - keys.append((0x5B, True)) # leftWindows - keys.append((0x55, True)) # u + keys.append((0x5B, True)) # leftWindows + keys.append((0x55, True)) # u inputs = [] # Release unwanted keys and press desired keys. for vk, desired in keys: @@ -170,5 +169,7 @@ def setAutoStart(autoStartContext: AutoStartContext, enable: bool) -> None: 0, winreg.KEY_READ | winreg.KEY_WRITE | winreg.KEY_WOW64_64KEY ) - winreg.SetValueEx(k, "Configuration", None, winreg.REG_SZ, - ",".join(conf)) + winreg.SetValueEx( + k, "Configuration", None, winreg.REG_SZ, + ",".join(conf) + ) From 8f3a519497f6c33745890597db2aef6dc2ae166e Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 15:51:43 -0600 Subject: [PATCH 05/18] Windows API/lock session state: return Windows 8 or later session state enumerations. Re #15663. Return Windows 8.1 or later lock session state enumeration as Windows 7 is no longer supported by NVDA. --- source/winAPI/_wtsApi32.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/winAPI/_wtsApi32.py b/source/winAPI/_wtsApi32.py index 3b90ed50350..beab9751647 100644 --- a/source/winAPI/_wtsApi32.py +++ b/source/winAPI/_wtsApi32.py @@ -214,13 +214,13 @@ class _WTS_LockState_Win7(IntEnum): """The session is unlocked.""" -def _setWTS_LockState() -> Type[Union[_WTS_LockState, _WTS_LockState_Win7]]: +def _setWTS_LockState() -> _WTS_LockState: """ Ensure that the correct values for WTS_SESSIONSTATE_LOCK are used based on the platform. """ - return _WTS_LockState_Win7 if (winVersion.getWinVer() < winVersion.WIN8) else _WTS_LockState + return _WTS_LockState -WTS_LockState: Type[Union[_WTS_LockState, _WTS_LockState_Win7]] = _setWTS_LockState() +WTS_LockState: _WTS_LockState = _setWTS_LockState() """ Set of known session states that NVDA can handle. These values are different on different versions of Windows. From f64a1251c01f0a79bfc9a7f1673ca30321a068f0 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 15:52:13 -0600 Subject: [PATCH 06/18] Windows API/session lock state: update copyright header --- source/winAPI/_wtsApi32.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/winAPI/_wtsApi32.py b/source/winAPI/_wtsApi32.py index beab9751647..0899cfe031c 100644 --- a/source/winAPI/_wtsApi32.py +++ b/source/winAPI/_wtsApi32.py @@ -1,5 +1,5 @@ # A part of NonVisual Desktop Access (NVDA) -# Copyright (C) 2022 NV Access Limited +# Copyright (C) 2022-2023 NV Access Limited # This file may be used under the terms of the GNU General Public License, version 2 or later. # For more details see: https://www.gnu.org/licenses/gpl-2.0.html From a0407652d6140dfd9210497a739948f4025d2171 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 15:57:40 -0600 Subject: [PATCH 07/18] Windows API/lock session state: remove unused imports. Re #15663 --- source/winAPI/_wtsApi32.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/source/winAPI/_wtsApi32.py b/source/winAPI/_wtsApi32.py index 0899cfe031c..4381d1273d7 100644 --- a/source/winAPI/_wtsApi32.py +++ b/source/winAPI/_wtsApi32.py @@ -13,11 +13,7 @@ from enum import ( IntEnum, ) -from typing import ( - Callable, - Union, - Type, -) +from typing import Callable import ctypes # Use for ctypes.Union to prevent name collision with typing.Union from ctypes import ( windll, @@ -35,7 +31,6 @@ LPWSTR, BOOL, ) -import winVersion WTS_CURRENT_SERVER_HANDLE = HANDLE(0) From 59e8c7910361c1ea44843b975ad79e3ba63b48ab Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 16:08:32 -0600 Subject: [PATCH 08/18] winVersion/full screen magnification: say 'Windows 8.1'. Re #15664. Mostly for screen curtain: as NVDA requires Windows 8.1 or later, there is no need to actualy provide a flag that says full screen magnification API is present. However the API is not supported for 32-bit apps (WWoW64), so keep the flag around in case Microsoft removes in a future Windows release. --- source/winVersion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/winVersion.py b/source/winVersion.py index 3a8a31aaae5..15e914b4360 100644 --- a/source/winVersion.py +++ b/source/winVersion.py @@ -217,4 +217,4 @@ def isFullScreenMagnificationAvailable() -> bool: WOW64 applications such as NVDA. For our usages, support has been added since Windows 8, relying on our testing our specific usage of the API with each Windows version since Windows 8 """ - return getWinVer() >= WIN8 + return getWinVer() >= WIN81 From 09a7957f64b22399379de4a12f2e623f5ee64dc2 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 16:11:50 -0600 Subject: [PATCH 09/18] User guide: update audio ducking context help to remove Windows 8 requirement (Windows 8.1 is the minimum OS) --- user_docs/en/userGuide.t2t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_docs/en/userGuide.t2t b/user_docs/en/userGuide.t2t index 4dbfc48cb98..3337396405f 100644 --- a/user_docs/en/userGuide.t2t +++ b/user_docs/en/userGuide.t2t @@ -1815,7 +1815,7 @@ This option allows you to choose the audio device that NVDA should instruct the ==== Audio Ducking Mode ====[SelectSynthesizerDuckingMode] Key: ``NVDA+shift+d`` -On Windows 8 and above, this option allows you to choose if NVDA should lower the volume of other applications while NVDA is speaking, or all the time while NVDA is running. +This option allows you to choose if NVDA should lower the volume of other applications while NVDA is speaking, or all the time while NVDA is running. - No Ducking: NVDA will never lower the volume of other audio. - Duck when outputting speech and sounds: NVDA will only lower the volume of other audio when NVDA is speaking or playing sounds. This may not work for all synthesizers. - Always duck: NVDA will keep the volume of other audio lower the whole time NVDA is running. From 23ddec01824cf9373acbe01f6f2dd1c98e86ec09 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 16:26:43 -0600 Subject: [PATCH 10/18] Changelog: add deprecation notice on easeOfAccess.canConfigTerminateOnDesktopSwitch with no replacement. Re #15662 --- user_docs/en/changes.t2t | 1 + 1 file changed, 1 insertion(+) diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index f5a23c5ba47..cbbb9d4d94e 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -113,6 +113,7 @@ Code which imports from one of them, should instead import from the replacement === Deprecations === - Using ``watchdog.getFormattedStacksForAllThreads`` is deprecated - please use ``logHandler.getFormattedStacksForAllThreads`` instead. (#15616, @lukaszgo1) +- easeOfAccess.canConfigTerminateOnDesktopSwitch is deprecated with no replacement - it will always be True as NVDA requires Windows 8.1 or later. (#15662, @josephsl) - From c43c9fc58243453643222b048af9afb28ddf8c4b Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 17:04:15 -0600 Subject: [PATCH 11/18] winVersion.isFullScreenMagnificationAvailable: just return True Co-authored-by: Sean Budd --- source/winVersion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/winVersion.py b/source/winVersion.py index 15e914b4360..1a00f3b57b4 100644 --- a/source/winVersion.py +++ b/source/winVersion.py @@ -217,4 +217,4 @@ def isFullScreenMagnificationAvailable() -> bool: WOW64 applications such as NVDA. For our usages, support has been added since Windows 8, relying on our testing our specific usage of the API with each Windows version since Windows 8 """ - return getWinVer() >= WIN81 + return True From 7f6f11144c02a3a805c2260e197d8217d80f7ff7 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 17:04:32 -0600 Subject: [PATCH 12/18] Update source/easeOfAccess.py Co-authored-by: Sean Budd --- source/easeOfAccess.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/easeOfAccess.py b/source/easeOfAccess.py index 756f165cdd5..abd47932065 100644 --- a/source/easeOfAccess.py +++ b/source/easeOfAccess.py @@ -167,6 +167,9 @@ def setAutoStart(autoStartContext: AutoStartContext, enable: bool) -> None: winreg.KEY_READ | winreg.KEY_WRITE | winreg.KEY_WOW64_64KEY ) winreg.SetValueEx( - k, "Configuration", None, winreg.REG_SZ, + k, + "Configuration", + None, + winreg.REG_SZ, ",".join(conf) ) From 4dbbfbbae47e39daba380174440cdd3f0df19441 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 19:14:41 -0600 Subject: [PATCH 13/18] winVersion.isFullScreenMagnificationAvailable: mark as deprecated. Re #15664 --- source/winVersion.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/source/winVersion.py b/source/winVersion.py index 1a00f3b57b4..d78c0456d2d 100644 --- a/source/winVersion.py +++ b/source/winVersion.py @@ -16,6 +16,8 @@ import functools import winreg import platform +import NVDAState +from logHandler import log # Records a mapping between Windows builds and release names. @@ -211,10 +213,14 @@ def isUwpOcrAvailable(): return os.path.isdir(UWP_OCR_DATA_PATH) -def isFullScreenMagnificationAvailable() -> bool: - """ - Technically this is always False. The Magnification API has been marked by MS as unsupported for - WOW64 applications such as NVDA. For our usages, support has been added since Windows 8, relying on our - testing our specific usage of the API with each Windows version since Windows 8 - """ - return True +if NVDAState._allowDeprecatedAPI(): + def isFullScreenMagnificationAvailable() -> bool: + """ + Technically this is always False. The Magnification API has been marked by MS as unsupported for + WOW64 applications such as NVDA. For our usages, support has been added since Windows 8, relying on our + testing our specific usage of the API with each Windows version since Windows 8 + """ + log.debugWarning( + "Deprecated function called: winVersion.isFullScreenMagnificationAvailable", stack_info=True + ) + return True From 5c8a01e8e6af023935ebdf32df6d3f627d8a9c05 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 19:16:37 -0600 Subject: [PATCH 14/18] Screen curtain: remove winVersion.isFullScreenMagnificationAvailable call, returning True when asked to start. Re #15664 --- source/visionEnhancementProviders/screenCurtain.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/visionEnhancementProviders/screenCurtain.py b/source/visionEnhancementProviders/screenCurtain.py index 319cf8a3a35..7f7e11574b1 100644 --- a/source/visionEnhancementProviders/screenCurtain.py +++ b/source/visionEnhancementProviders/screenCurtain.py @@ -5,13 +5,11 @@ """Screen curtain implementation based on the windows magnification API. The Magnification API has been marked by MS as unsupported for WOW64 applications such as NVDA. (#12491) -This module has been tested on Windows versions specified by winVersion.isFullScreenMagnificationAvailable. """ import os import vision from vision import providerBase -import winVersion from ctypes import Structure, windll, c_float, POINTER, WINFUNCTYPE, WinError from ctypes.wintypes import BOOL from autoSettingsUtils.driverSetting import BooleanDriverSetting @@ -330,7 +328,7 @@ def canStart(cls): versions of Windows, this may not continue to be true in the future. The Magnification API was introduced by Microsoft with Windows 8. """ - return winVersion.isFullScreenMagnificationAvailable() + return True @classmethod def getSettingsPanelClass(cls) -> Optional[Type]: From 2510085dc2b713abe897077650e457ecf50782b4 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 19:17:28 -0600 Subject: [PATCH 15/18] Changelog: add deprecation notice for winVersion.isFullScreenMagnificationAvailable. Re #15664 --- user_docs/en/changes.t2t | 1 + 1 file changed, 1 insertion(+) diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index db2c985cac3..69ea77a2c5d 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -117,6 +117,7 @@ Code which imports from one of them, should instead import from the replacement - Using ``watchdog.getFormattedStacksForAllThreads`` is deprecated - please use ``logHandler.getFormattedStacksForAllThreads`` instead. (#15616, @lukaszgo1) - ``easeOfAccess.canConfigTerminateOnDesktopSwitch`` has been deprecated, as it became obsolete since Windows 7 is no longer supported. (#15644, @LeonarddeR) +- ``winVersion.isFullScreenMagnificationAvailable`` has been deprecated, as it became obsolete since Windows 7 is no longer supported. (#15664, @josephsl) - From b37b85a91a69ee4b12180819bd2cdd603fb9cd9d Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 19:19:59 -0600 Subject: [PATCH 16/18] Screen curtain: general lint --- source/visionEnhancementProviders/screenCurtain.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/visionEnhancementProviders/screenCurtain.py b/source/visionEnhancementProviders/screenCurtain.py index 7f7e11574b1..64c53005fe0 100644 --- a/source/visionEnhancementProviders/screenCurtain.py +++ b/source/visionEnhancementProviders/screenCurtain.py @@ -8,7 +8,6 @@ """ import os -import vision from vision import providerBase from ctypes import Structure, windll, c_float, POINTER, WINFUNCTYPE, WinError from ctypes.wintypes import BOOL @@ -134,6 +133,7 @@ def _get_supportedSettings(self) -> SupportedSettingType: ), ] + warnOnLoadText = _( # Translators: A warning shown when activating the screen curtain. # the translation of "Screen Curtain" should match the "translated name" @@ -344,7 +344,7 @@ def getSettings(cls) -> ScreenCurtainSettings: def __init__(self): super().__init__() - log.debug(f"Starting ScreenCurtain") + log.debug("Starting ScreenCurtain") Magnification.MagInitialize() try: Magnification.MagSetFullscreenColorEffect(TRANSFORM_BLACK) @@ -359,7 +359,7 @@ def __init__(self): log.exception() def terminate(self): - log.debug(f"Terminating ScreenCurtain") + log.debug("Terminating ScreenCurtain") try: super().terminate() finally: From 96d4826662e07dfbd15e1859d10d5701568860d8 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 19:36:49 -0600 Subject: [PATCH 17/18] Changelog: winVersion.isFullScreenMagnificationAvailable -> visionEnhancementProviders.screenCurtain.ScreenCurtainProvider.canStart. Re #15664 --- user_docs/en/changes.t2t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index 69ea77a2c5d..546de817b64 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -117,7 +117,7 @@ Code which imports from one of them, should instead import from the replacement - Using ``watchdog.getFormattedStacksForAllThreads`` is deprecated - please use ``logHandler.getFormattedStacksForAllThreads`` instead. (#15616, @lukaszgo1) - ``easeOfAccess.canConfigTerminateOnDesktopSwitch`` has been deprecated, as it became obsolete since Windows 7 is no longer supported. (#15644, @LeonarddeR) -- ``winVersion.isFullScreenMagnificationAvailable`` has been deprecated, as it became obsolete since Windows 7 is no longer supported. (#15664, @josephsl) +- ``winVersion.isFullScreenMagnificationAvailable`` has been deprecated - use ``visionEnhancementProviders.screenCurtain.ScreenCurtainProvider.canStart`` instead. (#15664, @josephsl) - From fad0b3204255ce5e3425ec8a796ffd32cb63aa31 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Sun, 22 Oct 2023 19:55:30 -0600 Subject: [PATCH 18/18] winVersion: provide replacement for winVersion.isFullScreenMagnificationAvailable. Re #15664 --- source/winVersion.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/winVersion.py b/source/winVersion.py index d78c0456d2d..0b84dc83a05 100644 --- a/source/winVersion.py +++ b/source/winVersion.py @@ -221,6 +221,8 @@ def isFullScreenMagnificationAvailable() -> bool: testing our specific usage of the API with each Windows version since Windows 8 """ log.debugWarning( - "Deprecated function called: winVersion.isFullScreenMagnificationAvailable", stack_info=True + "Deprecated function called: winVersion.isFullScreenMagnificationAvailable, " + "use visionEnhancementProviders.screenCurtain.ScreenCurtainProvider.canStart instead.", + stack_info=True ) return True