Closed notgull closed 6 months ago
The ptr()
method returns the actual pointer to any handle, not just window handles. Conversely, from_ptr()
can construct a handle from any pointer. These are the escape hatches to integrate with external libraries.
Aren't these enough?
raw-window-handle
has a WindowHandle
type, where it is asserted that the window inside is a valid window handle. It has an unsafe
constructor to assure this. It would be useful to not have to call this unsafe constructor in my own code.
(Note that one of the conditions for a valid window handle is that is has to belong to the calling thread)
I understand that some libraries do use raw-window-handle as a dependency, but WinSafe doesn't. So I don't think it's a good idea to add it as dependency just to have an integration – if so, it would be justifiable to add a dependency to every other library in the world.
Interoperation across library boundaries is inherently unsafe. If you don't feel comfortable using unsafe
blocks in your project, I suggest you to create an interoperation crate to make the bridge between WinSafe and raw-window-handle. This way the unsafe code would be confined there.
It would be nice to be able to use
winsafe
in things likesoftbuffer
. So it would be nice if it exposedraw-window-handle
'sHasWindowHandle
trait on types likeWindowMain
. Even if it was an optional feature that would be nice.