michaelforney / swc

a library for making a simple Wayland compositor
MIT License
614 stars 52 forks source link

Add some stubs for newer protocol bits in the data manager, claiming support for protocol version 3. #53

Open alarixnia opened 4 years ago

alarixnia commented 4 years ago

This is enough to allow some SDL2 applications to work, e.g. quakespasm. It was done in my fork of swc that adds support for NetBSD and a new "seat" for the wscons input API, in case you're interested in that.

alarixnia commented 4 years ago
$ crawl
wl_registry@2: error 0: invalid version for global wl_data_device_manager (16): have 1, wanted 3
Failed to initialise SDL: The video driver did not add any displays

I think it's just requesting version 3 for no good reason. It's also just defining stubs for these capabilities in SDL_waylandevents.c:

https://github.com/spurious/SDL-mirror/blob/master/src/video/wayland/SDL_waylandevents.c#L681

SDL_waylandvideo.c requests version 3:

https://github.com/spurious/SDL-mirror/blob/master/src/video/wayland/SDL_waylandvideo.c#L384

I should correct my first post that this actually allows (all?) SDL2 applications to work, except those also using GLEW. I previously had a bug that was preventing non-GL applications from running, but that seems resolved. So you can run milkytracker, Dungeon Crawl, mpv, etc.

michaelforney commented 4 years ago

Thanks for the links. SDL should definitely not be trying to bind version 3 of wl_data_device_manager if the compositor advertises a lower version. That will always result in a protocol error. I submitted a patch to fix that at https://bugzilla.libsdl.org/show_bug.cgi?id=4924.

It looks like SDL does use the v3 request wl_data_offer_set_actions, but I think it may be possible to support v1 and v2 by just making that request conditional on the data device version being >= 3.

On the swc side, I went ahead and pushed support for v2 first, since that was an easy change. For v3, apart from the two stubs you added, I think we also need add wl_data_source.set_actions. Otherwise, if a client makes that request, it will crash the compositor (trying to call a NULL request handler).