Skip to content

Block touch input while the magnifier is running#20357

Open
Boumtchack wants to merge 9 commits into
nvaccess:betafrom
France-Travail:feature/disableTouchscreen
Open

Block touch input while the magnifier is running#20357
Boumtchack wants to merge 9 commits into
nvaccess:betafrom
France-Travail:feature/disableTouchscreen

Conversation

@Boumtchack

@Boumtchack Boumtchack commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Link to issue number:

Closes #20038

Summary of the issue:

Touch screen input causes incorrect mappings when the NVDA magnifier is running. Touch input must be disabled while the magnifier is active to prevent this conflict.

Description of user facing changes:

On installed copies of NVDA, touch gestures are silently blocked while the magnifier is running. An earcon plays on each blocked gesture so the user knows the touch was received but suppressed. On portable copies, copies running from source, or without UI access, a warning dialog appears when the magnifier starts to inform the user that touch input cannot be intercepted and may not behave as expected.

Description of developer facing changes:

A blockTouchInput: bool flag is added to touchHandler. In TouchHandler.pump(), when the flag is True, gestures are skipped and an earcon is played instead of executing the gesture. Magnifier._startMagnifier sets touchHandler.blockTouchInput = True if the handler is active, or schedules a gui.messageBox warning via wx.CallAfter otherwise. Magnifier._stopMagnifier unconditionally resets the flag to False.

Description of development approach:

Keeps the touch handler running and blocks only at the gesture execution layer in pump(), which runs on the main thread and avoids any threading concerns with audio feedback.

Testing strategy:

unit

Known issues with pull request:

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@Boumtchack Boumtchack marked this pull request as ready for review June 17, 2026 15:08
@Boumtchack Boumtchack requested a review from a team as a code owner June 17, 2026 15:08
@Boumtchack Boumtchack requested a review from seanbudd June 17, 2026 15:08
@SaschaCowley

Copy link
Copy Markdown
Member

@Boumtchack this approach will not work. Disabling NVDA's touch support does *NOT disable touchscreen input, it simply disables NVDA's processing of touch events. Arguably this makes the situation worse, as touching the screen in this state will silently perform actions. While we have no way of preventing this in portable copies (we can't intercept touch inputs in portables), we already intercept all touch events when touch support is enabled in installed copies.

What we need to do is continue to block touch inputs but alert the user that touch support is unavailable. Of course, if NVDA's touch support is disabled, or NVDA is running from source, portable, or (I think) without UI access, we still need to pop up a dialog alerting the user that the touch screen will not behave as expected while the magnifier is running.

@SaschaCowley SaschaCowley marked this pull request as draft June 17, 2026 23:33
@Boumtchack Boumtchack marked this pull request as ready for review June 22, 2026 13:32
@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Jun 23, 2026
@seanbudd seanbudd requested a review from SaschaCowley June 23, 2026 02:17
@seanbudd

Copy link
Copy Markdown
Member

@SaschaCowley - can you check the approach now?

@SaschaCowley SaschaCowley left a comment

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 logic is flawed, but this is the right direction.

Comment thread source/_magnifier/magnifier.py Outdated
Comment thread source/_magnifier/magnifier.py Outdated
Comment thread source/touchHandler.py Outdated
Comment thread tests/unit/test_magnifier/test_magnifier.py
@SaschaCowley SaschaCowley marked this pull request as draft June 23, 2026 06:14
@Boumtchack Boumtchack marked this pull request as ready for review June 24, 2026 06:28
@seanbudd seanbudd requested a review from SaschaCowley June 25, 2026 04:12
Comment thread tests/unit/test_magnifier/test_magnifier.py Outdated
Comment thread source/_magnifier/magnifier.py Outdated
Comment thread source/_magnifier/magnifier.py Outdated
@seanbudd seanbudd added this to the 2026.2 milestone Jun 25, 2026
@seanbudd seanbudd marked this pull request as draft June 29, 2026 05:06
@Boumtchack Boumtchack marked this pull request as ready for review June 29, 2026 14:03
Comment thread tests/unit/test_magnifier/test_magnifierTouchscreen.py Outdated
Comment on lines +17 to +30
def setUp(self):
super().setUp()
self.magnifier = Magnifier()
screenDimensions = getPrimaryDisplayOrientation()
self.focusCoords = Coordinates(screenDimensions.width // 2, screenDimensions.height // 2)
self.magnifier._focusManager.getCurrentFocusCoordinates = MagicMock(return_value=self.focusCoords)

def tearDown(self):
if hasattr(self.magnifier, "_timer") and self.magnifier._timer:
self.magnifier._timer.Stop()
self.magnifier._timer = None
if hasattr(self.magnifier, "_isActive") and self.magnifier._isActive:
self.magnifier._isActive = False
super().tearDown()

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.

this still seems to be unnecessarily duplicating setup/tearDown from TestMagnifier

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 tests could use a good clean up regarding all the changes that have been made since the start, I would say we let this like that and I'll do a big clean up in the future

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 we make base class and use it across these two test suites? I'm not asking for a full refactor, just for the changed/added code. We try to fix things incrementally when we touch them rather than do large scale refactors.

@hwf1324

hwf1324 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Please change the title of this PR to avoid confusion.

@Boumtchack

Copy link
Copy Markdown
Contributor Author

how would you change the title? it seems ok to me

@hwf1324

hwf1324 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

For example: “Block touch input while the magnifier is running”?

@Boumtchack Boumtchack changed the title touchscreen and magnifier support Block touch input while the magnifier is running Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants