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] keybindings cannot use key events which have Unicode keysyms not listed in /usr/include/X11/keysymdef.h #497

Closed mike-fabian closed 2 months ago

mike-fabian commented 7 months ago

/usr/include/X11/keysymdef.h contains:

 * For any future extension of the keysyms with characters already
 * found in ISO 10646 / Unicode, the following algorithm shall be
 * used. The new keysym code position will simply be the character's
 * Unicode number plus 0x01000000. The keysym values in the range
 * 0x01000100 to 0x0110ffff are reserved to represent Unicode
 * characters in the range U+0100 to U+10FFFF.

For example a keyboard layout might contain something like:

key <LatR> { [ r, R, U1F62D, U1F923 ] } ; // r R 😭 🤣

so typing AltGr+r would produce the keysym 0x0101f62d. Currently a keybinding in ibus-typing-booster cannot be assigned to such a key.

The reason is:

$ python3
Python 3.12.1 (main, Dec 18 2023, 00:00:00) [GCC 13.2.1 20231205 (Red Hat 13.2.1-6)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi import require_version
>>> require_version('IBus', '1.0')
>>> from gi.repository import IBus
>>> IBus.keyval_name(IBus.KEY_Left)
'Left'
>>> IBus.KEY_Left == IBus.keyval_from_name('Left')
True
>>> IBus.keyval_name(0x0100263a)
'U+263A'
>>> IBus.keyval_from_name('U+263A')
16777215
>>> f'0x{IBus.keyval_from_name('U+263A'):08x}'
'0x00ffffff'

i.e. IBus.keyval_name('0x0100263a') produces the name U+263A but IBus.keyval_from_name('U+263A') cannot convert that back correctly to the key value.

mike-fabian commented 7 months ago

Fixed in https://github.com/mike-fabian/ibus-typing-booster/releases/tag/2.25.1

mike-fabian commented 2 months ago

This changed again in ibus recently:

$ python3 
Python 3.12.3 (main, Apr 17 2024, 00:00:00) [GCC 14.0.1 20240411 (Red Hat 14.0.1-0)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi import require_version
>>> require_version('IBus', '1.0')
>>> 
>>> from gi.repository import IBus
>>> IBus.keyval_name(0x0100263a)
'0x100263a'
>>> f'0x{IBus.keyval_from_name('U+263A'):08x}'
'0x00ffffff'
>>> f'0x{IBus.keyval_from_name('0x100263a'):08x}'
'0x00ffffff'
>>> 
mike-fabian commented 2 months ago

Old:

>>> IBus.keyval_name(0x0100263a)
'U+263A'

New:

>>> IBus.keyval_name(0x0100263a)
'0x100263a'
mike-fabian commented 2 months ago
mfabian@f39:~
$ python3
Python 3.12.3 (main, Apr 17 2024, 00:00:00) [GCC 13.2.1 20240316 (Red Hat 13.2.1-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi import require_version
>>> require_version('IBus', '1.0')
>>> from gi.repository import IBus
>>> IBus.keyval_name(0x0100263a)
'U+263A'
>>> 
mfabian@f39:~
$ rpm -q ibus
ibus-1.5.29-1.fc39.x86_64
mfabian@f39:~
$ 
mike-fabian commented 2 months ago
mfabian@f40:~$ python3
Python 3.12.3 (main, Apr 17 2024, 00:00:00) [GCC 14.0.1 20240411 (Red Hat 14.0.1-0)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi import require_version
>>> require_version('IBus', '1.0')
>>> from gi.repository import IBus
>>> IBus.keyval_name(0x0100263a)
'0x100263a'
>>> 
mfabian@f40:~$ rpm -q ibus
ibus-1.5.30-5.fc40.x86_64
mfabian@f40:~$ 
mike-fabian commented 2 months ago

Actually not all version of ibus-1.5.30 have the new behaviour:

bash-5.2# python3
Python 3.12.3 (main, Apr 17 2024, 00:00:00) [GCC 14.0.1 20240411 (Red Hat 14.0.1-0)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi import require_version
>>> require_version('IBus', '1.0')
>>> from gi.repository import IBus
>>> IBus.keyval_name(0x0100263a)
'U+263A'
>>> 
bash-5.2# rpm -q ibus
ibus-1.5.30-1.fc40.x86_64
bash-5.2# 

I.e. on Fedora 40, ibus-1.5.30-1.fc40.x86_64 still has the old behaviour, ibus-1.5.30-5.fc40.x86_64 has the new behaviour.

mike-fabian commented 2 months ago

This is the commit which changed it: https://github.com/fujiwarat/ibus/commit/e7329cb14de4097ca894ce19d1903a7df28acd78