Block touch input while the magnifier is running#20357
Conversation
|
@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 - can you check the approach now? |
SaschaCowley
left a comment
There was a problem hiding this comment.
I think the logic is flawed, but this is the right direction.
| 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() |
There was a problem hiding this comment.
this still seems to be unnecessarily duplicating setup/tearDown from TestMagnifier
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
|
Please change the title of this PR to avoid confusion. |
|
how would you change the title? it seems ok to me |
|
For example: “Block touch input while the magnifier is running”? |
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: