-
Notifications
You must be signed in to change notification settings - Fork 112
Open
Description
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:
rust_minifb/src/os/posix/x11.rs
Lines 363 to 374 in 056c5af
| let empty_string = b"\0"; | |
| (d.lib.XSetLocaleModifiers)(empty_string.as_ptr() as _); | |
| let xim = (d.lib.XOpenIM)( | |
| d.display, | |
| 0 as XrmDatabase, | |
| std::ptr::null_mut::<c_char>(), | |
| std::ptr::null_mut::<c_char>(), | |
| ); | |
| if (xim as usize) == 0 { | |
| return Err(Error::WindowCreate( | |
| "Failed to setup X IM via XOpenIM.".to_owned(), |
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:
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
david0100101