Skip to content

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

Merged
hecrj merged 5 commits intoiced-rs:masterfrom
dtzxporter:run-window-callback
Feb 7, 2024
Merged

Provide native window access, via "fetch_native_handle" method on window.#2200
hecrj merged 5 commits intoiced-rs:masterfrom
dtzxporter:run-window-callback

Conversation

@dtzxporter
Copy link
Contributor

This should alleviate some of the concerns in: #2194 (comment) 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 dtzxporter marked this pull request as draft January 17, 2024 23:46
@dtzxporter dtzxporter changed the title Attempt #2 to address native window access, without loaning the raw window handle. Provide native window access, without loaning the raw window handle. Jan 17, 2024
@dtzxporter
Copy link
Contributor Author

Will rework this once #2191 lands.

@dtzxporter dtzxporter closed this Jan 19, 2024
@dtzxporter dtzxporter reopened this Jan 19, 2024
@dtzxporter dtzxporter marked this pull request as ready for review January 19, 2024 19:48
@dtzxporter dtzxporter changed the title Provide native window access, without loaning the raw window handle. Provide native window access, via "request_native_handle" method on window. Jan 19, 2024
@dtzxporter dtzxporter changed the title Provide native window access, via "request_native_handle" method on window. Provide native window access, via "fetch_native_handle" method on window. Jan 24, 2024
@hecrj hecrj added feature New feature or request shell addition labels Feb 7, 2024
@hecrj hecrj added this to the 0.12 milestone Feb 7, 2024
@hecrj hecrj force-pushed the run-window-callback branch from 9a871c1 to f18a814 Compare February 7, 2024 08:47
Copy link
Member

@hecrj hecrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@hecrj hecrj enabled auto-merge February 7, 2024 08:49
@hecrj hecrj merged commit d3619b5 into iced-rs:master Feb 7, 2024
@hecrj hecrj mentioned this pull request May 8, 2024
@WhyNotHugo
Copy link

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
Copy link
Member

hecrj commented May 9, 2024

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
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addition feature New feature or request shell

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments