RustAudio / baseview

low-level window system interface for audio plugin UIs
Apache License 2.0
259 stars 54 forks source link

Bump raw-window-handle = "0.6.2"? #193

Open GaussianWonder opened 3 weeks ago

GaussianWonder commented 3 weeks ago

Is an update to raw-window-handle possible?

It would allow integration with parented webview windows via wry >=v0.36.0.

The latest I can push in this direction currently is 0.35.2, at that stage wry still accepts HasRawWindowHandle trait.

I notice that keeping support for HasRawWindowHandle in newer versions requires some work, mainly:

raw_window_handle returns Result:

window.rs

unsafe impl<'a> HasRawWindowHandle for Window<'a> {
    fn raw_window_handle(&self) -> Result<RawWindowHandle, HandleError> {
        self.window.raw_window_handle()
    }
}

---WindowHandle accepts NonZero isize:

win/window.rs

unsafe impl HasRawWindowHandle for WindowHandle {
    fn raw_window_handle(&self) -> Result<RawWindowHandle, HandleError> {
        self.hwnd
            .ok_or(HandleError::Unavailable)
            .and_then(|hwnd| NonZeroIsize::new(hwnd as isize).ok_or(HandleError::Unavailable))
            .map(|hwnd| RawWindowHandle::Win32(Win32WindowHandle::new(hwnd)))
    }
}

This is where it occurred to me that these changes might not simply be a change of internal types, it can affect library to library operations, and it can unveil some hidden complexity I might not be aware of.

I am willing to continue working on a fork and making a PR for this, but I am not quite sure if this is the right approach.

On top of keeping support for the HasRawWindowHandle, there is also a HasWindowHandle trait now.