Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix prevent display from turning off #17714

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion source/config/configSpec.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#possible log levels are DEBUG, IO, DEBUGWARNING, INFO
loggingLevel = string(default="INFO")
showWelcomeDialogAtStartup = boolean(default=true)
preventDisplayTurnOff = featureFlag(optionsEnum="BoolFlag", behaviorOfDefault="enabled")
preventDisplayTurningOff = boolean(default=true)

# Speech settings
[speech]
Expand Down
20 changes: 8 additions & 12 deletions source/gui/settingsDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,18 +983,14 @@ def makeSettings(self, settingsSizer):
if globalVars.appArgs.secure:
mirrorBox.Disable()

self.preventDisplayTurnOffCombo: nvdaControls.FeatureFlagCombo = (
settingsSizerHelper.addLabeledControl(
labelText=_(
# Translators: This is a label for a combo-box in the general settings panel.
"Prevent &display from turning off during say all or reading with braille",
),
wxCtrlClass=nvdaControls.FeatureFlagCombo,
keyPath=["general", "preventDisplayTurnOff"],
conf=config.conf,
)
item = self.preventDisplayTurningOffCheckBox = wx.CheckBox(
self,
# Translators: The label of a checkbox in general settings.
label="Prevent &display from turning off during say all or reading with braille",
)
self.bindHelpEvent("PreventDisplayTurnOff", self.preventDisplayTurnOffCombo)
self.bindHelpEvent("PreventDisplayTurningOff", self.preventDisplayTurningOffCheckBox)
item.Value = config.conf["general"]["preventDisplayTurningOff"]
settingsSizerHelper.addItem(item)

def onChangeMirrorURL(self, evt: wx.CommandEvent | wx.KeyEvent):
"""Show the dialog to change the update mirror URL, and refresh the dialog in response to the URL being changed."""
Expand Down Expand Up @@ -1117,7 +1113,7 @@ def onSave(self):
updateCheck.terminate()
updateCheck.initialize()

self.preventDisplayTurnOffCombo.saveCurrentValueToConf()
config.conf["general"]["preventDisplayTurningOff"] = self.preventDisplayTurningOffCheckBox.IsChecked()

def onPanelActivated(self):
if updateCheck:
Expand Down
10 changes: 5 additions & 5 deletions source/systemUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,21 @@ def run(self):
log.debugWarning("task had errors", exc_info=True)


def preventSystemIdle(preventDisplayTurnOff: bool | None = None, persistent: bool = False) -> None:
def preventSystemIdle(preventDisplayTurningOff: bool | None = None, persistent: bool = False) -> None:
"""
Prevent the system from locking the screen or going to sleep.
:param preventDisplayTurnOff: If `True`, keep the display awake as well.
:param preventDisplayTurningOff: If `True`, keep the display awake as well.
if `False`, only avoid system sleep.
if `None`, the general setting "prevent display turn off" will be used.
:param persistent: If `True`, the state will be maintained until calling :func:`resetThreadExecutionState` is called.
"""
if preventDisplayTurnOff is None:
if preventDisplayTurningOff is None:
import config

preventDisplayTurnOff = bool(config.conf["general"]["preventDisplayTurnOff"])
preventDisplayTurningOff = config.conf["general"]["preventDisplayTurningOff"]
windll.kernel32.SetThreadExecutionState(
winKernel.ES_SYSTEM_REQUIRED
| (winKernel.ES_DISPLAY_REQUIRED if preventDisplayTurnOff else 0)
| (winKernel.ES_DISPLAY_REQUIRED if preventDisplayTurningOff else 0)
| (winKernel.ES_CONTINUOUS if persistent else 0),
)

Expand Down
9 changes: 2 additions & 7 deletions user_docs/en/userGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1846,18 +1846,13 @@ If you wish to change the update mirror, press the "Change..." button to open th
Please note that when using an update mirror, the operator of the mirror has access to all [information sent with update checks](#GeneralSettingsCheckForUpdates).
Contact the operator of the update mirror for details of their data handling policies to ensure you are comfortable with the way your information will be handled before setting an update mirror.

##### Prevent display from turning off during say all or reading with braille {#PreventDisplayTurnOff}
##### Prevent display from turning off during say all or reading with braille {#PreventDisplayTurningOff}

This option ensures that the display stays on when reading with say all or with braille (e.g. when pressing scroll buttons).
This check box, when enabled, ensures that the display stays on when reading with say all or with braille (e.g. when pressing scroll buttons).
This avoids the situation where the screen unexpectedly locks during a say all.
This option is enabled by default.
Consider disabling this option if you are suffering from a shorter battery life.

| . {.hideHeaderRow} |.|
|---|---|
|Options |Default (Enabled), Disabled, Enabled|
|Default |Enabled|

#### Speech Settings {#SpeechSettings}

<!-- KC:setting -->
Expand Down