Skip to content

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

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

hecrj merged 5 commits into
iced-rs:masterfrom
dtzxporter:run-window-callback

Conversation

@dtzxporter

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

@hecrj hecrj left a comment

Copy link
Copy Markdown
Member

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

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

hecrj commented May 9, 2024

Copy link
Copy Markdown
Member

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

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?

hahnavi pushed a commit to hahnavi/iced that referenced this pull request Sep 26, 2026
Provide native window access, via "fetch_native_handle" method on window.
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