From a12769478bb81e05ad3b5587fc26f75ff7af5d92 Mon Sep 17 00:00:00 2001 From: Sammi De Guzman Date: Tue, 26 Sep 2023 20:04:55 -0700 Subject: [PATCH] Reimplement half-delay on X11 as covered in #1132 --- plover/oslayer/linux/keyboardcontrol_x11.py | 9 ++++++++- plover/output/keyboard.py | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/plover/oslayer/linux/keyboardcontrol_x11.py b/plover/oslayer/linux/keyboardcontrol_x11.py index c100a36b5..a60eb4c25 100644 --- a/plover/oslayer/linux/keyboardcontrol_x11.py +++ b/plover/oslayer/linux/keyboardcontrol_x11.py @@ -24,6 +24,7 @@ import os import select import threading +from time import sleep from Xlib import X, XK from Xlib.display import Display @@ -1223,7 +1224,7 @@ def send_backspaces(self, count): self._display.sync() def send_string(self, string): - for char in self.with_delay(string): + for char in string: keysym = uchr_to_keysym(char) # TODO: can we find mappings for multiple keys at a time? mapping = self._get_mapping(keysym, automatically_map=False) @@ -1232,12 +1233,18 @@ def send_string(self, string): mapping = self._get_mapping(keysym, automatically_map=True) if mapping is None: continue + self._display.sync() + self.half_delay() mapping_changed = True self._send_keycode(mapping.keycode, mapping.modifiers) self._display.sync() + if mapping_changed: + self.half_delay() + else: + self.delay() def send_key_combination(self, combo): # Parse and validate combo. diff --git a/plover/output/keyboard.py b/plover/output/keyboard.py index 58efabe4d..740f0e6ca 100644 --- a/plover/output/keyboard.py +++ b/plover/output/keyboard.py @@ -15,6 +15,10 @@ def delay(self): if self._key_press_delay_ms > 0: sleep(self._key_press_delay_ms / 1000) + def half_delay(self): + if self._key_press_delay_ms > 0: + sleep(self._key_press_delay_ms / 2000) + def with_delay(self, iterable): for item in iterable: yield item