unix::WindowExt no longer returns pointers for things that aren't actually pointers (#364)

Fixes #256

`get_xlib_window` and `get_xlib_screen_id` previously returned `Option<*mut c_void>` by
casting integer IDs into pointers, which while producing no functionality issues, is
semantically incorrect and rather surprising. Worse still, the docs for `get_xlib_window`
stated that it was in fact a valid pointer.

Additionally, now all `unix::WindowExt` methods return `std::os::raw` types rather than
`libc` types; note that the two versions of `c_void` are not interchangeable in the eyes of
the compiler, so those wanting the `libc` type will need to explicitly cast.

This is a breaking change, and will require some trivial changes to glutin.
This commit is contained in:
Francesca Sunshine 2017-12-17 04:17:26 -05:00 committed by Pierre Krieger
parent 8f18dab061
commit 23e4293179
3 changed files with 26 additions and 27 deletions

View file

@ -5,7 +5,7 @@ use libc;
use std::borrow::Borrow;
use std::{mem, cmp};
use std::sync::{Arc, Mutex};
use std::os::raw::{c_int, c_long, c_uchar};
use std::os::raw::{c_int, c_long, c_uchar, c_ulong, c_void};
use std::thread;
use std::time::Duration;
@ -537,13 +537,13 @@ impl Window2 {
}
#[inline]
pub fn get_xlib_display(&self) -> *mut libc::c_void {
self.x.display.display as *mut libc::c_void
pub fn get_xlib_display(&self) -> *mut c_void {
self.x.display.display as _
}
#[inline]
pub fn get_xlib_screen_id(&self) -> *mut libc::c_void {
self.x.screen_id as *mut libc::c_void
pub fn get_xlib_screen_id(&self) -> c_int {
self.x.screen_id
}
#[inline]
@ -553,20 +553,20 @@ impl Window2 {
#[inline]
pub fn platform_display(&self) -> *mut libc::c_void {
self.x.display.display as *mut libc::c_void
self.x.display.display as _
}
#[inline]
pub fn get_xlib_window(&self) -> *mut libc::c_void {
self.x.window as *mut libc::c_void
pub fn get_xlib_window(&self) -> c_ulong {
self.x.window
}
#[inline]
pub fn platform_window(&self) -> *mut libc::c_void {
self.x.window as *mut libc::c_void
self.x.window as _
}
pub fn get_xcb_connection(&self) -> *mut libc::c_void {
pub fn get_xcb_connection(&self) -> *mut c_void {
unsafe {
(self.x.display.xlib_xcb.XGetXCBConnection)(self.get_xlib_display() as *mut _) as *mut _
}