rust-windowing / winit

Window handling library in pure Rust

Home Page:https://docs.rs/winit/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Panic when _XSETTINGS_SETTINGS property is not found

pcapriotti opened this issue · comments

I'm getting a crash when creating an event loop on linux:

thread 'main' panicked at /home/paolo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.13/src/platform_impl/linux/x11/xsettings.rs:42:14:
called `Result::unwrap()` on an `Err` value: TypeMismatch(0)

Looking at the code, it seems the culprit is:

        // Read the _XSETTINGS_SETTINGS property.
        let data: Vec<u8> = self
            .get_property(
                owner.owner,
                atoms[_XSETTINGS_SETTINGS],
                atoms[_XSETTINGS_SETTINGS],
            )
            .unwrap();

which panics if _XSETTINGS_SETTINGS is not found. I'm running a somewhat minimal desktop setup with the i3 window manager, and I guess that property doesn't get set. Bypassing that code and simply returning Ok(None) makes the application work for me, so I think this should return with Err instead of panicking.

So your system reports that it has xsettings, allows to set property, etc, but then once you fetch the property it thinks that it doesn't exist.

Well I guess x11 is just x11 yet again.

also, all of that works fine on my i3 and on my i3 setup, the extension is not even present, so this code is never getting called. So you clearly have something in your setup that somehow makes certain parts of xsettings work, it's just the rest is broken.

It could be that my setup is broken. Although everything else seems to work fine. Running xsettingsd seems to fix it, so I guess that's a viable workaround for me.

In any case, maybe it's a good idea to return with an error here instead of panicking anyway? There doesn't seem any advantage in panicking, since there are fallback mechanisms for determining dpi, if I'm not mistaken.

I'll fix it, it's just why it even tells that you have xsettings, when you don't actually have xsettings.