mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
x11, android, win32: [ui]size, [u]int -> [ui]32
This commit is contained in:
parent
d11f63a749
commit
5a4fee967a
|
@ -13,7 +13,7 @@ android_start!(main);
|
||||||
fn main() { println!("This example requires glutin to be compiled with the `window` feature"); }
|
fn main() { println!("This example requires glutin to be compiled with the `window` feature"); }
|
||||||
|
|
||||||
#[cfg(feature = "window")]
|
#[cfg(feature = "window")]
|
||||||
fn resize_callback(width: uint, height: uint) {
|
fn resize_callback(width: u32, height: u32) {
|
||||||
println!("Window resized to {}x{}", width, height);
|
println!("Window resized to {}x{}", width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ fn resize_callback(width: uint, height: uint) {
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut window = glutin::Window::new().unwrap();
|
let mut window = glutin::Window::new().unwrap();
|
||||||
window.set_title("A fantastic window!");
|
window.set_title("A fantastic window!");
|
||||||
window.set_window_resize_callback(Some(resize_callback as fn(uint, uint)));
|
window.set_window_resize_callback(Some(resize_callback as fn(u32, u32)));
|
||||||
unsafe { window.make_current() };
|
unsafe { window.make_current() };
|
||||||
|
|
||||||
let context = support::load(&window);
|
let context = support::load(&window);
|
||||||
|
|
|
@ -3,7 +3,7 @@ extern crate android_glue;
|
||||||
use libc;
|
use libc;
|
||||||
use std::ffi::{CString};
|
use std::ffi::{CString};
|
||||||
use std::sync::mpsc::{Receiver, channel};
|
use std::sync::mpsc::{Receiver, channel};
|
||||||
use {CreationError, Event, WindowBuilder, MouseCursor};
|
use {CreationError, Event, MouseCursor};
|
||||||
use CreationError::OsError;
|
use CreationError::OsError;
|
||||||
use events::ElementState::{Pressed, Released};
|
use events::ElementState::{Pressed, Released};
|
||||||
use events::Event::{MouseInput, MouseMoved};
|
use events::Event::{MouseInput, MouseMoved};
|
||||||
|
@ -39,13 +39,13 @@ impl MonitorID {
|
||||||
Some("Primary".to_string())
|
Some("Primary".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_dimensions(&self) -> (uint, uint) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "headless")]
|
#[cfg(feature = "headless")]
|
||||||
pub struct HeadlessContext(int);
|
pub struct HeadlessContext(i32);
|
||||||
|
|
||||||
#[cfg(feature = "headless")]
|
#[cfg(feature = "headless")]
|
||||||
impl HeadlessContext {
|
impl HeadlessContext {
|
||||||
|
@ -190,31 +190,31 @@ impl Window {
|
||||||
pub fn hide(&self) {
|
pub fn hide(&self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_position(&self) -> Option<(int, int)> {
|
pub fn get_position(&self) -> Option<(i32, i32)> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_position(&self, _x: int, _y: int) {
|
pub fn set_position(&self, _x: i32, _y: i32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_inner_size(&self) -> Option<(uint, uint)> {
|
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
||||||
let native_window = unsafe { android_glue::get_native_window() };
|
let native_window = unsafe { android_glue::get_native_window() };
|
||||||
|
|
||||||
if native_window.is_null() {
|
if native_window.is_null() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some((
|
Some((
|
||||||
unsafe { ffi::ANativeWindow_getWidth(native_window) } as uint,
|
unsafe { ffi::ANativeWindow_getWidth(native_window) } as u32,
|
||||||
unsafe { ffi::ANativeWindow_getHeight(native_window) } as uint
|
unsafe { ffi::ANativeWindow_getHeight(native_window) } as u32
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_outer_size(&self) -> Option<(uint, uint)> {
|
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
||||||
self.get_inner_size()
|
self.get_inner_size()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_inner_size(&self, _x: uint, _y: uint) {
|
pub fn set_inner_size(&self, _x: u32, _y: u32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_window_proxy(&self) -> WindowProxy {
|
pub fn create_window_proxy(&self) -> WindowProxy {
|
||||||
|
@ -233,7 +233,7 @@ impl Window {
|
||||||
events.push_back(MouseInput(Released, LeftMouseButton));
|
events.push_back(MouseInput(Released, LeftMouseButton));
|
||||||
},
|
},
|
||||||
android_glue::Event::EventMove(x, y) => {
|
android_glue::Event::EventMove(x, y) => {
|
||||||
events.push_back(MouseMoved((x as int, y as int)));
|
events.push_back(MouseMoved((x as i32, y as i32)));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
@ -278,10 +278,10 @@ impl Window {
|
||||||
::Api::OpenGlEs
|
::Api::OpenGlEs
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_window_resize_callback(&mut self, _: Option<fn(uint, uint)>) {
|
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_cursor(&self, cursor: MouseCursor) {
|
pub fn set_cursor(&self, _: MouseCursor) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#[derive(Clone, Show, Copy)]
|
#[derive(Clone, Show, Copy)]
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
/// The size of the window has changed.
|
/// The size of the window has changed.
|
||||||
Resized(usize, usize),
|
Resized(u32, u32),
|
||||||
|
|
||||||
/// The position of the window has changed.
|
/// The position of the window has changed.
|
||||||
Moved(isize, isize),
|
Moved(i32, i32),
|
||||||
|
|
||||||
/// The window has been closed.
|
/// The window has been closed.
|
||||||
Closed,
|
Closed,
|
||||||
|
@ -23,7 +23,7 @@ pub enum Event {
|
||||||
/// The cursor has moved on the window.
|
/// The cursor has moved on the window.
|
||||||
///
|
///
|
||||||
/// The parameter are the (x,y) coords in pixels relative to the top-left corner of the window.
|
/// The parameter are the (x,y) coords in pixels relative to the top-left corner of the window.
|
||||||
MouseMoved((isize, isize)),
|
MouseMoved((i32, i32)),
|
||||||
|
|
||||||
/// A positive value indicates that the wheel was rotated forward, away from the user;
|
/// A positive value indicates that the wheel was rotated forward, away from the user;
|
||||||
/// a negative value indicates that the wheel was rotated backward, toward the user.
|
/// a negative value indicates that the wheel was rotated backward, toward the user.
|
||||||
|
|
28
src/lib.rs
28
src/lib.rs
|
@ -157,10 +157,10 @@ struct BuilderAttribs<'a> {
|
||||||
headless: bool,
|
headless: bool,
|
||||||
strict: bool,
|
strict: bool,
|
||||||
sharing: Option<&'a winimpl::Window>,
|
sharing: Option<&'a winimpl::Window>,
|
||||||
dimensions: Option<(usize, usize)>,
|
dimensions: Option<(u32, u32)>,
|
||||||
title: String,
|
title: String,
|
||||||
monitor: Option<winimpl::MonitorID>,
|
monitor: Option<winimpl::MonitorID>,
|
||||||
gl_version: Option<(usize, usize)>,
|
gl_version: Option<(u32, u32)>,
|
||||||
gl_debug: bool,
|
gl_debug: bool,
|
||||||
vsync: bool,
|
vsync: bool,
|
||||||
visible: bool,
|
visible: bool,
|
||||||
|
@ -207,7 +207,7 @@ impl<'a> WindowBuilder<'a> {
|
||||||
/// Requests the window to be of specific dimensions.
|
/// Requests the window to be of specific dimensions.
|
||||||
///
|
///
|
||||||
/// Width and height are in pixels.
|
/// Width and height are in pixels.
|
||||||
pub fn with_dimensions(mut self, width: usize, height: usize) -> WindowBuilder<'a> {
|
pub fn with_dimensions(mut self, width: u32, height: u32) -> WindowBuilder<'a> {
|
||||||
self.attribs.dimensions = Some((width, height));
|
self.attribs.dimensions = Some((width, height));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ impl<'a> WindowBuilder<'a> {
|
||||||
///
|
///
|
||||||
/// Version is a (major, minor) pair. For example to request OpenGL 3.3
|
/// Version is a (major, minor) pair. For example to request OpenGL 3.3
|
||||||
/// you would pass `(3, 3)`.
|
/// you would pass `(3, 3)`.
|
||||||
pub fn with_gl_version(mut self, version: (usize, usize)) -> WindowBuilder<'a> {
|
pub fn with_gl_version(mut self, version: (u32, u32)) -> WindowBuilder<'a> {
|
||||||
self.attribs.gl_version = Some(version);
|
self.attribs.gl_version = Some(version);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,7 @@ pub struct HeadlessRendererBuilder {
|
||||||
#[cfg(feature = "headless")]
|
#[cfg(feature = "headless")]
|
||||||
impl HeadlessRendererBuilder {
|
impl HeadlessRendererBuilder {
|
||||||
/// Initializes a new `HeadlessRendererBuilder` with default values.
|
/// Initializes a new `HeadlessRendererBuilder` with default values.
|
||||||
pub fn new(width: usize, height: usize) -> HeadlessRendererBuilder {
|
pub fn new(width: u32, height: u32) -> HeadlessRendererBuilder {
|
||||||
HeadlessRendererBuilder {
|
HeadlessRendererBuilder {
|
||||||
attribs: BuilderAttribs {
|
attribs: BuilderAttribs {
|
||||||
headless: true,
|
headless: true,
|
||||||
|
@ -354,7 +354,7 @@ impl HeadlessRendererBuilder {
|
||||||
///
|
///
|
||||||
/// Version is a (major, minor) pair. For example to request OpenGL 3.3
|
/// Version is a (major, minor) pair. For example to request OpenGL 3.3
|
||||||
/// you would pass `(3, 3)`.
|
/// you would pass `(3, 3)`.
|
||||||
pub fn with_gl_version(mut self, version: (usize, usize)) -> HeadlessRendererBuilder {
|
pub fn with_gl_version(mut self, version: (u32, u32)) -> HeadlessRendererBuilder {
|
||||||
self.attribs.gl_version = Some(version);
|
self.attribs.gl_version = Some(version);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -490,7 +490,7 @@ impl Window {
|
||||||
///
|
///
|
||||||
/// Returns `None` if the window no longer exists.
|
/// Returns `None` if the window no longer exists.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_position(&self) -> Option<(isize, isize)> {
|
pub fn get_position(&self) -> Option<(i32, i32)> {
|
||||||
self.window.get_position()
|
self.window.get_position()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,7 +500,7 @@ impl Window {
|
||||||
///
|
///
|
||||||
/// This is a no-op if the window has already been closed.
|
/// This is a no-op if the window has already been closed.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_position(&self, x: isize, y: isize) {
|
pub fn set_position(&self, x: i32, y: i32) {
|
||||||
self.window.set_position(x, y)
|
self.window.set_position(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ impl Window {
|
||||||
///
|
///
|
||||||
/// Returns `None` if the window no longer exists.
|
/// Returns `None` if the window no longer exists.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_inner_size(&self) -> Option<(usize, usize)> {
|
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
||||||
self.window.get_inner_size()
|
self.window.get_inner_size()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,7 +523,7 @@ impl Window {
|
||||||
///
|
///
|
||||||
/// Returns `None` if the window no longer exists.
|
/// Returns `None` if the window no longer exists.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_outer_size(&self) -> Option<(usize, usize)> {
|
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
||||||
self.window.get_outer_size()
|
self.window.get_outer_size()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,7 +533,7 @@ impl Window {
|
||||||
///
|
///
|
||||||
/// This is a no-op if the window has already been closed.
|
/// This is a no-op if the window has already been closed.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_inner_size(&self, x: usize, y: usize) {
|
pub fn set_inner_size(&self, x: u32, y: u32) {
|
||||||
self.window.set_inner_size(x, y)
|
self.window.set_inner_size(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,7 +612,7 @@ impl Window {
|
||||||
/// operating systems) during resize operations. This can be used to repaint
|
/// operating systems) during resize operations. This can be used to repaint
|
||||||
/// during window resizing.
|
/// during window resizing.
|
||||||
#[experimental]
|
#[experimental]
|
||||||
pub fn set_window_resize_callback(&mut self, callback: Option<fn(usize, usize)>) {
|
pub fn set_window_resize_callback(&mut self, callback: Option<fn(u32, u32)>) {
|
||||||
self.window.set_window_resize_callback(callback);
|
self.window.set_window_resize_callback(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -683,7 +683,7 @@ impl HeadlessContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[experimental]
|
#[experimental]
|
||||||
pub fn set_window_resize_callback(&mut self, _: Option<fn(usize, usize)>) {
|
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -760,7 +760,7 @@ impl MonitorID {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the number of pixels currently displayed on the monitor.
|
/// Returns the number of pixels currently displayed on the monitor.
|
||||||
pub fn get_dimensions(&self) -> (usize, usize) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
let &MonitorID(ref id) = self;
|
let &MonitorID(ref id) = self;
|
||||||
id.get_dimensions()
|
id.get_dimensions()
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,9 @@ thread_local!(static WINDOW: Rc<RefCell<Option<(winapi::HWND, Sender<Event>)>>>
|
||||||
pub struct ContextHack(pub winapi::HGLRC);
|
pub struct ContextHack(pub winapi::HGLRC);
|
||||||
unsafe impl Send for ContextHack {}
|
unsafe impl Send for ContextHack {}
|
||||||
|
|
||||||
pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: String,
|
pub fn new_window(builder_dimensions: Option<(u32, u32)>, builder_title: String,
|
||||||
builder_monitor: Option<super::MonitorID>,
|
builder_monitor: Option<super::MonitorID>,
|
||||||
builder_gl_version: Option<(uint, uint)>, builder_debug: bool,
|
builder_gl_version: Option<(u32, u32)>, builder_debug: bool,
|
||||||
builder_vsync: bool, builder_hidden: bool,
|
builder_vsync: bool, builder_hidden: bool,
|
||||||
builder_sharelists: Option<ContextHack>, builder_multisampling: Option<u16>)
|
builder_sharelists: Option<ContextHack>, builder_multisampling: Option<u16>)
|
||||||
-> Result<Window, CreationError>
|
-> Result<Window, CreationError>
|
||||||
|
@ -140,7 +140,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
|
||||||
if handle.is_null() {
|
if handle.is_null() {
|
||||||
use std::os;
|
use std::os;
|
||||||
tx.send(Err(OsError(format!("CreateWindowEx function failed: {}",
|
tx.send(Err(OsError(format!("CreateWindowEx function failed: {}",
|
||||||
os::error_string(os::errno() as uint)))));
|
os::error_string(os::errno() as usize)))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
|
||||||
let hdc = unsafe { winapi::GetDC(dummy_window) };
|
let hdc = unsafe { winapi::GetDC(dummy_window) };
|
||||||
if hdc.is_null() {
|
if hdc.is_null() {
|
||||||
tx.send(Err(OsError(format!("GetDC function failed: {}",
|
tx.send(Err(OsError(format!("GetDC function failed: {}",
|
||||||
os::error_string(os::errno() as uint)))));
|
os::error_string(os::errno() as usize)))));
|
||||||
unsafe { winapi::DestroyWindow(dummy_window); }
|
unsafe { winapi::DestroyWindow(dummy_window); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
|
||||||
|
|
||||||
if pf_index == 0 {
|
if pf_index == 0 {
|
||||||
tx.send(Err(OsError(format!("ChoosePixelFormat function failed: {}",
|
tx.send(Err(OsError(format!("ChoosePixelFormat function failed: {}",
|
||||||
os::error_string(os::errno() as uint)))));
|
os::error_string(os::errno() as usize)))));
|
||||||
unsafe { winapi::DestroyWindow(dummy_window); }
|
unsafe { winapi::DestroyWindow(dummy_window); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
|
||||||
mem::size_of::<winapi::PIXELFORMATDESCRIPTOR>() as winapi::UINT, &mut output) } == 0
|
mem::size_of::<winapi::PIXELFORMATDESCRIPTOR>() as winapi::UINT, &mut output) } == 0
|
||||||
{
|
{
|
||||||
tx.send(Err(OsError(format!("DescribePixelFormat function failed: {}",
|
tx.send(Err(OsError(format!("DescribePixelFormat function failed: {}",
|
||||||
os::error_string(os::errno() as uint)))));
|
os::error_string(os::errno() as usize)))));
|
||||||
unsafe { winapi::DestroyWindow(dummy_window); }
|
unsafe { winapi::DestroyWindow(dummy_window); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
|
||||||
unsafe {
|
unsafe {
|
||||||
if winapi::SetPixelFormat(dummy_hdc, 1, &pixel_format) == 0 {
|
if winapi::SetPixelFormat(dummy_hdc, 1, &pixel_format) == 0 {
|
||||||
tx.send(Err(OsError(format!("SetPixelFormat function failed: {}",
|
tx.send(Err(OsError(format!("SetPixelFormat function failed: {}",
|
||||||
os::error_string(os::errno() as uint)))));
|
os::error_string(os::errno() as usize)))));
|
||||||
winapi::DestroyWindow(dummy_window);
|
winapi::DestroyWindow(dummy_window);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
|
||||||
let ctxt = unsafe { gl::wgl::CreateContext(dummy_hdc as *const libc::c_void) };
|
let ctxt = unsafe { gl::wgl::CreateContext(dummy_hdc as *const libc::c_void) };
|
||||||
if ctxt.is_null() {
|
if ctxt.is_null() {
|
||||||
tx.send(Err(OsError(format!("wglCreateContext function failed: {}",
|
tx.send(Err(OsError(format!("wglCreateContext function failed: {}",
|
||||||
os::error_string(os::errno() as uint)))));
|
os::error_string(os::errno() as usize)))));
|
||||||
unsafe { winapi::DestroyWindow(dummy_window); }
|
unsafe { winapi::DestroyWindow(dummy_window); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
|
||||||
if handle.is_null() {
|
if handle.is_null() {
|
||||||
use std::os;
|
use std::os;
|
||||||
tx.send(Err(OsError(format!("CreateWindowEx function failed: {}",
|
tx.send(Err(OsError(format!("CreateWindowEx function failed: {}",
|
||||||
os::error_string(os::errno() as uint)))));
|
os::error_string(os::errno() as usize)))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
|
||||||
let hdc = unsafe { winapi::GetDC(real_window) };
|
let hdc = unsafe { winapi::GetDC(real_window) };
|
||||||
if hdc.is_null() {
|
if hdc.is_null() {
|
||||||
tx.send(Err(OsError(format!("GetDC function failed: {}",
|
tx.send(Err(OsError(format!("GetDC function failed: {}",
|
||||||
os::error_string(os::errno() as uint)))));
|
os::error_string(os::errno() as usize)))));
|
||||||
unsafe { winapi::DestroyWindow(real_window); }
|
unsafe { winapi::DestroyWindow(real_window); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
|
||||||
unsafe {
|
unsafe {
|
||||||
if winapi::SetPixelFormat(hdc, 1, &pixel_format) == 0 {
|
if winapi::SetPixelFormat(hdc, 1, &pixel_format) == 0 {
|
||||||
tx.send(Err(OsError(format!("SetPixelFormat function failed: {}",
|
tx.send(Err(OsError(format!("SetPixelFormat function failed: {}",
|
||||||
os::error_string(os::errno() as uint)))));
|
os::error_string(os::errno() as usize)))));
|
||||||
winapi::DestroyWindow(real_window);
|
winapi::DestroyWindow(real_window);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -339,7 +339,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
|
||||||
|
|
||||||
if ctxt.is_null() {
|
if ctxt.is_null() {
|
||||||
tx.send(Err(OsError(format!("OpenGL context creation failed: {}",
|
tx.send(Err(OsError(format!("OpenGL context creation failed: {}",
|
||||||
os::error_string(os::errno() as uint)))));
|
os::error_string(os::errno() as usize)))));
|
||||||
unsafe { winapi::DestroyWindow(real_window); }
|
unsafe { winapi::DestroyWindow(real_window); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -369,7 +369,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
|
||||||
let lib = unsafe { winapi::LoadLibraryW(name) };
|
let lib = unsafe { winapi::LoadLibraryW(name) };
|
||||||
if lib.is_null() {
|
if lib.is_null() {
|
||||||
tx.send(Err(OsError(format!("LoadLibrary function failed: {}",
|
tx.send(Err(OsError(format!("LoadLibrary function failed: {}",
|
||||||
os::error_string(os::errno() as uint)))));
|
os::error_string(os::errno() as usize)))));
|
||||||
unsafe { gl::wgl::DeleteContext(context); }
|
unsafe { gl::wgl::DeleteContext(context); }
|
||||||
unsafe { winapi::DestroyWindow(real_window); }
|
unsafe { winapi::DestroyWindow(real_window); }
|
||||||
return;
|
return;
|
||||||
|
@ -475,16 +475,16 @@ extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
||||||
|
|
||||||
winapi::WM_SIZE => {
|
winapi::WM_SIZE => {
|
||||||
use events::Event::Resized;
|
use events::Event::Resized;
|
||||||
let w = winapi::LOWORD(lparam as winapi::DWORD) as uint;
|
let w = winapi::LOWORD(lparam as winapi::DWORD) as u32;
|
||||||
let h = winapi::HIWORD(lparam as winapi::DWORD) as uint;
|
let h = winapi::HIWORD(lparam as winapi::DWORD) as u32;
|
||||||
send_event(window, Resized(w, h));
|
send_event(window, Resized(w, h));
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
|
|
||||||
winapi::WM_MOVE => {
|
winapi::WM_MOVE => {
|
||||||
use events::Event::Moved;
|
use events::Event::Moved;
|
||||||
let x = winapi::LOWORD(lparam as winapi::DWORD) as i16 as int;
|
let x = winapi::LOWORD(lparam as winapi::DWORD) as i32;
|
||||||
let y = winapi::HIWORD(lparam as winapi::DWORD) as i16 as int;
|
let y = winapi::HIWORD(lparam as winapi::DWORD) as i32;
|
||||||
send_event(window, Moved(x, y));
|
send_event(window, Moved(x, y));
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
|
@ -500,8 +500,8 @@ extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
||||||
winapi::WM_MOUSEMOVE => {
|
winapi::WM_MOUSEMOVE => {
|
||||||
use events::Event::MouseMoved;
|
use events::Event::MouseMoved;
|
||||||
|
|
||||||
let x = winapi::GET_X_LPARAM(lparam) as int;
|
let x = winapi::GET_X_LPARAM(lparam) as i32;
|
||||||
let y = winapi::GET_Y_LPARAM(lparam) as int;
|
let y = winapi::GET_Y_LPARAM(lparam) as i32;
|
||||||
|
|
||||||
send_event(window, MouseMoved((x, y)));
|
send_event(window, MouseMoved((x, y)));
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ impl HeadlessContext {
|
||||||
::Api::OpenGl
|
::Api::OpenGl
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_window_resize_callback(&mut self, _: Option<fn(uint, uint)>) {
|
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See the docs in the crate root file.
|
/// See the docs in the crate root file.
|
||||||
pub fn get_position(&self) -> Option<(int, int)> {
|
pub fn get_position(&self) -> Option<(i32, i32)> {
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
let mut placement: winapi::WINDOWPLACEMENT = unsafe { mem::zeroed() };
|
let mut placement: winapi::WINDOWPLACEMENT = unsafe { mem::zeroed() };
|
||||||
|
@ -142,11 +142,11 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
let ref rect = placement.rcNormalPosition;
|
let ref rect = placement.rcNormalPosition;
|
||||||
Some((rect.left as int, rect.top as int))
|
Some((rect.left as i32, rect.top as i32))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See the docs in the crate root file.
|
/// See the docs in the crate root file.
|
||||||
pub fn set_position(&self, x: int, y: int) {
|
pub fn set_position(&self, x: i32, y: i32) {
|
||||||
use libc;
|
use libc;
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -157,7 +157,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See the docs in the crate root file.
|
/// See the docs in the crate root file.
|
||||||
pub fn get_inner_size(&self) -> Option<(uint, uint)> {
|
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
||||||
use std::mem;
|
use std::mem;
|
||||||
let mut rect: winapi::RECT = unsafe { mem::uninitialized() };
|
let mut rect: winapi::RECT = unsafe { mem::uninitialized() };
|
||||||
|
|
||||||
|
@ -166,13 +166,13 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
Some((
|
Some((
|
||||||
(rect.right - rect.left) as uint,
|
(rect.right - rect.left) as u32,
|
||||||
(rect.bottom - rect.top) as uint
|
(rect.bottom - rect.top) as u32
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See the docs in the crate root file.
|
/// See the docs in the crate root file.
|
||||||
pub fn get_outer_size(&self) -> Option<(uint, uint)> {
|
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
||||||
use std::mem;
|
use std::mem;
|
||||||
let mut rect: winapi::RECT = unsafe { mem::uninitialized() };
|
let mut rect: winapi::RECT = unsafe { mem::uninitialized() };
|
||||||
|
|
||||||
|
@ -181,13 +181,13 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
Some((
|
Some((
|
||||||
(rect.right - rect.left) as uint,
|
(rect.right - rect.left) as u32,
|
||||||
(rect.bottom - rect.top) as uint
|
(rect.bottom - rect.top) as u32
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See the docs in the crate root file.
|
/// See the docs in the crate root file.
|
||||||
pub fn set_inner_size(&self, x: uint, y: uint) {
|
pub fn set_inner_size(&self, x: u32, y: u32) {
|
||||||
use libc;
|
use libc;
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -283,7 +283,7 @@ impl Window {
|
||||||
::Api::OpenGl
|
::Api::OpenGl
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_window_resize_callback(&mut self, _: Option<fn(uint, uint)>) {
|
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_cursor(&self, cursor: MouseCursor) {
|
pub fn set_cursor(&self, cursor: MouseCursor) {
|
||||||
|
|
|
@ -17,10 +17,10 @@ pub struct MonitorID {
|
||||||
/// The position of the monitor in pixels on the desktop.
|
/// The position of the monitor in pixels on the desktop.
|
||||||
///
|
///
|
||||||
/// A window that is positionned at these coordinates will overlap the monitor.
|
/// A window that is positionned at these coordinates will overlap the monitor.
|
||||||
position: (uint, uint),
|
position: (u32, u32),
|
||||||
|
|
||||||
/// The current resolution in pixels on the monitor.
|
/// The current resolution in pixels on the monitor.
|
||||||
dimensions: (uint, uint),
|
dimensions: (u32, u32),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Win32 implementation of the main `get_available_monitors` function.
|
/// Win32 implementation of the main `get_available_monitors` function.
|
||||||
|
@ -32,7 +32,7 @@ pub fn get_available_monitors() -> RingBuf<MonitorID> {
|
||||||
|
|
||||||
// enumerating the devices is done by querying device 0, then device 1, then device 2, etc.
|
// enumerating the devices is done by querying device 0, then device 1, then device 2, etc.
|
||||||
// until the query function returns null
|
// until the query function returns null
|
||||||
for id in iter::count(0u, 1) {
|
for id in iter::count(0u32, 1) {
|
||||||
// getting the DISPLAY_DEVICEW object of the current device
|
// getting the DISPLAY_DEVICEW object of the current device
|
||||||
let output = {
|
let output = {
|
||||||
let mut output: winapi::DISPLAY_DEVICEW = unsafe { mem::zeroed() };
|
let mut output: winapi::DISPLAY_DEVICEW = unsafe { mem::zeroed() };
|
||||||
|
@ -72,9 +72,9 @@ pub fn get_available_monitors() -> RingBuf<MonitorID> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let point: &winapi::POINTL = mem::transmute(&dev.union1);
|
let point: &winapi::POINTL = mem::transmute(&dev.union1);
|
||||||
let position = (point.x as uint, point.y as uint);
|
let position = (point.x as u32, point.y as u32);
|
||||||
|
|
||||||
let dimensions = (dev.dmPelsWidth as uint, dev.dmPelsHeight as uint);
|
let dimensions = (dev.dmPelsWidth as u32, dev.dmPelsHeight as u32);
|
||||||
|
|
||||||
(position, dimensions)
|
(position, dimensions)
|
||||||
};
|
};
|
||||||
|
@ -113,7 +113,7 @@ impl MonitorID {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See the docs if the crate root file.
|
/// See the docs if the crate root file.
|
||||||
pub fn get_dimensions(&self) -> (uint, uint) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
// TODO: retreive the dimensions every time this is called
|
// TODO: retreive the dimensions every time this is called
|
||||||
self.dimensions
|
self.dimensions
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ impl MonitorID {
|
||||||
/// This is a Win32-only function for `MonitorID` that returns the position of the
|
/// This is a Win32-only function for `MonitorID` that returns the position of the
|
||||||
/// monitor on the desktop.
|
/// monitor on the desktop.
|
||||||
/// A window that is positionned at these coordinates will overlap the monitor.
|
/// A window that is positionned at these coordinates will overlap the monitor.
|
||||||
pub fn get_position(&self) -> (uint, uint) {
|
pub fn get_position(&self) -> (u32, u32) {
|
||||||
self.position
|
self.position
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@ fn with_c_str<F, T>(s: &str, f: F) -> T where F: FnOnce(*const i8) -> T {
|
||||||
pub struct HeadlessContext {
|
pub struct HeadlessContext {
|
||||||
context: ffi::OSMesaContext,
|
context: ffi::OSMesaContext,
|
||||||
buffer: Vec<u32>,
|
buffer: Vec<u32>,
|
||||||
width: uint,
|
width: u32,
|
||||||
height: uint,
|
height: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HeadlessContext {
|
impl HeadlessContext {
|
||||||
|
@ -25,7 +25,8 @@ impl HeadlessContext {
|
||||||
Ok(HeadlessContext {
|
Ok(HeadlessContext {
|
||||||
width: dimensions.0,
|
width: dimensions.0,
|
||||||
height: dimensions.1,
|
height: dimensions.1,
|
||||||
buffer: ::std::iter::repeat(unsafe { mem::uninitialized() }).take(dimensions.0 * dimensions.1).collect(),
|
buffer: ::std::iter::repeat(unsafe { mem::uninitialized() })
|
||||||
|
.take((dimensions.0 * dimensions.1) as usize).collect(),
|
||||||
context: unsafe {
|
context: unsafe {
|
||||||
let ctxt = ffi::OSMesaCreateContext(0x1908, ptr::null());
|
let ctxt = ffi::OSMesaCreateContext(0x1908, ptr::null());
|
||||||
if ctxt.is_null() {
|
if ctxt.is_null() {
|
||||||
|
@ -59,7 +60,7 @@ impl HeadlessContext {
|
||||||
::Api::OpenGl
|
::Api::OpenGl
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_window_resize_callback(&mut self, _: Option<fn(uint, uint)>) {
|
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -383,7 +383,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_geometry(&self) -> Option<(isize, isize, usize, usize)> {
|
fn get_geometry(&self) -> Option<(i32, i32, u32, u32)> {
|
||||||
unsafe {
|
unsafe {
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
|
@ -402,27 +402,27 @@ impl Window {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some((x as isize, y as isize, width as usize, height as usize))
|
Some((x as i32, y as i32, width as u32, height as u32))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_position(&self) -> Option<(isize, isize)> {
|
pub fn get_position(&self) -> Option<(i32, i32)> {
|
||||||
self.get_geometry().map(|(x, y, _, _)| (x, y))
|
self.get_geometry().map(|(x, y, _, _)| (x, y))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_position(&self, x: isize, y: isize) {
|
pub fn set_position(&self, x: i32, y: i32) {
|
||||||
unsafe { ffi::XMoveWindow(self.x.display, self.x.window, x as libc::c_int, y as libc::c_int) }
|
unsafe { ffi::XMoveWindow(self.x.display, self.x.window, x as libc::c_int, y as libc::c_int) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_inner_size(&self) -> Option<(usize, usize)> {
|
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
|
||||||
self.get_geometry().map(|(_, _, w, h)| (w, h))
|
self.get_geometry().map(|(_, _, w, h)| (w, h))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_outer_size(&self) -> Option<(usize, usize)> {
|
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_inner_size(&self, _x: usize, _y: usize) {
|
pub fn set_inner_size(&self, _x: u32, _y: u32) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,14 +476,14 @@ impl Window {
|
||||||
let (current_width, current_height) = self.current_size.get();
|
let (current_width, current_height) = self.current_size.get();
|
||||||
if current_width != cfg_event.width || current_height != cfg_event.height {
|
if current_width != cfg_event.width || current_height != cfg_event.height {
|
||||||
self.current_size.set((cfg_event.width, cfg_event.height));
|
self.current_size.set((cfg_event.width, cfg_event.height));
|
||||||
events.push_back(Resized(cfg_event.width as usize, cfg_event.height as usize));
|
events.push_back(Resized(cfg_event.width as u32, cfg_event.height as u32));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
ffi::MotionNotify => {
|
ffi::MotionNotify => {
|
||||||
use events::Event::MouseMoved;
|
use events::Event::MouseMoved;
|
||||||
let event: &ffi::XMotionEvent = unsafe { mem::transmute(&xev) };
|
let event: &ffi::XMotionEvent = unsafe { mem::transmute(&xev) };
|
||||||
events.push_back(MouseMoved((event.x as isize, event.y as isize)));
|
events.push_back(MouseMoved((event.x as i32, event.y as i32)));
|
||||||
},
|
},
|
||||||
|
|
||||||
ffi::KeyPress | ffi::KeyRelease => {
|
ffi::KeyPress | ffi::KeyRelease => {
|
||||||
|
@ -609,7 +609,7 @@ impl Window {
|
||||||
::Api::OpenGl
|
::Api::OpenGl
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_window_resize_callback(&mut self, _: Option<fn(usize, usize)>) {
|
pub fn set_window_resize_callback(&mut self, _: Option<fn(u32, u32)>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_cursor(&self, cursor: MouseCursor) {
|
pub fn set_cursor(&self, cursor: MouseCursor) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::collections::RingBuf;
|
||||||
use super::super::ffi;
|
use super::super::ffi;
|
||||||
use super::ensure_thread_init;
|
use super::ensure_thread_init;
|
||||||
|
|
||||||
pub struct MonitorID(pub usize);
|
pub struct MonitorID(pub u32);
|
||||||
|
|
||||||
pub fn get_available_monitors() -> RingBuf<MonitorID> {
|
pub fn get_available_monitors() -> RingBuf<MonitorID> {
|
||||||
ensure_thread_init();
|
ensure_thread_init();
|
||||||
|
@ -18,7 +18,7 @@ pub fn get_available_monitors() -> RingBuf<MonitorID> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut monitors = RingBuf::new();
|
let mut monitors = RingBuf::new();
|
||||||
monitors.extend(range(0, nb_monitors).map(|i| MonitorID(i as usize)));
|
monitors.extend(range(0, nb_monitors).map(|i| MonitorID(i as u32)));
|
||||||
monitors
|
monitors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ pub fn get_primary_monitor() -> MonitorID {
|
||||||
primary_monitor
|
primary_monitor
|
||||||
};
|
};
|
||||||
|
|
||||||
MonitorID(primary_monitor as usize)
|
MonitorID(primary_monitor as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonitorID {
|
impl MonitorID {
|
||||||
|
@ -43,7 +43,7 @@ impl MonitorID {
|
||||||
Some(format!("Monitor #{}", screen_num))
|
Some(format!("Monitor #{}", screen_num))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_dimensions(&self) -> (usize, usize) {
|
pub fn get_dimensions(&self) -> (u32, u32) {
|
||||||
let dimensions = unsafe {
|
let dimensions = unsafe {
|
||||||
let display = ffi::XOpenDisplay(ptr::null());
|
let display = ffi::XOpenDisplay(ptr::null());
|
||||||
let MonitorID(screen_num) = *self;
|
let MonitorID(screen_num) = *self;
|
||||||
|
@ -51,7 +51,7 @@ impl MonitorID {
|
||||||
let width = ffi::XWidthOfScreen(screen);
|
let width = ffi::XWidthOfScreen(screen);
|
||||||
let height = ffi::XHeightOfScreen(screen);
|
let height = ffi::XHeightOfScreen(screen);
|
||||||
ffi::XCloseDisplay(display);
|
ffi::XCloseDisplay(display);
|
||||||
(width as usize, height as usize)
|
(width as u32, height as u32)
|
||||||
};
|
};
|
||||||
|
|
||||||
dimensions
|
dimensions
|
||||||
|
|
Loading…
Reference in a new issue