Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making requests with WEnum::Unknown #764

Open
andriyDev opened this issue Oct 21, 2024 · 1 comment
Open

Making requests with WEnum::Unknown #764

andriyDev opened this issue Oct 21, 2024 · 1 comment

Comments

@andriyDev
Copy link

There is currently no way (as far as I can tell) to pass along unknown enum variants through requests. All APIs which take an enum expect a known enum variant.

Motivation

The zwlr_output_head_v1 protocol reports head transforms giving me WEnum<Transform>. I want to write these to disk, then in a future run, send them as part of a request in the zwlr_output_configuration_head_v1 protocol. Unfortunately, since the set_mode protocol takes a Transform instead of a WEnum<Transform>, my conversion is lossy. If the Transform enum is ever extended, my code breaks!

This is not limited to unstable protocols. In theory, you could want to do something similar with the wl_surface protocol (e,g, take the PreferredBufferTransform, and conditionally replace it to some other transform).

@ids1024
Copy link
Member

ids1024 commented Oct 21, 2024

This is relevant for wl_shm::format, where it's probably valid for the compositor to advertise and the client to use a format that isn't part of the enum, but this isn't really documented: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/425.

Exactly how enums like this are supposed to be used seems a bit ambiguous in Wayland, generally. Hopefully https://gitlab.freedesktop.org/wayland/wayland/-/issues/497 can address this. I think we'd want to use WEneum for "open" enums, but just the contained type for closed ones? Though I don't know how that would work with something like zwlr_output_head_v1 where the enum is defined in a different protocol.

andriyDev added a commit to andriyDev/wl-distore that referenced this issue Oct 21, 2024
Until Smithay/wayland-rs#764 is fixed, this is the only solution that works.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants