diff --git a/source/easeOfAccess.py b/source/easeOfAccess.py index 067cf9477b1..abd47932065 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. @@ -73,8 +73,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: @@ -166,5 +166,10 @@ 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) + ) diff --git a/source/visionEnhancementProviders/screenCurtain.py b/source/visionEnhancementProviders/screenCurtain.py index 319cf8a3a35..64c53005fe0 100644 --- a/source/visionEnhancementProviders/screenCurtain.py +++ b/source/visionEnhancementProviders/screenCurtain.py @@ -5,13 +5,10 @@ """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 @@ -136,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" @@ -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]: @@ -346,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) @@ -361,7 +359,7 @@ def __init__(self): log.exception() def terminate(self): - log.debug(f"Terminating ScreenCurtain") + log.debug("Terminating ScreenCurtain") try: super().terminate() finally: diff --git a/source/winAPI/_wtsApi32.py b/source/winAPI/_wtsApi32.py index 3b90ed50350..4381d1273d7 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 @@ -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) @@ -214,13 +209,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. diff --git a/source/winVersion.py b/source/winVersion.py index 3a8a31aaae5..0b84dc83a05 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,16 @@ 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 getWinVer() >= WIN8 +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, " + "use visionEnhancementProviders.screenCurtain.ScreenCurtainProvider.canStart instead.", + stack_info=True + ) + return True diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index db2c985cac3..546de817b64 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 - use ``visionEnhancementProviders.screenCurtain.ScreenCurtainProvider.canStart`` instead. (#15664, @josephsl) - diff --git a/user_docs/en/userGuide.t2t b/user_docs/en/userGuide.t2t index f7ec8b857bd..c727dcd9797 100644 --- a/user_docs/en/userGuide.t2t +++ b/user_docs/en/userGuide.t2t @@ -1816,7 +1816,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.