|
2 | 2 | // SPDX-License-Identifier: Apache-2.0 |
3 | 3 | // SPDX-License-Identifier: MIT |
4 | 4 |
|
5 | | -use std::ops::{Deref, DerefMut}; |
6 | | - |
7 | | -use windows_sys::Win32::{ |
8 | | - Foundation::HWND, |
9 | | - UI::WindowsAndMessaging::{ACCEL, WINDOW_LONG_PTR_INDEX}, |
10 | | -}; |
| 5 | +use windows_sys::Win32::{Foundation::HWND, UI::WindowsAndMessaging::WINDOW_LONG_PTR_INDEX}; |
11 | 6 |
|
12 | 7 | pub fn encode_wide<S: AsRef<std::ffi::OsStr>>(string: S) -> Vec<u16> { |
13 | 8 | std::os::windows::prelude::OsStrExt::encode_wide(string.as_ref()) |
14 | 9 | .chain(std::iter::once(0)) |
15 | 10 | .collect() |
16 | 11 | } |
17 | 12 |
|
18 | | -/// ACCEL wrapper to implement Debug |
19 | | -#[derive(Clone)] |
20 | | -#[repr(transparent)] |
21 | | -pub struct Accel(pub ACCEL); |
22 | | - |
23 | | -impl std::fmt::Debug for Accel { |
24 | | - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
25 | | - f.debug_struct("ACCEL") |
26 | | - .field("key", &self.0.key) |
27 | | - .field("cmd", &self.0.cmd) |
28 | | - .field("fVirt", &self.0.fVirt) |
29 | | - .finish() |
30 | | - } |
31 | | -} |
32 | | - |
33 | | -impl Deref for Accel { |
34 | | - type Target = ACCEL; |
35 | | - |
36 | | - fn deref(&self) -> &Self::Target { |
37 | | - &self.0 |
38 | | - } |
39 | | -} |
40 | | - |
41 | | -impl DerefMut for Accel { |
42 | | - fn deref_mut(&mut self) -> &mut Self::Target { |
43 | | - &mut self.0 |
44 | | - } |
45 | | -} |
46 | | - |
47 | 13 | // taken from winit's code base |
48 | 14 | // https://github.com/rust-windowing/winit/blob/ee88e38f13fbc86a7aafae1d17ad3cd4a1e761df/src/platform_impl/windows/util.rs#L138 |
49 | 15 | pub fn get_instance_handle() -> windows_sys::Win32::Foundation::HMODULE { |
|
0 commit comments