XSetLocaleModifiers breaks XOpenIM if you have XMODIFIERS
On my setup, which I understand is probably vanishingly uncommon by now, all minifb apps crash on startup with:
thread 'main' panicked at examples/char_callback.rs:29:6:
Unable to create the window: Failed to create window, "Failed to setup X IM via XOpenIM."
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
This is coming from here:
https://github.com/emoon/rust_minifb/blob/056c5afef1388247ca976f0edabd171a4393f3ed/src/os/posix/x11.rs#L363-L374
It appears that, on my system, im-config (an ubuntu-ism, maybe?), has set XMODIFIERS=@im=ibus in:
% fgrep -r XMODIFIERS /etc 2>/dev/null
/etc/X11/Xsession.d/70im-config_launch:if [ -z "$XMODIFIERS" ] && \
/etc/X11/Xsession.d/70im-config_launch: export XMODIFIERS
..and that the XSetLocaleModifiers undoes this, and XOpenIm isn't happy about it.
I couldn't really work out what's going on here:
https://github.com/mirror/libX11/blob/ff8706a5eae25b8bafce300527079f68a201d27f/src/xlibi18n/lcWrap.c#L291-L295
The documentation for XSetLocaleModifiers mentions the XMODIFIERS environment variable, but it's not super clear to me if it's supposed to be overridden or appended or ...
Possible fixes:
- remove that
XSetLocaleModifierscall, which works fine on my machine, it appears to work fine with or without the environment variable set. - don't do it if the environment variable is set, assuming the user knows what they're doing (lol not me)
- workaround: document that you have to clear
XMODIFIERS=to run any minifb app
environment:
- amd64 ubuntu 24.04
- i3wm HEAD 'cos the packaged one has weird issues with screen blanking on my amd card (???)
LC_*:en_GB.UTF-8, but not fixed byLC_ALL=Cim-configpointing atibus- explicitly launching
ibus-daemon -d -ron startup - using
setxkbmapto switch between keyboard layouts
Thanks for the report. I will have a look.
I'm experiencing the same issue, I'm running CachyOS as my operating system