x11, android, win32: [ui]size, [u]int -> [ui]32

This commit is contained in:
Andrey Lesnikov 2015-01-13 15:21:36 +03:00
parent d11f63a749
commit 5a4fee967a
10 changed files with 91 additions and 90 deletions

View file

@ -24,9 +24,9 @@ thread_local!(static WINDOW: Rc<RefCell<Option<(winapi::HWND, Sender<Event>)>>>
pub struct ContextHack(pub winapi::HGLRC);
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_gl_version: Option<(uint, uint)>, builder_debug: bool,
builder_gl_version: Option<(u32, u32)>, builder_debug: bool,
builder_vsync: bool, builder_hidden: bool,
builder_sharelists: Option<ContextHack>, builder_multisampling: Option<u16>)
-> Result<Window, CreationError>
@ -140,7 +140,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
if handle.is_null() {
use std::os;
tx.send(Err(OsError(format!("CreateWindowEx function failed: {}",
os::error_string(os::errno() as uint)))));
os::error_string(os::errno() as usize)))));
return;
}
@ -152,7 +152,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
let hdc = unsafe { winapi::GetDC(dummy_window) };
if hdc.is_null() {
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); }
return;
}
@ -180,7 +180,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
if pf_index == 0 {
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); }
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
{
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); }
return;
}
@ -201,7 +201,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
unsafe {
if winapi::SetPixelFormat(dummy_hdc, 1, &pixel_format) == 0 {
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);
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) };
if ctxt.is_null() {
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); }
return;
}
@ -271,7 +271,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
if handle.is_null() {
use std::os;
tx.send(Err(OsError(format!("CreateWindowEx function failed: {}",
os::error_string(os::errno() as uint)))));
os::error_string(os::errno() as usize)))));
return;
}
@ -283,7 +283,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
let hdc = unsafe { winapi::GetDC(real_window) };
if hdc.is_null() {
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); }
return;
}
@ -294,7 +294,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
unsafe {
if winapi::SetPixelFormat(hdc, 1, &pixel_format) == 0 {
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);
return;
}
@ -339,7 +339,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
if ctxt.is_null() {
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); }
return;
}
@ -369,7 +369,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
let lib = unsafe { winapi::LoadLibraryW(name) };
if lib.is_null() {
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 { winapi::DestroyWindow(real_window); }
return;
@ -475,16 +475,16 @@ extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
winapi::WM_SIZE => {
use events::Event::Resized;
let w = winapi::LOWORD(lparam as winapi::DWORD) as uint;
let h = winapi::HIWORD(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 u32;
send_event(window, Resized(w, h));
0
},
winapi::WM_MOVE => {
use events::Event::Moved;
let x = winapi::LOWORD(lparam as winapi::DWORD) as i16 as int;
let y = winapi::HIWORD(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 i32;
send_event(window, Moved(x, y));
0
},
@ -500,8 +500,8 @@ extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
winapi::WM_MOUSEMOVE => {
use events::Event::MouseMoved;
let x = winapi::GET_X_LPARAM(lparam) as int;
let y = winapi::GET_Y_LPARAM(lparam) as int;
let x = winapi::GET_X_LPARAM(lparam) as i32;
let y = winapi::GET_Y_LPARAM(lparam) as i32;
send_event(window, MouseMoved((x, y)));

View file

@ -44,7 +44,7 @@ impl HeadlessContext {
::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.
pub fn get_position(&self) -> Option<(int, int)> {
pub fn get_position(&self) -> Option<(i32, i32)> {
use std::mem;
let mut placement: winapi::WINDOWPLACEMENT = unsafe { mem::zeroed() };
@ -142,11 +142,11 @@ impl Window {
}
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.
pub fn set_position(&self, x: int, y: int) {
pub fn set_position(&self, x: i32, y: i32) {
use libc;
unsafe {
@ -157,7 +157,7 @@ impl Window {
}
/// 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;
let mut rect: winapi::RECT = unsafe { mem::uninitialized() };
@ -166,13 +166,13 @@ impl Window {
}
Some((
(rect.right - rect.left) as uint,
(rect.bottom - rect.top) as uint
(rect.right - rect.left) as u32,
(rect.bottom - rect.top) as u32
))
}
/// 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;
let mut rect: winapi::RECT = unsafe { mem::uninitialized() };
@ -181,13 +181,13 @@ impl Window {
}
Some((
(rect.right - rect.left) as uint,
(rect.bottom - rect.top) as uint
(rect.right - rect.left) as u32,
(rect.bottom - rect.top) as u32
))
}
/// 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;
unsafe {
@ -283,7 +283,7 @@ impl Window {
::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) {

View file

@ -17,10 +17,10 @@ pub struct MonitorID {
/// The position of the monitor in pixels on the desktop.
///
/// 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.
dimensions: (uint, uint),
dimensions: (u32, u32),
}
/// 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.
// 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
let output = {
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 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)
};
@ -113,7 +113,7 @@ impl MonitorID {
}
/// 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
self.dimensions
}
@ -127,7 +127,7 @@ impl MonitorID {
/// This is a Win32-only function for `MonitorID` that returns the position of the
/// monitor on the desktop.
/// 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
}
}