API to get wayland-rs connection and surface from a window
mwcampbell opened this issue · comments
raw-window-handle
lets us get the libwayland pointers, but that's unsafe, and it's up to the caller to ensure that the pointers are only used while the connection and surface are alive.
I think I need this in accesskit_winit
for the implementation of the new Wayland accessibility protocol extension. The current prototype is unsound, and as far as I can tell, the only other way to resolve that would be to add a lifetime parameter to the Adapter
struct, which would significantly complicate things for users.
Yet another version of raw-window-handle
would be disruptive to the ecosystem. So I propose methods on WaylandWindowExt
. It doesn't matter if these methods return the Backend
and ObjectId
, or the Connection
and WlSurface
, since both are safe.
I also suggest doing this as a non-semver-breaking fix, since a new semver-breaking version of winit is also an ecosystem-breaking event.
See #3317
The general solution would be to have Owned
handle that you basically consume which implements HasWindowHandle
thus it'll ref-count winit. You can also see wgpu
on how they handle the safe
handles.
Keep in mind that other handles are not really safer, since winit can destroy the surface, close connection, etc, unless there's a ref-counting.
If you're really concerned about stuff like that, run your own event queue for now, which is more robust.