Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e02bf58
Ease of Access: add an underscore to 'canConfigTerminateOnDesktopSwit…
josephsl Oct 22, 2023
9c6a627
Ease of Access: provide a warning about deprecated 'canConfigTerminat…
josephsl Oct 22, 2023
f64a065
Ease of Access: update copyright header
josephsl Oct 22, 2023
33ee059
Ease of Access: general lint. Re #15662
josephsl Oct 22, 2023
8f3a519
Windows API/lock session state: return Windows 8 or later session sta…
josephsl Oct 22, 2023
f64a125
Windows API/session lock state: update copyright header
josephsl Oct 22, 2023
a040765
Windows API/lock session state: remove unused imports. Re #15663
josephsl Oct 22, 2023
59e8c79
winVersion/full screen magnification: say 'Windows 8.1'. Re #15664.
josephsl Oct 22, 2023
09a7957
User guide: update audio ducking context help to remove Windows 8 req…
josephsl Oct 22, 2023
23ddec0
Changelog: add deprecation notice on easeOfAccess.canConfigTerminateO…
josephsl Oct 22, 2023
4b61132
Merge branch 'master' into removeWin8ConstantMentions
josephsl Oct 22, 2023
c43c9fc
winVersion.isFullScreenMagnificationAvailable: just return True
josephsl Oct 22, 2023
7f6f111
Update source/easeOfAccess.py
josephsl Oct 22, 2023
458afd9
Merge branch 'master' into removeWin8ConstantMentions
josephsl Oct 23, 2023
4dbbfbb
winVersion.isFullScreenMagnificationAvailable: mark as deprecated. Re…
josephsl Oct 23, 2023
5c8a01e
Screen curtain: remove winVersion.isFullScreenMagnificationAvailable …
josephsl Oct 23, 2023
2510085
Changelog: add deprecation notice for winVersion.isFullScreenMagnific…
josephsl Oct 23, 2023
b37b85a
Screen curtain: general lint
josephsl Oct 23, 2023
96d4826
Changelog: winVersion.isFullScreenMagnificationAvailable -> visionEnh…
josephsl Oct 23, 2023
fad0b32
winVersion: provide replacement for winVersion.isFullScreenMagnificat…
josephsl Oct 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions source/easeOfAccess.py
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
)
10 changes: 4 additions & 6 deletions source/visionEnhancementProviders/screenCurtain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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]:
Expand All @@ -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)
Expand All @@ -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:
Expand Down
15 changes: 5 additions & 10 deletions source/winAPI/_wtsApi32.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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,
Expand All @@ -35,7 +31,6 @@
LPWSTR,
BOOL,
)
import winVersion


WTS_CURRENT_SERVER_HANDLE = HANDLE(0)
Expand Down Expand Up @@ -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.
Expand Down
22 changes: 15 additions & 7 deletions source/winVersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this please use the standard __getattr__ methoud outlined in deprecations.md?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it like this initially as the deprecated symbol is a function, not a constant or a variable, using gui.quit as precedence. If an add-on or other part of NVDA calls winVersion.isFullScreenMagnificationAvailable using the proposed deprecation method, Python will raise attribute error, which amounts to removing the function altogether from the module.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the gui.quit example did come before this was standardised though, so I wouldn't use it as precedent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should give us a motivation to refine the getattr method when dealing with deprecated functions and class methods. I'll follow the suggested process, and then will create a new GitHub issue.

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
1 change: 1 addition & 0 deletions user_docs/en/changes.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -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)
-


Expand Down
2 changes: 1 addition & 1 deletion user_docs/en/userGuide.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down