Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update winit to version 0.29 #264

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions surfman/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ sm-angle-default = ["sm-angle"]
sm-no-wgl = ["sm-angle-default"]
sm-test = []
sm-wayland-default = []
sm-winit = ["winit"]
sm-winit = ["winit", "sm-raw-window-handle"]
sm-x11 = ["x11"]
sm-raw-window-handle = ["raw-window-handle"]

Expand All @@ -38,8 +38,8 @@ libc = "0.2"
log = "0.4"
sparkle = { version = "0.1", optional = true }
osmesa-sys = { version = "0.1", optional = true }
winit = { version = "0.28.1", optional = true }
raw-window-handle = { version = "0.5", optional = true }
winit = { version = "0.29", optional = true }
raw-window-handle = { version = "0.6", optional = true }

[dev-dependencies]
clap = "2"
Expand Down Expand Up @@ -79,4 +79,4 @@ winapi = { version = "0.3", features = ["d3d11", "libloaderapi", "winbase", "win

[target.'cfg(target_os = "android")'.dependencies]
raw-window-handle = "0.5"
winit = { version = "0.28.1", features = [ "android-native-activity" ] }
winit = { version = "0.29", features = [ "android-native-activity" ] }
12 changes: 8 additions & 4 deletions surfman/src/platform/macos/cgl/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,14 @@ impl Connection {
use raw_window_handle::RawWindowHandle::AppKit;

match raw_handle {
AppKit(handle) => Ok(NativeWidget {
view: NSView(unsafe { msg_send![handle.ns_view as id, retain] }),
opaque: unsafe { msg_send![handle.ns_window as id, isOpaque] },
}),
AppKit(handle) => {
let view = NSView(unsafe { msg_send![handle.ns_view.as_ptr() as id, retain] });
let window: id = unsafe { msg_send![view.0, window] };
Ok(NativeWidget {
view: view,
opaque: unsafe { msg_send![window, isOpaque] },
})
}
_ => Err(Error::IncompatibleNativeWidget),
}
}
Expand Down
45 changes: 29 additions & 16 deletions surfman/src/platform/macos/system/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ use euclid::default::Size2D;
use std::os::raw::c_void;
use std::str::FromStr;

#[cfg(feature = "sm-winit")]
use winit::platform::macos::WindowExtMacOS;
#[cfg(feature = "sm-winit")]
use winit::window::Window;
#[cfg(feature = "sm-winit")]
use raw_window_handle::HasWindowHandle;

/// A no-op connection.
///
Expand Down Expand Up @@ -145,16 +145,25 @@ impl Connection {
&self,
window: &Window,
) -> Result<NativeWidget, Error> {
let ns_view = window.ns_view() as id;
let ns_window = window.ns_window() as id;
if ns_view.is_null() {
return Err(Error::IncompatibleNativeWidget);
}
unsafe {
Ok(NativeWidget {
view: NSView(msg_send![ns_view, retain]),
opaque: msg_send![ns_window as id, isOpaque],
})
use raw_window_handle::RawWindowHandle::AppKit;

let handle = window.window_handle().map_err(|_| Error::IncompatibleNativeWidget)?;
let raw_handle = handle.as_raw();
match raw_handle {
AppKit(handle) => {
let ns_view = handle.ns_view.as_ptr() as id;
if ns_view.is_null() {
return Err(Error::IncompatibleNativeWidget);
}
let ns_window: id = unsafe { msg_send![ns_view, window] };
unsafe {
Ok(NativeWidget {
view: NSView(msg_send![ns_view, retain]),
opaque: msg_send![ns_window, isOpaque],
})
}
}
_ => Err(Error::IncompatibleNativeWidget),
}
}

Expand All @@ -180,10 +189,14 @@ impl Connection {
use raw_window_handle::RawWindowHandle::AppKit;

match raw_handle {
AppKit(handle) => Ok(NativeWidget {
view: NSView(unsafe { msg_send![handle.ns_view as id, retain] }),
opaque: unsafe { msg_send![handle.ns_window as id, isOpaque] },
}),
AppKit(handle) => {
let view = NSView(unsafe { msg_send![handle.ns_view.as_ptr() as id, retain] });
let window: id = unsafe { msg_send![view.0, window] };
Ok(NativeWidget {
view: view,
opaque: unsafe { msg_send![window, isOpaque] },
})
}
_ => Err(Error::IncompatibleNativeWidget),
}
}
Expand Down
2 changes: 1 addition & 1 deletion surfman/src/platform/macos/system/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ impl Drop for ViewInfo {
self.display_link.stop();

// Drop the reference that the callback was holding onto.
mem::transmute_copy::<Arc<VblankCond>, Arc<VblankCond>>(&self.next_vblank);
let _ = mem::transmute_copy::<Arc<VblankCond>, Arc<VblankCond>>(&self.next_vblank);
}
}
}
Expand Down
28 changes: 14 additions & 14 deletions surfman/src/platform/unix/wayland/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ use std::ptr;
use std::sync::Arc;
use wayland_sys::client::{wl_display, wl_proxy, WAYLAND_CLIENT_HANDLE};

#[cfg(feature = "sm-winit")]
use winit::platform::wayland::WindowExtWayland;
#[cfg(feature = "sm-winit")]
use winit::window::Window;

Expand Down Expand Up @@ -164,13 +162,12 @@ impl Connection {
/// Opens the display connection corresponding to the given `winit` window.
#[cfg(feature = "sm-winit")]
pub fn from_winit_window(window: &Window) -> Result<Connection, Error> {
unsafe {
let wayland_display = match window.wayland_display() {
Some(wayland_display) => wayland_display as *mut wl_display,
None => return Err(Error::IncompatibleWinitWindow),
};
Connection::from_wayland_display(wayland_display, false)
}
use raw_window_handle::HasRawDisplayHandle;
let raw_display_handle = match window.raw_display_handle() {
Ok(raw_display_handle) => raw_display_handle,
_ => return Err(Error::ConnectionFailed),
};
Connection::from_raw_display_handle(raw_display_handle)
}

/// Opens the display connection corresponding to the given raw display handle.
Expand All @@ -182,7 +179,7 @@ impl Connection {
use raw_window_handle::WaylandDisplayHandle;
unsafe {
let wayland_display = match raw_handle {
Wayland(WaylandDisplayHandle { display, .. }) => display as *mut wl_display,
Wayland(WaylandDisplayHandle { display, .. }) => display.as_ptr() as *mut wl_display,
_ => return Err(Error::IncompatibleRawDisplayHandle),
};

Expand All @@ -198,11 +195,14 @@ impl Connection {
&self,
window: &Window,
) -> Result<NativeWidget, Error> {
let wayland_surface = match window.wayland_surface() {
Some(wayland_surface) => wayland_surface as *mut wl_proxy,
None => return Err(Error::IncompatibleNativeWidget),
use raw_window_handle::RawWindowHandle;
use raw_window_handle::HasRawWindowHandle;
let wayland_surface = match window.raw_window_handle() {
Ok(RawWindowHandle::Wayland(handle)) => handle.surface.as_ptr() as *mut wl_proxy,
_ => return Err(Error::IncompatibleNativeWidget),
};


// The window's DPI factor is 1.0 when nothing has been rendered to it yet. So use the DPI
// factor of the primary monitor instead, since that's where the window will presumably go
// when actually displayed. (The user might move it somewhere else later, of course.)
Expand Down Expand Up @@ -239,7 +239,7 @@ impl Connection {
use raw_window_handle::RawWindowHandle::Wayland;

let wayland_surface = match raw_handle {
Wayland(handle) => handle.surface as *mut wl_proxy,
Wayland(handle) => handle.surface.as_ptr() as *mut wl_proxy,
_ => return Err(Error::IncompatibleNativeWidget),
};

Expand Down
Loading