From 32e5c7fa8e5630bb5ed653d1bc78ba2aa7d28761 Mon Sep 17 00:00:00 2001 From: James Teh Date: Tue, 28 Jul 2026 15:27:22 +1000 Subject: [PATCH] When queuing calls to the main thread which present speech or braille to the user, ensure they are executed immediately. By default, functions queued with queueHandler.queueFunction are delayed slightly so that queues can implement rate limiting, filter extraneous events, etc. Any of that has already occurred on the server. Therefore, on the client, we want output to be presented to the user as soon as possible; there's no benefit in delaying further. This should make speech and braille output from the server feel more responsive. --- .../globalPlugins/rdAccess/handlers/remoteBrailleHandler.py | 4 ++-- .../globalPlugins/rdAccess/handlers/remoteSpeechHandler.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addon/globalPlugins/rdAccess/handlers/remoteBrailleHandler.py b/addon/globalPlugins/rdAccess/handlers/remoteBrailleHandler.py index 8c8bbd4..b3c09fe 100644 --- a/addon/globalPlugins/rdAccess/handlers/remoteBrailleHandler.py +++ b/addon/globalPlugins/rdAccess/handlers/remoteBrailleHandler.py @@ -93,7 +93,7 @@ def _command_display(self, cells: list[int]): with self._queuedWriteLock: self._queuedWrite = cells if not braille.handler.enabled and self.hasFocus: - self._queueFunctionOnMainThread(self._performLocalWriteCells) + self._queueFunctionOnMainThread(self._performLocalWriteCells, _immediate=True) elif self._remoteSessionhasFocus is False: self.requestRemoteAttribute(protocol.GenericAttribute.TIME_SINCE_INPUT) @@ -107,7 +107,7 @@ def _performLocalWriteCells(self): def _handleRemoteSessionGainFocus(self): super()._handleRemoteSessionGainFocus() - self._queueFunctionOnMainThread(self._performLocalWriteCells) + self._queueFunctionOnMainThread(self._performLocalWriteCells, _immediate=True) def _handleExecuteGesture(self, gesture): assert braille.handler is not None diff --git a/addon/globalPlugins/rdAccess/handlers/remoteSpeechHandler.py b/addon/globalPlugins/rdAccess/handlers/remoteSpeechHandler.py index 820ee0b..cedf326 100644 --- a/addon/globalPlugins/rdAccess/handlers/remoteSpeechHandler.py +++ b/addon/globalPlugins/rdAccess/handlers/remoteSpeechHandler.py @@ -60,7 +60,7 @@ def _outgoing_language(self, language: str | None = None) -> str | None: @protocol.commandHandler(protocol.RdMessageType.SPEAK) def _command_speak(self, sequence: SpeechSequence): - self._queueFunctionOnMainThread(self._speak, sequence) + self._queueFunctionOnMainThread(self._speak, sequence, _immediate=True) def _speak(self, sequence: SpeechSequence): pitchChange = configuration.getIncomingSpeechPitchChange(fromCache=True) @@ -80,7 +80,7 @@ def _speak(self, sequence: SpeechSequence): @protocol.commandHandler(protocol.RdMessageType.CANCEL) def _command_cancel(self): self._indexesSpeaking.clear() - self._queueFunctionOnMainThread(self._cancel) + self._queueFunctionOnMainThread(self._cancel, _immediate=True) def _cancel(self): self._driver.cancel() @@ -90,7 +90,7 @@ def _cancel(self): @protocol.commandHandler(protocol.RdMessageType.PAUSE_SPEECH) def _command_pause(self, switch: bool): - self._queueFunctionOnMainThread(self._pause, switch) + self._queueFunctionOnMainThread(self._pause, switch, _immediate=True) def _pause(self, switch: bool): speech.pauseSpeech(switch)