parent
82d6ad4616
commit
d2501e8886
13 changed files with 164 additions and 90 deletions
47
crates/gpui/src/platform/windows/wrapper.rs
Normal file
47
crates/gpui/src/platform/windows/wrapper.rs
Normal file
|
@ -0,0 +1,47 @@
|
|||
use std::ops::Deref;
|
||||
|
||||
use windows::Win32::{Foundation::HANDLE, UI::WindowsAndMessaging::HCURSOR};
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub(crate) struct SafeHandle {
|
||||
raw: HANDLE,
|
||||
}
|
||||
|
||||
unsafe impl Send for SafeHandle {}
|
||||
unsafe impl Sync for SafeHandle {}
|
||||
|
||||
impl From<HANDLE> for SafeHandle {
|
||||
fn from(value: HANDLE) -> Self {
|
||||
SafeHandle { raw: value }
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for SafeHandle {
|
||||
type Target = HANDLE;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.raw
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub(crate) struct SafeCursor {
|
||||
raw: HCURSOR,
|
||||
}
|
||||
|
||||
unsafe impl Send for SafeCursor {}
|
||||
unsafe impl Sync for SafeCursor {}
|
||||
|
||||
impl From<HCURSOR> for SafeCursor {
|
||||
fn from(value: HCURSOR) -> Self {
|
||||
SafeCursor { raw: value }
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for SafeCursor {
|
||||
type Target = HCURSOR;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.raw
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue