iced-rs / iced

A cross-platform GUI library for Rust, inspired by Elm
https://iced.rs
MIT License
23.18k stars 1.07k forks source link

Provide native window access, via "fetch_native_handle" method on window. #2200

Closed dtzxporter closed 4 months ago

dtzxporter commented 5 months ago

This should alleviate some of the concerns in: https://github.com/iced-rs/iced/pull/2194#issuecomment-1888517346 because it will force the callback to be ran in the event loop in iced, and gives us a reference to the window directly instead. While the user could mess up the iced state by making changes here, I think that anyone using this method should know what they are doing and it's an advanced use case.

Links:

2194

dtzxporter commented 5 months ago

Will rework this once #2191 lands.

WhyNotHugo commented 1 month ago

How does one get from a iced::widget::shader::wgpu::rwh::WindowHandle to something like a wayland_client::protocol::wl_registry::WlRegistry or even a wayland_client::protocol::wl_shell_surface::WlShellSurface?

What about global protocol objects like wl_output?

hecrj commented 1 month ago

You call as_raw, then pattern match on Wayland, and you keep going from there.

https://docs.rs/iced/latest/iced/widget/shader/wgpu/rwh/enum.RawWindowHandle.html#variant.Wayland

WhyNotHugo commented 1 month ago

I looked at that before asking here, but that variant's associated type is:

pub struct WaylandWindowHandle {
    pub surface: NonNull<c_void>,
}

I'm not sure how to operate on a c_void (which is basically a type-erased pointer). Can't this actually be a reference with a proper type instead?