You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The get_xlib_window returns a value that is defined by the X11 API to be Wffi::indow (which is a typedef to c_ulong), but casts it to *mut c_void.
Likewise, get_xlib_screen_id returns a value defined by the X11 API to be a c_int, but casts it to *mut c_void.
My understanding of the X11 API is very light, but this seems wrong to do so, especially given depending on the architecture, these types are not guaranteed to even be the same size.
Do you have some insight regarding this @Ralith ? (pinging you as you seem to have a fair amount of knowledge of X11)
When get_xlib_window is used by glutin, it's either cast right back to ffi::Window (here) or used as ffi::EGLNativeWindowType to later be passed to eglCreateWindowSurface (here). Looking at the official example, that function does expect the window ID, so casting the value itself into a pointer does seem to be correct, albeit unintuitive, since it's being used for type erasure.
Sorry, this must have slipped through the cracks. I don't know of any reason why we shouldn't be using the proper C types here; it seems we're only getting away with it by coincidence.
Activity
francesca64 commentedon Dec 15, 2017
When
get_xlib_windowis used by glutin, it's either cast right back toffi::Window(here) or used asffi::EGLNativeWindowTypeto later be passed toeglCreateWindowSurface(here). Looking at the official example, that function does expect the window ID, so casting the value itself into a pointer does seem to be correct, albeit unintuitive, since it's being used for type erasure.While
ffi::Windowisn't guaranteed to be pointer-sized, I can't imagine it will ever be larger, and as far as I can tell Rust treats these pointer conversions just like it would any ordinary integer cast. In other words, this should always work.Ralith commentedon Dec 15, 2017
Sorry, this must have slipped through the cracks. I don't know of any reason why we shouldn't be using the proper C types here; it seems we're only getting away with it by coincidence.
unix::WindowExt no longer returns pointers for things that aren't act…
unix::WindowExt no longer returns pointers for things that aren't act…
unix::WindowExt no longer returns pointers for things that aren't act…
Merge next back to dev branch (rust-windowing#305)