Ran rustfmt

This commit is contained in:
Daniel Collin 2015-11-27 23:47:15 +01:00
parent 15ec55aae2
commit 860f8b4f3d

View file

@ -24,10 +24,11 @@ struct BitmapInfo {
pub bmi_colors: [RGBQUAD; 3], pub bmi_colors: [RGBQUAD; 3],
} }
unsafe extern "system" fn wnd_proc(window: winapi::HWND, msg: winapi::UINT, unsafe extern "system" fn wnd_proc(window: winapi::HWND,
wparam: winapi::WPARAM, lparam: winapi::LPARAM) msg: winapi::UINT,
-> winapi::LRESULT wparam: winapi::WPARAM,
{ lparam: winapi::LPARAM)
-> winapi::LRESULT {
match msg { match msg {
winapi::winuser::WM_KEYDOWN => { winapi::winuser::WM_KEYDOWN => {
if (wparam & 0xff) == 27 { if (wparam & 0xff) == 27 {
@ -57,7 +58,15 @@ unsafe extern "system" fn wnd_proc(window: winapi::HWND, msg: winapi::UINT,
let dc = user32::GetDC(window); let dc = user32::GetDC(window);
gdi32::StretchDIBits(dc, 0, 0, width, height, 0, 0, width, height, gdi32::StretchDIBits(dc,
0,
0,
width,
height,
0,
0,
width,
height,
mem::transmute(buffer), mem::transmute(buffer),
mem::transmute(&bitmap_info), mem::transmute(&bitmap_info),
winapi::wingdi::DIB_RGB_COLORS, winapi::wingdi::DIB_RGB_COLORS,
@ -109,21 +118,33 @@ impl Minifb {
user32::RegisterClassW(&class); user32::RegisterClassW(&class);
let mut rect = winapi::RECT { let mut rect = winapi::RECT {
left: 0, right: width as winapi::LONG, left: 0,
top: 0, bottom: height as winapi::LONG, right: width as winapi::LONG,
top: 0,
bottom: height as winapi::LONG,
}; };
user32::AdjustWindowRect(&mut rect, winapi::WS_POPUP | winapi::WS_SYSMENU | winapi::WS_CAPTION, 0); user32::AdjustWindowRect(&mut rect,
winapi::WS_POPUP | winapi::WS_SYSMENU | winapi::WS_CAPTION,
0);
rect.right -= rect.left; rect.right -= rect.left;
rect.bottom -= rect.top; rect.bottom -= rect.top;
let handle = user32::CreateWindowExA(0, let handle = user32::CreateWindowExA(0,
"minifb_window".as_ptr() as *mut _, s.as_ptr(), "minifb_window".as_ptr() as *mut _,
winapi::WS_OVERLAPPEDWINDOW & !winapi::WS_MAXIMIZEBOX & !winapi::WS_THICKFRAME, s.as_ptr(),
winapi::CW_USEDEFAULT, winapi::CW_USEDEFAULT, winapi::WS_OVERLAPPEDWINDOW &
rect.right, rect.bottom, !winapi::WS_MAXIMIZEBOX &
ptr::null_mut(), ptr::null_mut(), ptr::null_mut(), ptr::null_mut()); !winapi::WS_THICKFRAME,
winapi::CW_USEDEFAULT,
winapi::CW_USEDEFAULT,
rect.right,
rect.bottom,
ptr::null_mut(),
ptr::null_mut(),
ptr::null_mut(),
ptr::null_mut());
if !handle.is_null() { if !handle.is_null() {
user32::ShowWindow(handle, winapi::SW_NORMAL); user32::ShowWindow(handle, winapi::SW_NORMAL);
@ -146,10 +167,13 @@ impl Minifb {
unsafe { unsafe {
let mut msg = mem::uninitialized(); let mut msg = mem::uninitialized();
user32::SetWindowLongPtrW(self.window, winapi::winuser::GWLP_USERDATA, buffer.as_ptr() as i64); user32::SetWindowLongPtrW(self.window,
winapi::winuser::GWLP_USERDATA,
buffer.as_ptr() as i64);
user32::InvalidateRect(self.window, ptr::null_mut(), winapi::TRUE); user32::InvalidateRect(self.window, ptr::null_mut(), winapi::TRUE);
while user32::PeekMessageW(&mut msg, self.window, 0, 0, winapi::winuser::PM_REMOVE) != 0 { while user32::PeekMessageW(&mut msg, self.window, 0, 0, winapi::winuser::PM_REMOVE) !=
0 {
user32::TranslateMessage(&mut msg); user32::TranslateMessage(&mut msg);
user32::DispatchMessageW(&mut msg); user32::DispatchMessageW(&mut msg);
} }
@ -160,6 +184,3 @@ impl Minifb {
} }
} }
} }