window: remove some dead code on Windows
Since removing non-GL usage, this code is dead.
This commit is contained in:
1 parent
957ad6af90
commit
0ef89f3de0
3 files changed
+3
-129
No files matched your search
@@ -1,120 +0,0 @@
|
||||
use crate::bitmaps::BitmapImage;
|
||||
use anyhow::bail;
|
||||
use std::io::Error as IoError;
|
||||
use winapi::shared::windef::*;
|
||||
use winapi::um::wingdi::*;
|
||||
|
||||
pub struct GdiBitmap {
|
||||
hdc: HDC,
|
||||
hbitmap: HBITMAP,
|
||||
data: *mut u8,
|
||||
width: usize,
|
||||
height: usize,
|
||||
}
|
||||
|
||||
impl BitmapImage for GdiBitmap {
|
||||
unsafe fn pixel_data(&self) -> *const u8 {
|
||||
self.data
|
||||
}
|
||||
|
||||
unsafe fn pixel_data_mut(&mut self) -> *mut u8 {
|
||||
self.data
|
||||
}
|
||||
|
||||
fn image_dimensions(&self) -> (usize, usize) {
|
||||
(self.width, self.height)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for GdiBitmap {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
DeleteObject(self.hbitmap as _);
|
||||
}
|
||||
unsafe {
|
||||
DeleteObject(self.hdc as _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GdiBitmap {
|
||||
pub fn hdc(&self) -> HDC {
|
||||
self.hdc
|
||||
}
|
||||
|
||||
pub fn hbitmap(&self) -> HBITMAP {
|
||||
self.hbitmap
|
||||
}
|
||||
|
||||
/// A helper for initializing a window
|
||||
pub(crate) fn new_empty() -> Self {
|
||||
Self {
|
||||
hdc: std::ptr::null_mut(),
|
||||
hbitmap: std::ptr::null_mut(),
|
||||
data: std::ptr::null_mut(),
|
||||
width: 0,
|
||||
height: 0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_compatible(width: usize, height: usize, hdc: HDC) -> anyhow::Result<Self> {
|
||||
let hdc = unsafe { CreateCompatibleDC(hdc) };
|
||||
if hdc.is_null() {
|
||||
let err = IoError::last_os_error();
|
||||
bail!("CreateCompatibleDC: {}", err);
|
||||
}
|
||||
|
||||
let mut data = std::ptr::null_mut();
|
||||
let bmi = BITMAPINFO {
|
||||
bmiHeader: BITMAPINFOHEADER {
|
||||
biSize: std::mem::size_of::<BITMAPINFOHEADER>() as u32,
|
||||
biPlanes: 1,
|
||||
biBitCount: 32,
|
||||
biWidth: width as i32,
|
||||
// Windows bitmaps are upside-down vs. the rest of the world, so
|
||||
// we need to supply a negative height here:
|
||||
// https://stackoverflow.com/a/9023702/149111
|
||||
biHeight: -(height as i32),
|
||||
biClrImportant: 0,
|
||||
biClrUsed: 0,
|
||||
biCompression: 0,
|
||||
biSizeImage: width as u32 * height as u32 * 4,
|
||||
biXPelsPerMeter: 0,
|
||||
biYPelsPerMeter: 0,
|
||||
},
|
||||
bmiColors: [RGBQUAD {
|
||||
rgbBlue: 0,
|
||||
rgbRed: 0,
|
||||
rgbGreen: 0,
|
||||
rgbReserved: 0,
|
||||
}],
|
||||
};
|
||||
let hbitmap = unsafe {
|
||||
CreateDIBSection(
|
||||
hdc,
|
||||
&bmi,
|
||||
DIB_RGB_COLORS,
|
||||
&mut data,
|
||||
std::ptr::null_mut(),
|
||||
0,
|
||||
)
|
||||
};
|
||||
|
||||
if hbitmap.is_null() {
|
||||
let err = IoError::last_os_error();
|
||||
bail!("CreateDIBSection: {}", err);
|
||||
}
|
||||
|
||||
unsafe {
|
||||
SelectObject(hdc, hbitmap as _);
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
hdc,
|
||||
hbitmap,
|
||||
data: data as *mut u8,
|
||||
width,
|
||||
height,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
pub mod connection;
|
||||
pub mod event;
|
||||
pub mod gdi;
|
||||
mod wgl;
|
||||
pub mod window;
|
||||
|
||||
pub use self::window::*;
|
||||
pub use connection::*;
|
||||
pub use event::*;
|
||||
pub use gdi::*;
|
||||
|
||||
/// Convert a rust string to a windows wide string
|
||||
fn wide_string(s: &str) -> Vec<u16> {
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
use super::gdi::*;
|
||||
use super::*;
|
||||
use crate::bitmaps::*;
|
||||
use crate::color::Color;
|
||||
use crate::connection::ConnectionOps;
|
||||
use crate::{
|
||||
config, Clipboard, Dimensions, KeyCode, KeyEvent, Modifiers, MouseButtons, MouseCursor,
|
||||
MouseEvent, MouseEventKind, MousePress, Operator, Point, Rect, ScreenPoint, WindowCallbacks,
|
||||
WindowOps, WindowOpsMut,
|
||||
MouseEvent, MouseEventKind, MousePress, Point, Rect, ScreenPoint, WindowCallbacks, WindowOps,
|
||||
WindowOpsMut,
|
||||
};
|
||||
use anyhow::{bail, Context};
|
||||
use lazy_static::lazy_static;
|
||||
@@ -26,7 +23,6 @@ use winapi::shared::ntdef::*;
|
||||
use winapi::shared::windef::*;
|
||||
use winapi::um::imm::*;
|
||||
use winapi::um::libloaderapi::GetModuleHandleW;
|
||||
use winapi::um::wingdi::*;
|
||||
use winapi::um::winuser::*;
|
||||
use winreg::{enums::HKEY_CURRENT_USER, RegKey};
|
||||
|
||||
@@ -718,7 +714,7 @@ unsafe fn wm_paint(hwnd: HWND, _msg: UINT, _wparam: WPARAM, _lparam: LPARAM) ->
|
||||
},
|
||||
rgbReserved: [0; 32],
|
||||
};
|
||||
let dc = BeginPaint(hwnd, &mut ps);
|
||||
let _ = BeginPaint(hwnd, &mut ps);
|
||||
|
||||
let mut rect = RECT {
|
||||
left: 0,
|
||||
|
||||
Reference in new issue
Block a user