Cargo clippy
This commit is contained in:
parent
0583f3de5f
commit
09fc541055
1 changed files with 8 additions and 9 deletions
|
@ -1,8 +1,8 @@
|
||||||
extern crate winapi;
|
extern crate winapi;
|
||||||
|
|
||||||
|
use std::ffi::CString;
|
||||||
use std::ptr::null_mut;
|
use std::ptr::null_mut;
|
||||||
|
|
||||||
use self::winapi::_core::mem::MaybeUninit;
|
|
||||||
use self::winapi::shared::guiddef::GUID;
|
use self::winapi::shared::guiddef::GUID;
|
||||||
use self::winapi::shared::minwindef::{LPARAM, LPVOID, LRESULT, UINT, WPARAM};
|
use self::winapi::shared::minwindef::{LPARAM, LPVOID, LRESULT, UINT, WPARAM};
|
||||||
use self::winapi::shared::windef::{HBRUSH, HGLRC, HICON, HMENU, HWND};
|
use self::winapi::shared::windef::{HBRUSH, HGLRC, HICON, HMENU, HWND};
|
||||||
|
@ -20,7 +20,6 @@ use self::winapi::um::winuser::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::WindowOpenOptions;
|
use crate::WindowOpenOptions;
|
||||||
use std::ffi::CString;
|
|
||||||
|
|
||||||
pub struct Window;
|
pub struct Window;
|
||||||
|
|
||||||
|
@ -29,7 +28,7 @@ impl Window {
|
||||||
pub fn open(options: WindowOpenOptions) -> Self {
|
pub fn open(options: WindowOpenOptions) -> Self {
|
||||||
unsafe {
|
unsafe {
|
||||||
// We generate a unique name for the new window class to prevent name collisions
|
// We generate a unique name for the new window class to prevent name collisions
|
||||||
let mut guid: GUID = MaybeUninit::uninit().assume_init();
|
let mut guid: GUID = std::mem::zeroed();
|
||||||
CoCreateGuid(&mut guid);
|
CoCreateGuid(&mut guid);
|
||||||
let class_name = format!(
|
let class_name = format!(
|
||||||
"Baseview-{:0X}-{:0X}-{:0X}-{:0X}{:0X}-{:0X}{:0X}{:0X}{:0X}{:0X}{:0X}\0",
|
"Baseview-{:0X}-{:0X}-{:0X}-{:0X}{:0X}-{:0X}{:0X}{:0X}{:0X}{:0X}{:0X}\0",
|
||||||
|
@ -46,7 +45,7 @@ impl Window {
|
||||||
guid.Data4[7]
|
guid.Data4[7]
|
||||||
);
|
);
|
||||||
|
|
||||||
let hinstance = GetModuleHandleA(0 as *const i8);
|
let hinstance = GetModuleHandleA(std::ptr::null::<i8>());
|
||||||
let wnd_class = WNDCLASSA {
|
let wnd_class = WNDCLASSA {
|
||||||
// todo: for OpenGL, will use it later
|
// todo: for OpenGL, will use it later
|
||||||
style: CS_OWNDC | CS_HREDRAW | CS_VREDRAW,
|
style: CS_OWNDC | CS_HREDRAW | CS_VREDRAW,
|
||||||
|
@ -58,7 +57,7 @@ impl Window {
|
||||||
hIcon: 0 as HICON,
|
hIcon: 0 as HICON,
|
||||||
hCursor: 0 as HICON,
|
hCursor: 0 as HICON,
|
||||||
hbrBackground: 0 as HBRUSH,
|
hbrBackground: 0 as HBRUSH,
|
||||||
lpszMenuName: 0 as *const i8,
|
lpszMenuName: std::ptr::null::<i8>(),
|
||||||
};
|
};
|
||||||
RegisterClassA(&wnd_class);
|
RegisterClassA(&wnd_class);
|
||||||
|
|
||||||
|
@ -81,8 +80,8 @@ impl Window {
|
||||||
|
|
||||||
let hdc = GetDC(hwnd);
|
let hdc = GetDC(hwnd);
|
||||||
|
|
||||||
let mut pfd: PIXELFORMATDESCRIPTOR = MaybeUninit::uninit().assume_init();
|
let mut pfd: PIXELFORMATDESCRIPTOR = std::mem::zeroed();
|
||||||
pfd.nSize = core::mem::size_of::<PIXELFORMATDESCRIPTOR>() as u16;
|
pfd.nSize = std::mem::size_of::<PIXELFORMATDESCRIPTOR>() as u16;
|
||||||
pfd.nVersion = 1;
|
pfd.nVersion = 1;
|
||||||
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
||||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||||
|
@ -136,7 +135,7 @@ impl Window {
|
||||||
|
|
||||||
fn handle_msg(_window: HWND) -> bool {
|
fn handle_msg(_window: HWND) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut msg: MSG = MaybeUninit::uninit().assume_init();
|
let mut msg: MSG = std::mem::zeroed();
|
||||||
loop {
|
loop {
|
||||||
if PeekMessageA(&mut msg, 0 as HWND, 0, 0, PM_REMOVE) == 0 {
|
if PeekMessageA(&mut msg, 0 as HWND, 0, 0, PM_REMOVE) == 0 {
|
||||||
return true;
|
return true;
|
||||||
|
@ -164,5 +163,5 @@ unsafe extern "system" fn wnd_proc(
|
||||||
return DefWindowProcA(hwnd, msg, w_param, l_param);
|
return DefWindowProcA(hwnd, msg, w_param, l_param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue