Sinono3 / souvlaki

A cross-platform library for handling OS media controls and metadata.
MIT License
79 stars 15 forks source link

Support HWND directly #29

Closed ShayBox closed 1 year ago

ShayBox commented 1 year ago

Why do you require a *mut c_void then convert it to HWND internally, when every windows library directly gives you HWND.
https://github.com/Sinono3/souvlaki/blob/master/src/platform/windows/mod.rs#L53
How do you even convert HWND to *mut c_void? None of the examples even show using the library with any windows crate.

Sinono3 commented 1 year ago

Hi. In the windows crate, the HWND is just a wrapper around isize. The HWND is practically an IntPtr, therefore converting *mut c_void to HWND is just a cast. To convert it see: Getting a windows-rs HWND from winit?. Not all HWND implementations by different crates are the same. Ex.: in winapi, an empty enum is used. Maybe if we supported HWND directly it would not be HWND but isize.

EDIT: Converting a HWND to *mut c_void should simply be:

use std::ffi::c_void;
let hwnd = HWND(100isize);
let void_ptr = hwnd.0 as *mut c_void;
ShayBox commented 1 year ago

Thank you :+1: