mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
Update for Rustc
This commit is contained in:
parent
ebe32bb2d8
commit
4c5e430dd3
|
@ -38,9 +38,9 @@ git = "https://github.com/servo/rust-core-graphics"
|
|||
git = "https://github.com/servo/rust-core-graphics"
|
||||
|
||||
[target.i686-pc-windows-gnu.dependencies.winapi]
|
||||
version = "^0.0.3"
|
||||
version = "*"
|
||||
features = ["gdi32", "kernel32", "user32"]
|
||||
|
||||
[target.x86_64-pc-windows-gnu.dependencies.winapi]
|
||||
version = "^0.0.3"
|
||||
version = "*"
|
||||
features = ["gdi32", "kernel32", "user32"]
|
||||
|
|
|
@ -25,7 +25,7 @@ fn main() {
|
|||
}
|
||||
|
||||
print!("Please write the number of the monitor to use: ");
|
||||
let num = from_str(stdin().read_line().unwrap().as_slice().trim())
|
||||
let num = stdin().read_line().unwrap().as_slice().trim().parse()
|
||||
.expect("Plase enter a number");
|
||||
let monitor = glutin::get_available_monitors().nth(num).expect("Please enter a valid ID");
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ impl Context {
|
|||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
static VERTEX_DATA: [f32, ..15] = [
|
||||
static VERTEX_DATA: [f32; 15] = [
|
||||
-0.5, -0.5, 1.0, 0.0, 0.0,
|
||||
0.0, 0.5, 0.0, 1.0, 0.0,
|
||||
0.5, -0.5, 0.0, 0.0, 1.0
|
||||
|
|
|
@ -287,7 +287,7 @@ unsafe impl Send for Window {}
|
|||
unsafe impl Sync for Window {}
|
||||
|
||||
#[cfg(feature = "window")]
|
||||
#[deriving(Clone)]
|
||||
#[derive(Clone)]
|
||||
pub struct WindowProxy;
|
||||
|
||||
impl WindowProxy {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#[deriving(Clone, Show, Copy)]
|
||||
#[derive(Clone, Show, Copy)]
|
||||
pub enum Event {
|
||||
/// The size of the window has changed.
|
||||
Resized(uint, uint),
|
||||
|
@ -38,13 +38,13 @@ pub enum Event {
|
|||
|
||||
pub type ScanCode = u8;
|
||||
|
||||
#[deriving(Show, Hash, PartialEq, Eq, Clone, Copy)]
|
||||
#[derive(Show, Hash, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum ElementState {
|
||||
Pressed,
|
||||
Released,
|
||||
}
|
||||
|
||||
#[deriving(Show, Hash, PartialEq, Eq, Clone, Copy)]
|
||||
#[derive(Show, Hash, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum MouseButton {
|
||||
LeftMouseButton,
|
||||
RightMouseButton,
|
||||
|
@ -52,7 +52,7 @@ pub enum MouseButton {
|
|||
OtherMouseButton(u8),
|
||||
}
|
||||
|
||||
#[deriving(Show, Hash, PartialEq, Eq, Clone, Copy)]
|
||||
#[derive(Show, Hash, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum VirtualKeyCode {
|
||||
/// The '1' key over the letters.
|
||||
Key1,
|
||||
|
|
|
@ -68,7 +68,7 @@ mod events;
|
|||
pub struct MonitorID(winimpl::MonitorID);
|
||||
|
||||
/// Error that can happen while creating a window or a headless renderer.
|
||||
#[deriving(Clone, Show, PartialEq, Eq)]
|
||||
#[derive(Clone, Show, PartialEq, Eq)]
|
||||
pub enum CreationError {
|
||||
OsError(String),
|
||||
NotSupported,
|
||||
|
@ -84,7 +84,7 @@ impl std::error::Error for CreationError {
|
|||
}
|
||||
|
||||
/// All APIs related to OpenGL that you can possibly get while using glutin.
|
||||
#[deriving(Show, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Show, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Api {
|
||||
/// The classical OpenGL. Available on Windows, Linux, OS/X.
|
||||
OpenGl,
|
||||
|
@ -575,7 +575,7 @@ impl gl_common::GlFunctionsSource for Window {
|
|||
/// threads.
|
||||
///
|
||||
#[cfg(feature = "window")]
|
||||
#[deriving(Clone)]
|
||||
#[derive(Clone)]
|
||||
pub struct WindowProxy {
|
||||
proxy: winimpl::WindowProxy,
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ unsafe impl Send for Window {}
|
|||
unsafe impl Sync for Window {}
|
||||
|
||||
#[cfg(feature = "window")]
|
||||
#[deriving(Clone)]
|
||||
#[derive(Clone)]
|
||||
pub struct WindowProxy;
|
||||
|
||||
impl WindowProxy {
|
||||
|
|
|
@ -7,6 +7,7 @@ use CreationError::OsError;
|
|||
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use std::sync::mpsc::{Sender, Receiver, channel};
|
||||
|
||||
use libc;
|
||||
use super::gl;
|
||||
|
@ -222,11 +223,12 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
|
|||
|
||||
// loading the extra WGL functions
|
||||
let extra_functions = gl::wgl_extra::Wgl::load_with(|addr| {
|
||||
unsafe {
|
||||
addr.with_c_str(|s| {
|
||||
use libc;
|
||||
gl::wgl::GetProcAddress(s) as *const libc::c_void
|
||||
})
|
||||
use std::c_str::ToCStr;
|
||||
|
||||
unsafe {
|
||||
let addr = addr.to_c_str();
|
||||
gl::wgl::GetProcAddress(addr.as_ptr()) as *const libc::c_void
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -417,7 +419,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
|
|||
}
|
||||
}).detach();
|
||||
|
||||
rx.recv()
|
||||
rx.recv().unwrap()
|
||||
}
|
||||
|
||||
/// Checks that the window is the good one, and if so send the event to it.
|
||||
|
@ -435,7 +437,7 @@ fn send_event(input_window: winapi::HWND, event: Event) {
|
|||
return;
|
||||
}
|
||||
|
||||
sender.send_opt(event).ok(); // ignoring if closed
|
||||
sender.send(event).ok(); // ignoring if closed
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::sync::atomic::AtomicBool;
|
||||
use std::ptr;
|
||||
use std::collections::RingBuf;
|
||||
use std::sync::mpsc::Receiver;
|
||||
use libc;
|
||||
use {CreationError, Event};
|
||||
|
||||
|
@ -89,7 +90,7 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone)]
|
||||
#[derive(Clone)]
|
||||
pub struct WindowProxy;
|
||||
|
||||
impl WindowProxy {
|
||||
|
@ -222,7 +223,7 @@ impl Window {
|
|||
/// See the docs in the crate root file.
|
||||
// TODO: return iterator
|
||||
pub fn wait_events(&self) -> RingBuf<Event> {
|
||||
match self.events_receiver.recv_opt() {
|
||||
match self.events_receiver.recv() {
|
||||
Ok(ev) => {
|
||||
// if the received event is `Closed`, setting `is_closed` to true
|
||||
match ev {
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::collections::RingBuf;
|
|||
/// Win32 implementation of the main `MonitorID` object.
|
||||
pub struct MonitorID {
|
||||
/// The system name of the monitor.
|
||||
name: [winapi::WCHAR, ..32],
|
||||
name: [winapi::WCHAR; 32],
|
||||
|
||||
/// Name to give to the user.
|
||||
readable_name: String,
|
||||
|
|
|
@ -1241,7 +1241,7 @@ pub struct XSetWindowAttributes {
|
|||
#[repr(C)]
|
||||
pub struct XEvent {
|
||||
pub type_: libc::c_int,
|
||||
pad: [libc::c_long, ..24],
|
||||
pad: [libc::c_long; 24],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -1253,7 +1253,7 @@ pub struct XClientMessageEvent {
|
|||
pub window: Window,
|
||||
pub message_type: Atom,
|
||||
pub format: libc::c_int,
|
||||
pub l: [libc::c_long, ..5],
|
||||
pub l: [libc::c_long; 5],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -1435,7 +1435,7 @@ extern "C" {
|
|||
res_class: *mut libc::c_char) -> XIM;
|
||||
|
||||
// TODO: this is a vararg function
|
||||
//pub fn XCreateIC(im: XIM, ...) -> XIC;
|
||||
//pub fn XCreateIC(im: XIM; .) -> XIC;
|
||||
pub fn XCreateIC(im: XIM, a: *const libc::c_char, b: libc::c_long, c: *const libc::c_char,
|
||||
d: Window, e: *const ()) -> XIC;
|
||||
pub fn XDestroyIC(ic: XIC);
|
||||
|
|
|
@ -57,7 +57,7 @@ impl Drop for XWindow {
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone)]
|
||||
#[derive(Clone)]
|
||||
pub struct WindowProxy {
|
||||
x: Arc<XWindow>,
|
||||
}
|
||||
|
@ -302,6 +302,7 @@ impl Window {
|
|||
|
||||
// loading the extra GLX functions
|
||||
let extra_functions = ffi::glx_extra::Glx::load_with(|addr| {
|
||||
use std::c_str::ToCStr;
|
||||
addr.with_c_str(|s| {
|
||||
use libc;
|
||||
ffi::glx::GetProcAddress(s as *const u8) as *const libc::c_void
|
||||
|
@ -355,6 +356,7 @@ impl Window {
|
|||
}
|
||||
|
||||
pub fn set_title(&self, title: &str) {
|
||||
use std::c_str::ToCStr;
|
||||
let c_title = title.to_c_str();
|
||||
unsafe {
|
||||
ffi::XStoreName(self.x.display, self.x.window, c_title.as_ptr());
|
||||
|
@ -494,7 +496,7 @@ impl Window {
|
|||
let written = unsafe {
|
||||
use std::str;
|
||||
|
||||
let mut buffer: [u8, ..16] = [mem::uninitialized(), ..16];
|
||||
let mut buffer: [u8; 16] = [mem::uninitialized(); 16];
|
||||
let raw_ev: *mut ffi::XKeyEvent = event;
|
||||
let count = ffi::Xutf8LookupString(self.x.ic, mem::transmute(raw_ev),
|
||||
mem::transmute(buffer.as_mut_ptr()),
|
||||
|
|
Loading…
Reference in a new issue