aboutsummaryrefslogtreecommitdiffstats
path: root/src/win32
diff options
context:
space:
mode:
Diffstat (limited to 'src/win32')
-rw-r--r--src/win32/callback.rs18
-rw-r--r--src/win32/init.rs27
-rw-r--r--src/win32/make_current_guard.rs4
3 files changed, 19 insertions, 30 deletions
diff --git a/src/win32/callback.rs b/src/win32/callback.rs
index 66d88e7..e852eeb 100644
--- a/src/win32/callback.rs
+++ b/src/win32/callback.rs
@@ -1,12 +1,8 @@
use std::mem;
use std::ptr;
-use std::rc::Rc;
use std::cell::RefCell;
use std::sync::mpsc::Sender;
-use std::sync::{
- Arc,
- Mutex
-};
+use std::sync::{Arc, Mutex};
use CursorState;
use Event;
@@ -232,16 +228,12 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
if let Ok(cursor_state) = cstash.cursor_state.lock() {
match *cursor_state {
CursorState::Normal => {
- unsafe {
- user32::SetCursor(user32::LoadCursorW(
- ptr::null_mut(),
- winapi::IDC_ARROW));
- }
+ user32::SetCursor(user32::LoadCursorW(
+ ptr::null_mut(),
+ winapi::IDC_ARROW));
},
CursorState::Grab | CursorState::Hide => {
- unsafe {
- user32::SetCursor(ptr::null_mut());
- }
+ user32::SetCursor(ptr::null_mut());
}
}
}
diff --git a/src/win32/init.rs b/src/win32/init.rs
index d0012e2..0a77cb7 100644
--- a/src/win32/init.rs
+++ b/src/win32/init.rs
@@ -1,11 +1,8 @@
use std::sync::atomic::AtomicBool;
-use std::sync::{
- Arc,
- Mutex
-};
+use std::sync::{Arc, Mutex};
+use std::io;
use std::ptr;
use std::mem;
-use std::os;
use std::thread;
use super::callback;
@@ -41,7 +38,7 @@ pub fn new_window(builder: BuilderAttribs<'static>, builder_sharelists: Option<C
-> Result<Window, CreationError>
{
// initializing variables to be sent to the task
- let title = builder.title.as_slice().utf16_units()
+ let title = builder.title.utf16_units()
.chain(Some(0).into_iter()).collect::<Vec<u16>>(); // title to utf16
let (tx, rx) = channel();
@@ -125,13 +122,13 @@ unsafe fn init(title: Vec<u16>, builder: BuilderAttribs<'static>,
if handle.is_null() {
return Err(OsError(format!("CreateWindowEx function failed: {}",
- os::error_string(os::errno()))));
+ format!("{}", io::Error::last_os_error()))));
}
let hdc = user32::GetDC(handle);
if hdc.is_null() {
let err = Err(OsError(format!("GetDC function failed: {}",
- os::error_string(os::errno()))));
+ format!("{}", io::Error::last_os_error()))));
return err;
}
@@ -191,13 +188,13 @@ unsafe fn init(title: Vec<u16>, builder: BuilderAttribs<'static>,
if handle.is_null() {
return Err(OsError(format!("CreateWindowEx function failed: {}",
- os::error_string(os::errno()))));
+ format!("{}", io::Error::last_os_error()))));
}
let hdc = user32::GetDC(handle);
if hdc.is_null() {
return Err(OsError(format!("GetDC function failed: {}",
- os::error_string(os::errno()))));
+ format!("{}", io::Error::last_os_error()))));
}
WindowWrapper(handle, hdc)
@@ -377,7 +374,7 @@ unsafe fn create_context(extra: Option<(&gl::wgl_extra::Wgl, &BuilderAttribs<'st
Some(extra_functions.CreateContextAttribsARB(hdc.1 as *const libc::c_void,
share as *const libc::c_void,
- attributes.as_slice().as_ptr()))
+ attributes.as_ptr()))
} else {
None
@@ -399,7 +396,7 @@ unsafe fn create_context(extra: Option<(&gl::wgl_extra::Wgl, &BuilderAttribs<'st
if ctxt.is_null() {
return Err(OsError(format!("OpenGL context creation failed: {}",
- os::error_string(os::errno()))));
+ format!("{}", io::Error::last_os_error()))));
}
Ok(ContextWrapper(ctxt as winapi::HGLRC))
@@ -506,12 +503,12 @@ unsafe fn set_pixel_format(hdc: &WindowWrapper, id: libc::c_int) -> Result<(), C
as winapi::UINT, &mut output) == 0
{
return Err(OsError(format!("DescribePixelFormat function failed: {}",
- os::error_string(os::errno()))));
+ format!("{}", io::Error::last_os_error()))));
}
if gdi32::SetPixelFormat(hdc.1, id, &output) == 0 {
return Err(OsError(format!("SetPixelFormat function failed: {}",
- os::error_string(os::errno()))));
+ format!("{}", io::Error::last_os_error()))));
}
Ok(())
@@ -525,7 +522,7 @@ unsafe fn load_opengl32_dll() -> Result<winapi::HMODULE, CreationError> {
if lib.is_null() {
return Err(OsError(format!("LoadLibrary function failed: {}",
- os::error_string(os::errno()))));
+ format!("{}", io::Error::last_os_error()))));
}
Ok(lib)
diff --git a/src/win32/make_current_guard.rs b/src/win32/make_current_guard.rs
index d6bcc8e..2435454 100644
--- a/src/win32/make_current_guard.rs
+++ b/src/win32/make_current_guard.rs
@@ -1,5 +1,5 @@
use std::marker::PhantomData;
-use std::os;
+use std::io;
use libc;
use winapi;
@@ -30,7 +30,7 @@ impl<'a, 'b> CurrentContextGuard<'a, 'b> {
if result == 0 {
return Err(CreationError::OsError(format!("wglMakeCurrent function failed: {}",
- os::error_string(os::errno()))));
+ format!("{}", io::Error::last_os_error()))));
}
Ok(CurrentContextGuard {