mike-fabian / ibus-typing-booster

ibus-typing-booster is a completion input method for faster typing
https://mike-fabian.github.io/ibus-typing-booster/
Other
226 stars 15 forks source link

[BUG] OSK: When using the on-screen-keyboard, committing a preedit with space doesn’t insert the space sometimes #397

Closed mike-fabian closed 1 year ago

mike-fabian commented 1 year ago

See: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5930#note_1573938

I thought this only happens when ibus-typing-booster was automatically enabled, not when selected manually in the Gnome panel.

But sometimes it happens also when ibus-typing-booster was selected manually. It seems to depend on whether the automatically selected typing booster or the manually selected typing booster was started first: After an ibus restart in Gnome Wayland, the problem may occur both in the automatically and the manually selected typing booster, depending on the order they are started.

The problem occurs when the do_process_key_event() function receives the space like this:

2022-11-02 18:09:30,679 hunspell_table.py line 5729 do_process_key_event DEBUG: KeyEvent object: val=32 code=0 state=0x40000000 name=“space” unicode=“ ” msymbol=“ ” shift=False lock=False control=False super=False hyper=False meta=False mod1=False mod2=False mod3=False mod4=False mod5=False button1=False button2=False button3=False button4=False button5=False release=True modifier=True

I.e. with a key value 32 and a key code of 0.

Then, self.forward_key_event(key.val, key.code, key.state) with 0 as key.code fails.

(I think ibus calculates the key code when 0 is given, but this doesn’t seem to work).

The problem does not occur when the do_process_key_event() function receives the space like this:

2022-11-02 18:15:11,619 hunspell_table.py line 5729 do_process_key_event DEBUG: KeyEvent object: val=32 code=57 state=0x40000000 name=“space” unicode=“ ” msymbol=“ ” shift=False lock=False control=False super=False hyper=False meta=False mod1=False mod2=False mod3=False mod4=False mod5=False button1=False button2=False button3=False button4=False button5=False release=True modifier=True

I.e. with 57 as the key.code for the space. 57 is the correct ibus key code for space (ibus key codes are calculated by subtracting 8 from the “normal” key codes).

I don’t know why the incoming space key from the OSK sometimes does have 0 instead of the correct key code.

mike-fabian commented 1 year ago

Now I try to avoid using forward_key_event() after a commit if the key to forward has a Unicode character and is not Return or Enter and no modifier keys are pressed. In that case I can avoid using forward_key_event() by committing a string containing that Unicode character instead. This works no matter what the key code was.

The fix/workaround for this is included in

https://github.com/mike-fabian/ibus-typing-booster/releases/tag/2.19.8