mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-28 07:33:14 -04:00
chore: Fix remaining typos in Rust file
Signed-off-by: John Nunley <dev@notgull.net>
This commit is contained in:
@@ -117,13 +117,13 @@ fn set_dark_mode_for_window(hwnd: HWND, is_dark_mode: bool) -> bool {
|
||||
|
||||
if let Some(set_window_composition_attribute) = *SET_WINDOW_COMPOSITION_ATTRIBUTE {
|
||||
unsafe {
|
||||
// SetWindowCompositionAttribute needs a bigbool (i32), not bool.
|
||||
let mut is_dark_mode_bigbool = BOOL::from(is_dark_mode);
|
||||
// SetWindowCompositionAttribute needs a big_bool (i32), not bool.
|
||||
let mut is_dark_mode_big_bool = BOOL::from(is_dark_mode);
|
||||
|
||||
let mut data = WINDOWCOMPOSITIONATTRIBDATA {
|
||||
Attrib: WCA_USEDARKMODECOLORS,
|
||||
pvData: &mut is_dark_mode_bigbool as *mut _ as _,
|
||||
cbData: std::mem::size_of_val(&is_dark_mode_bigbool) as _,
|
||||
pvData: &mut is_dark_mode_big_bool as *mut _ as _,
|
||||
cbData: std::mem::size_of_val(&is_dark_mode_big_bool) as _,
|
||||
};
|
||||
|
||||
let status = set_window_composition_attribute(hwnd, &mut data);
|
||||
|
||||
@@ -17,7 +17,7 @@ use windows_sys::{
|
||||
pub struct IUnknownVtbl {
|
||||
pub QueryInterface: unsafe extern "system" fn(
|
||||
This: *mut IUnknown,
|
||||
riid: *const GUID,
|
||||
r_iid: *const GUID,
|
||||
ppvObject: *mut *mut c_void,
|
||||
) -> HRESULT,
|
||||
pub AddRef: unsafe extern "system" fn(This: *mut IUnknown) -> u32,
|
||||
@@ -29,43 +29,45 @@ pub struct IDataObjectVtbl {
|
||||
pub parent: IUnknownVtbl,
|
||||
pub GetData: unsafe extern "system" fn(
|
||||
This: *mut IDataObject,
|
||||
pformatetcIn: *const FORMATETC,
|
||||
pmedium: *mut STGMEDIUM,
|
||||
p_format_etc_In: *const FORMATETC,
|
||||
p_medium: *mut STGMEDIUM,
|
||||
) -> HRESULT,
|
||||
pub GetDataHere: unsafe extern "system" fn(
|
||||
This: *mut IDataObject,
|
||||
pformatetc: *const FORMATETC,
|
||||
pmedium: *mut STGMEDIUM,
|
||||
p_format_etc: *const FORMATETC,
|
||||
p_medium: *mut STGMEDIUM,
|
||||
) -> HRESULT,
|
||||
QueryGetData: unsafe extern "system" fn(
|
||||
This: *mut IDataObject,
|
||||
p_format_etc: *const FORMATETC,
|
||||
) -> HRESULT,
|
||||
QueryGetData:
|
||||
unsafe extern "system" fn(This: *mut IDataObject, pformatetc: *const FORMATETC) -> HRESULT,
|
||||
pub GetCanonicalFormatEtc: unsafe extern "system" fn(
|
||||
This: *mut IDataObject,
|
||||
pformatetcIn: *const FORMATETC,
|
||||
pformatetcOut: *mut FORMATETC,
|
||||
p_format_etc_In: *const FORMATETC,
|
||||
p_format_etc_Out: *mut FORMATETC,
|
||||
) -> HRESULT,
|
||||
pub SetData: unsafe extern "system" fn(
|
||||
This: *mut IDataObject,
|
||||
pformatetc: *const FORMATETC,
|
||||
pformatetcOut: *const FORMATETC,
|
||||
p_format_etc: *const FORMATETC,
|
||||
p_format_etcOut: *const FORMATETC,
|
||||
fRelease: BOOL,
|
||||
) -> HRESULT,
|
||||
pub EnumFormatEtc: unsafe extern "system" fn(
|
||||
This: *mut IDataObject,
|
||||
dwDirection: u32,
|
||||
ppenumFormatEtc: *mut *mut IEnumFORMATETC,
|
||||
pp_enumFormatEtc: *mut *mut IEnumFORMATETC,
|
||||
) -> HRESULT,
|
||||
pub DAdvise: unsafe extern "system" fn(
|
||||
This: *mut IDataObject,
|
||||
pformatetc: *const FORMATETC,
|
||||
advf: u32,
|
||||
p_format_etc: *const FORMATETC,
|
||||
a_dvf: u32,
|
||||
pAdvSInk: *const IAdviseSink,
|
||||
pdwConnection: *mut u32,
|
||||
) -> HRESULT,
|
||||
pub DUnadvise: unsafe extern "system" fn(This: *mut IDataObject, dwConnection: u32) -> HRESULT,
|
||||
pub EnumDAdvise: unsafe extern "system" fn(
|
||||
This: *mut IDataObject,
|
||||
ppenumAdvise: *const *const IEnumSTATDATA,
|
||||
pp_enumAdvise: *const *const IEnumSTATDATA,
|
||||
) -> HRESULT,
|
||||
}
|
||||
|
||||
|
||||
@@ -1021,10 +1021,10 @@ pub(super) unsafe extern "system" fn public_window_callback(
|
||||
|
||||
let userdata_ptr = match (userdata, msg) {
|
||||
(0, WM_NCCREATE) => {
|
||||
let createstruct = unsafe { &mut *(lparam as *mut CREATESTRUCTW) };
|
||||
let initdata = unsafe { &mut *(createstruct.lpCreateParams as *mut InitData<'_>) };
|
||||
let create_struct = unsafe { &mut *(lparam as *mut CREATESTRUCTW) };
|
||||
let init_data = unsafe { &mut *(create_struct.lpCreateParams as *mut InitData<'_>) };
|
||||
|
||||
let result = match unsafe { initdata.on_nccreate(window) } {
|
||||
let result = match unsafe { init_data.on_nccreate(window) } {
|
||||
Some(userdata) => unsafe {
|
||||
super::set_window_long(window, GWL_USERDATA, userdata as _);
|
||||
DefWindowProcW(window, msg, wparam, lparam)
|
||||
@@ -1038,11 +1038,11 @@ pub(super) unsafe extern "system" fn public_window_callback(
|
||||
// but we'll make window creation fail here just in case.
|
||||
(0, WM_CREATE) => return -1,
|
||||
(_, WM_CREATE) => unsafe {
|
||||
let createstruct = &mut *(lparam as *mut CREATESTRUCTW);
|
||||
let initdata = createstruct.lpCreateParams;
|
||||
let initdata = &mut *(initdata as *mut InitData<'_>);
|
||||
let create_struct = &mut *(lparam as *mut CREATESTRUCTW);
|
||||
let init_data = create_struct.lpCreateParams;
|
||||
let init_data = &mut *(init_data as *mut InitData<'_>);
|
||||
|
||||
initdata.on_create();
|
||||
init_data.on_create();
|
||||
return DefWindowProcW(window, msg, wparam, lparam);
|
||||
},
|
||||
(0, _) => return unsafe { DefWindowProcW(window, msg, wparam, lparam) },
|
||||
@@ -1147,7 +1147,7 @@ unsafe fn public_window_callback_inner(
|
||||
// on all 4 borders would result in the caption getting drawn by the DWM.
|
||||
//
|
||||
// Another option would be to allow the DWM to paint inside the client area.
|
||||
// Unfortunately this results in janky resize behavior, where the compositor is
|
||||
// Unfortunately this results in inconsistent resize behavior, where the compositor is
|
||||
// ahead of the window surface. Currently, there seems no option to achieve this
|
||||
// with the Windows API.
|
||||
params.rgrc[0].top += 1;
|
||||
@@ -1312,10 +1312,10 @@ unsafe fn public_window_callback_inner(
|
||||
WM_WINDOWPOSCHANGED => {
|
||||
use crate::event::WindowEvent::Moved;
|
||||
|
||||
let windowpos = lparam as *const WINDOWPOS;
|
||||
if unsafe { (*windowpos).flags & SWP_NOMOVE != SWP_NOMOVE } {
|
||||
let window_pos = lparam as *const WINDOWPOS;
|
||||
if unsafe { (*window_pos).flags & SWP_NOMOVE != SWP_NOMOVE } {
|
||||
let physical_position =
|
||||
unsafe { PhysicalPosition::new((*windowpos).x, (*windowpos).y) };
|
||||
unsafe { PhysicalPosition::new((*window_pos).x, (*window_pos).y) };
|
||||
userdata.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window)),
|
||||
event: Moved(physical_position),
|
||||
@@ -1817,18 +1817,18 @@ unsafe fn public_window_callback_inner(
|
||||
}
|
||||
|
||||
WM_TOUCH => {
|
||||
let pcount = super::loword(wparam as u32) as usize;
|
||||
let mut inputs = Vec::with_capacity(pcount);
|
||||
let htouch = lparam;
|
||||
let p_count = super::loword(wparam as u32) as usize;
|
||||
let mut inputs = Vec::with_capacity(p_count);
|
||||
let h_touch = lparam;
|
||||
if unsafe {
|
||||
GetTouchInputInfo(
|
||||
htouch,
|
||||
pcount as u32,
|
||||
h_touch,
|
||||
p_count as u32,
|
||||
inputs.as_mut_ptr(),
|
||||
mem::size_of::<TOUCHINPUT>() as i32,
|
||||
) > 0
|
||||
} {
|
||||
unsafe { inputs.set_len(pcount) };
|
||||
unsafe { inputs.set_len(p_count) };
|
||||
for input in &inputs {
|
||||
let mut location = POINT {
|
||||
x: input.x / 100,
|
||||
@@ -1862,7 +1862,7 @@ unsafe fn public_window_callback_inner(
|
||||
});
|
||||
}
|
||||
}
|
||||
unsafe { CloseTouchInputHandle(htouch) };
|
||||
unsafe { CloseTouchInputHandle(h_touch) };
|
||||
result = ProcResult::Value(0);
|
||||
}
|
||||
|
||||
@@ -2557,7 +2557,7 @@ unsafe fn handle_raw_input(userdata: &ThreadMsgTargetData, data: RAWINPUT) {
|
||||
}
|
||||
|
||||
enum PointerMoveKind {
|
||||
/// Pointer enterd to the window.
|
||||
/// Pointer entered to the window.
|
||||
Enter,
|
||||
/// Pointer leaved the window client area.
|
||||
Leave,
|
||||
|
||||
@@ -399,19 +399,19 @@ impl<T> BufferedEvent<T> {
|
||||
match self {
|
||||
Self::Event(event) => dispatch(event),
|
||||
Self::ScaleFactorChanged(window_id, scale_factor, new_inner_size) => {
|
||||
let user_new_innner_size = Arc::new(Mutex::new(new_inner_size));
|
||||
let user_new_inner_size = Arc::new(Mutex::new(new_inner_size));
|
||||
dispatch(Event::WindowEvent {
|
||||
window_id,
|
||||
event: WindowEvent::ScaleFactorChanged {
|
||||
scale_factor,
|
||||
inner_size_writer: InnerSizeWriter::new(Arc::downgrade(
|
||||
&user_new_innner_size,
|
||||
&user_new_inner_size,
|
||||
)),
|
||||
},
|
||||
});
|
||||
let inner_size = *user_new_innner_size.lock().unwrap();
|
||||
let inner_size = *user_new_inner_size.lock().unwrap();
|
||||
|
||||
drop(user_new_innner_size);
|
||||
drop(user_new_inner_size);
|
||||
|
||||
if inner_size != new_inner_size {
|
||||
let window_flags = unsafe {
|
||||
|
||||
@@ -45,12 +45,12 @@ impl ImeContext {
|
||||
let mut boundary_before_char = 0;
|
||||
|
||||
for (attr, chr) in attrs.into_iter().zip(text.chars()) {
|
||||
let char_is_targetted =
|
||||
let char_is_targeted =
|
||||
attr as u32 == ATTR_TARGET_CONVERTED || attr as u32 == ATTR_TARGET_NOTCONVERTED;
|
||||
|
||||
if first.is_none() && char_is_targetted {
|
||||
if first.is_none() && char_is_targeted {
|
||||
first = Some(boundary_before_char);
|
||||
} else if first.is_some() && last.is_none() && !char_is_targetted {
|
||||
} else if first.is_some() && last.is_none() && !char_is_targeted {
|
||||
last = Some(boundary_before_char);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ use crate::{
|
||||
platform_impl::platform::{
|
||||
event_loop::ProcResult,
|
||||
keyboard_layout::{Layout, LayoutCache, WindowsModifiers, LAYOUT_CACHE},
|
||||
loword, primarylangid, KeyEventExtra,
|
||||
loword, primary_lang_id, KeyEventExtra,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -106,13 +106,13 @@ impl KeyEventBuilder {
|
||||
let mut matcher = || -> MatchResult {
|
||||
match msg_kind {
|
||||
WM_SETFOCUS => {
|
||||
// synthesize keydown events
|
||||
// synthesize key down events
|
||||
let kbd_state = get_async_kbd_state();
|
||||
let key_events = Self::synthesize_kbd_state(ElementState::Pressed, &kbd_state);
|
||||
MatchResult::MessagesToDispatch(self.pending.complete_multi(key_events))
|
||||
}
|
||||
WM_KILLFOCUS => {
|
||||
// sythesize keyup events
|
||||
// synthesize keyup events
|
||||
let kbd_state = get_kbd_state();
|
||||
let key_events = Self::synthesize_kbd_state(ElementState::Released, &kbd_state);
|
||||
MatchResult::MessagesToDispatch(self.pending.complete_multi(key_events))
|
||||
@@ -230,7 +230,7 @@ impl KeyEventBuilder {
|
||||
.unwrap_or(false);
|
||||
if more_char_coming {
|
||||
// No need to produce an event just yet, because there are still more characters that
|
||||
// need to appended to this keyobard event
|
||||
// need to appended to this keyboard event
|
||||
MatchResult::TokenToRemove(pending_token)
|
||||
} else {
|
||||
let mut event_info = self.event_info.lock().unwrap();
|
||||
@@ -328,7 +328,7 @@ impl KeyEventBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
// Allowing nominimal_bool lint because the `is_key_pressed` macro triggers this warning
|
||||
// Allowing nonminimal_bool lint because the `is_key_pressed` macro triggers this warning
|
||||
// and I don't know of another way to resolve it and also keeping the macro
|
||||
#[allow(clippy::nonminimal_bool)]
|
||||
fn synthesize_kbd_state(
|
||||
@@ -454,7 +454,7 @@ impl KeyEventBuilder {
|
||||
return None;
|
||||
}
|
||||
let scancode = scancode as ExScancode;
|
||||
let physical_key = scancode_to_physicalkey(scancode as u32);
|
||||
let physical_key = scancode_to_physical_key(scancode as u32);
|
||||
let mods = if caps_lock_on {
|
||||
WindowsModifiers::CAPS_LOCK
|
||||
} else {
|
||||
@@ -499,7 +499,7 @@ enum PartialText {
|
||||
|
||||
enum PartialLogicalKey {
|
||||
/// Use the text provided by the WM_CHAR messages and report that as a `Character` variant. If
|
||||
/// the text consists of multiple grapheme clusters (user-precieved characters) that means that
|
||||
/// the text consists of multiple grapheme clusters (user-perceived characters) that means that
|
||||
/// dead key could not be combined with the second input, and in that case we should fall back
|
||||
/// to using what would have without a dead-key input.
|
||||
TextOr(Key),
|
||||
@@ -544,7 +544,7 @@ impl PartialKeyEventInfo {
|
||||
} else {
|
||||
new_ex_scancode(lparam_struct.scancode, lparam_struct.extended)
|
||||
};
|
||||
let physical_key = scancode_to_physicalkey(scancode as u32);
|
||||
let physical_key = scancode_to_physical_key(scancode as u32);
|
||||
let location = get_location(scancode, layout.hkl as HKL);
|
||||
|
||||
let kbd_state = get_kbd_state();
|
||||
@@ -589,7 +589,7 @@ impl PartialKeyEventInfo {
|
||||
// We convert dead keys into their character.
|
||||
// The reason for this is that `key_without_modifiers` is designed for key-bindings,
|
||||
// but the US International layout treats `'` (apostrophe) as a dead key and the
|
||||
// reguar US layout treats it a character. In order for a single binding
|
||||
// regular US layout treats it a character. In order for a single binding
|
||||
// configuration to work with both layouts, we forward each dead key as a character.
|
||||
Key::Dead(k) => {
|
||||
if let Some(ch) = k {
|
||||
@@ -741,15 +741,15 @@ fn get_async_kbd_state() -> [u8; 256] {
|
||||
/// every AltGr key-press (and key-release). We check if the current event is a Ctrl event and if
|
||||
/// the next event is a right Alt (AltGr) event. If this is the case, the current event must be the
|
||||
/// fake Ctrl event.
|
||||
fn is_current_fake(curr_info: &PartialKeyEventInfo, next_msg: MSG, layout: &Layout) -> bool {
|
||||
let curr_is_ctrl = matches!(
|
||||
curr_info.logical_key,
|
||||
fn is_current_fake(current_info: &PartialKeyEventInfo, next_msg: MSG, layout: &Layout) -> bool {
|
||||
let current_is_ctrl = matches!(
|
||||
current_info.logical_key,
|
||||
PartialLogicalKey::This(Key::Named(NamedKey::Control))
|
||||
);
|
||||
if layout.has_alt_graph {
|
||||
let next_code = ex_scancode_from_lparam(next_msg.lParam);
|
||||
let next_is_altgr = next_code == 0xE038; // 0xE038 is right alt
|
||||
if curr_is_ctrl && next_is_altgr {
|
||||
if current_is_ctrl && next_is_altgr {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -942,12 +942,12 @@ fn get_location(scancode: ExScancode, hkl: HKL) -> KeyLocation {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn physicalkey_to_scancode(physical_key: PhysicalKey) -> Option<u32> {
|
||||
// See `scancode_to_physicalkey` for more info
|
||||
pub(crate) fn physical_key_to_scancode(physical_key: PhysicalKey) -> Option<u32> {
|
||||
// See `scancode_to_physical_key` for more info
|
||||
|
||||
let hkl = unsafe { GetKeyboardLayout(0) };
|
||||
|
||||
let primary_lang_id = primarylangid(loword(hkl as u32));
|
||||
let primary_lang_id = primary_lang_id(loword(hkl as u32));
|
||||
let is_korean = primary_lang_id as u32 == LANG_KOREAN;
|
||||
|
||||
let code = match physical_key {
|
||||
@@ -1124,7 +1124,7 @@ pub(crate) fn physicalkey_to_scancode(physical_key: PhysicalKey) -> Option<u32>
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn scancode_to_physicalkey(scancode: u32) -> PhysicalKey {
|
||||
pub(crate) fn scancode_to_physical_key(scancode: u32) -> PhysicalKey {
|
||||
// See: https://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html
|
||||
// and: https://www.w3.org/TR/uievents-code/
|
||||
// and: The widget/NativeKeyToDOMCodeName.h file in the firefox source
|
||||
|
||||
@@ -53,7 +53,7 @@ use windows_sys::Win32::{
|
||||
|
||||
use crate::{
|
||||
keyboard::{Key, KeyCode, ModifiersState, NamedKey, NativeKey, PhysicalKey},
|
||||
platform_impl::{loword, primarylangid, scancode_to_physicalkey},
|
||||
platform_impl::{loword, primary_lang_id, scancode_to_physical_key},
|
||||
};
|
||||
|
||||
pub(crate) static LAYOUT_CACHE: Lazy<Mutex<LayoutCache>> =
|
||||
@@ -121,12 +121,12 @@ impl WindowsModifiers {
|
||||
let rshift = key_state[VK_RSHIFT as usize] & 0x80 != 0;
|
||||
|
||||
let control = key_state[VK_CONTROL as usize] & 0x80 != 0;
|
||||
let lcontrol = key_state[VK_LCONTROL as usize] & 0x80 != 0;
|
||||
let rcontrol = key_state[VK_RCONTROL as usize] & 0x80 != 0;
|
||||
let l_control = key_state[VK_LCONTROL as usize] & 0x80 != 0;
|
||||
let r_control = key_state[VK_RCONTROL as usize] & 0x80 != 0;
|
||||
|
||||
let alt = key_state[VK_MENU as usize] & 0x80 != 0;
|
||||
let lalt = key_state[VK_LMENU as usize] & 0x80 != 0;
|
||||
let ralt = key_state[VK_RMENU as usize] & 0x80 != 0;
|
||||
let l_alt = key_state[VK_LMENU as usize] & 0x80 != 0;
|
||||
let r_alt = key_state[VK_RMENU as usize] & 0x80 != 0;
|
||||
|
||||
let caps = key_state[VK_CAPITAL as usize] & 0x01 != 0;
|
||||
|
||||
@@ -134,10 +134,10 @@ impl WindowsModifiers {
|
||||
if shift || lshift || rshift {
|
||||
result.insert(WindowsModifiers::SHIFT);
|
||||
}
|
||||
if control || lcontrol || rcontrol {
|
||||
if control || l_control || r_control {
|
||||
result.insert(WindowsModifiers::CONTROL);
|
||||
}
|
||||
if alt || lalt || ralt {
|
||||
if alt || l_alt || r_alt {
|
||||
result.insert(WindowsModifiers::ALT);
|
||||
}
|
||||
if caps {
|
||||
@@ -335,7 +335,7 @@ impl LayoutCache {
|
||||
if scancode == 0 {
|
||||
continue;
|
||||
}
|
||||
let keycode = match scancode_to_physicalkey(scancode) {
|
||||
let keycode = match scancode_to_physical_key(scancode) {
|
||||
PhysicalKey::Code(code) => code,
|
||||
// TODO: validate that we can skip on unidentified keys (probably never occurs?)
|
||||
_ => continue,
|
||||
@@ -387,7 +387,7 @@ impl LayoutCache {
|
||||
}
|
||||
|
||||
let native_code = NativeKey::Windows(vk as VIRTUAL_KEY);
|
||||
let key_code = match scancode_to_physicalkey(scancode) {
|
||||
let key_code = match scancode_to_physical_key(scancode) {
|
||||
PhysicalKey::Code(code) => code,
|
||||
// TODO: validate that we can skip on unidentified keys (probably never occurs?)
|
||||
_ => continue,
|
||||
@@ -542,7 +542,7 @@ fn is_numpad_specific(vk: VIRTUAL_KEY) -> bool {
|
||||
}
|
||||
|
||||
fn keycode_to_vkey(keycode: KeyCode, hkl: u64) -> VIRTUAL_KEY {
|
||||
let primary_lang_id = primarylangid(loword(hkl as u32));
|
||||
let primary_lang_id = primary_lang_id(loword(hkl as u32));
|
||||
let is_korean = primary_lang_id as u32 == LANG_KOREAN;
|
||||
let is_japanese = primary_lang_id as u32 == LANG_JAPANESE;
|
||||
|
||||
@@ -763,7 +763,7 @@ fn vkey_to_non_char_key(
|
||||
// List of the Web key names and their corresponding platform-native key names:
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
|
||||
|
||||
let primary_lang_id = primarylangid(loword(hkl as u32));
|
||||
let primary_lang_id = primary_lang_id(loword(hkl as u32));
|
||||
let is_korean = primary_lang_id as u32 == LANG_KOREAN;
|
||||
let is_japanese = primary_lang_id as u32 == LANG_JAPANESE;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ pub(crate) use self::{
|
||||
PlatformSpecificEventLoopAttributes,
|
||||
},
|
||||
icon::{SelectedCursor, WinIcon},
|
||||
keyboard::{physicalkey_to_scancode, scancode_to_physicalkey},
|
||||
keyboard::{physical_key_to_scancode, scancode_to_physical_key},
|
||||
monitor::{MonitorHandle, VideoModeHandle},
|
||||
window::Window,
|
||||
};
|
||||
@@ -148,7 +148,7 @@ const fn get_y_lparam(x: u32) -> i16 {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(crate) const fn primarylangid(lgid: u16) -> u16 {
|
||||
pub(crate) const fn primary_lang_id(lgid: u16) -> u16 {
|
||||
lgid & 0x3FF
|
||||
}
|
||||
|
||||
@@ -163,24 +163,26 @@ const fn hiword(x: u32) -> u16 {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
unsafe fn get_window_long(hwnd: HWND, nindex: WINDOW_LONG_PTR_INDEX) -> isize {
|
||||
unsafe fn get_window_long(hwnd: HWND, n_index: WINDOW_LONG_PTR_INDEX) -> isize {
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
return unsafe { windows_sys::Win32::UI::WindowsAndMessaging::GetWindowLongPtrW(hwnd, nindex) };
|
||||
return unsafe {
|
||||
windows_sys::Win32::UI::WindowsAndMessaging::GetWindowLongPtrW(hwnd, n_index)
|
||||
};
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
return unsafe {
|
||||
windows_sys::Win32::UI::WindowsAndMessaging::GetWindowLongW(hwnd, nindex) as isize
|
||||
windows_sys::Win32::UI::WindowsAndMessaging::GetWindowLongW(hwnd, n_index) as isize
|
||||
};
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
unsafe fn set_window_long(hwnd: HWND, nindex: WINDOW_LONG_PTR_INDEX, dwnewlong: isize) -> isize {
|
||||
unsafe fn set_window_long(hwnd: HWND, n_index: WINDOW_LONG_PTR_INDEX, new_long: isize) -> isize {
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
return unsafe {
|
||||
windows_sys::Win32::UI::WindowsAndMessaging::SetWindowLongPtrW(hwnd, nindex, dwnewlong)
|
||||
windows_sys::Win32::UI::WindowsAndMessaging::SetWindowLongPtrW(hwnd, n_index, new_long)
|
||||
};
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
return unsafe {
|
||||
windows_sys::Win32::UI::WindowsAndMessaging::SetWindowLongW(hwnd, nindex, dwnewlong as i32)
|
||||
windows_sys::Win32::UI::WindowsAndMessaging::SetWindowLongW(hwnd, n_index, new_long as i32)
|
||||
as isize
|
||||
};
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ use windows_sys::Win32::{
|
||||
},
|
||||
};
|
||||
|
||||
use super::scancode_to_physicalkey;
|
||||
use super::scancode_to_physical_key;
|
||||
use crate::{
|
||||
event::ElementState,
|
||||
event_loop::DeviceEvents,
|
||||
@@ -152,7 +152,7 @@ pub fn register_all_mice_and_keyboards_for_raw_input(
|
||||
mut window_handle: HWND,
|
||||
filter: DeviceEvents,
|
||||
) -> bool {
|
||||
// RIDEV_DEVNOTIFY: receive hotplug events
|
||||
// RIDEV_DEVNOTIFY: receive hot-plug events
|
||||
// RIDEV_INPUTSINK: receive events even if we're not in the foreground
|
||||
// RIDEV_REMOVE: don't receive device events (requires NULL hwndTarget)
|
||||
let flags = match filter {
|
||||
@@ -249,16 +249,16 @@ pub fn get_keyboard_physical_key(keyboard: RAWKEYBOARD) -> Option<PhysicalKey> {
|
||||
if scancode == 0xE11D || scancode == 0xE02A {
|
||||
// At the hardware (or driver?) level, pressing the Pause key is equivalent to pressing
|
||||
// Ctrl+NumLock.
|
||||
// This equvalence means that if the user presses Pause, the keyboard will emit two
|
||||
// subsequent keypresses:
|
||||
// This equivalence means that if the user presses Pause, the keyboard will emit two
|
||||
// subsequent key presses:
|
||||
// 1, 0xE11D - Which is a left Ctrl (0x1D) with an extension flag (0xE100)
|
||||
// 2, 0x0045 - Which on its own can be interpreted as Pause
|
||||
//
|
||||
// There's another combination which isn't quite an equivalence:
|
||||
// PrtSc used to be Shift+Asterisk. This means that on some keyboards, presssing
|
||||
// PrtSc used to be Shift+Asterisk. This means that on some keyboards, pressing
|
||||
// PrtSc (print screen) produces the following sequence:
|
||||
// 1, 0xE02A - Which is a left shift (0x2A) with an extension flag (0xE000)
|
||||
// 2, 0xE037 - Which is a numpad multiply (0x37) with an exteion flag (0xE000). This on
|
||||
// 2, 0xE037 - Which is a numpad multiply (0x37) with an extension flag (0xE000). This on
|
||||
// its own it can be interpreted as PrtSc
|
||||
//
|
||||
// For this reason, if we encounter the first keypress, we simply ignore it, trusting
|
||||
@@ -284,7 +284,7 @@ pub fn get_keyboard_physical_key(keyboard: RAWKEYBOARD) -> Option<PhysicalKey> {
|
||||
// https://devblogs.microsoft.com/oldnewthing/20080211-00/?p=23503
|
||||
PhysicalKey::Code(KeyCode::NumLock)
|
||||
} else {
|
||||
scancode_to_physicalkey(scancode as u32)
|
||||
scancode_to_physical_key(scancode as u32)
|
||||
};
|
||||
if keyboard.VKey == VK_SHIFT {
|
||||
if let PhysicalKey::Code(code) = physical_key {
|
||||
|
||||
@@ -1406,7 +1406,7 @@ unsafe fn init(
|
||||
let menu = attributes.platform_specific.menu;
|
||||
let fullscreen = attributes.fullscreen.clone();
|
||||
let maximized = attributes.maximized;
|
||||
let mut initdata = InitData {
|
||||
let mut init_data = InitData {
|
||||
event_loop,
|
||||
attributes,
|
||||
window_flags,
|
||||
@@ -1427,7 +1427,7 @@ unsafe fn init(
|
||||
parent.unwrap_or(0),
|
||||
menu.unwrap_or(0),
|
||||
util::get_instance_handle(),
|
||||
&mut initdata as *mut _ as *mut _,
|
||||
&mut init_data as *mut _ as *mut _,
|
||||
)
|
||||
};
|
||||
|
||||
@@ -1442,7 +1442,7 @@ unsafe fn init(
|
||||
|
||||
// If the handle is non-null, then window creation must have succeeded, which means
|
||||
// that we *must* have populated the `InitData.window` field.
|
||||
let win = initdata.window.unwrap();
|
||||
let win = init_data.window.unwrap();
|
||||
|
||||
// Need to set FULLSCREEN or MAXIMIZED after CreateWindowEx
|
||||
// This is because if the size is changed in WM_CREATE, the restored size will be stored in that size.
|
||||
|
||||
@@ -416,7 +416,7 @@ impl WindowFlags {
|
||||
0,
|
||||
);
|
||||
|
||||
// This condition is necessary to avoid having an unrestorable window
|
||||
// This condition is necessary to avoid having an un-restorable window
|
||||
if !new.contains(WindowFlags::MINIMIZED) {
|
||||
SetWindowLongW(window, GWL_STYLE, style as i32);
|
||||
SetWindowLongW(window, GWL_EXSTYLE, style_ex as i32);
|
||||
@@ -450,7 +450,7 @@ impl WindowFlags {
|
||||
let mut style = GetWindowLongW(hwnd, GWL_STYLE) as u32;
|
||||
let style_ex = GetWindowLongW(hwnd, GWL_EXSTYLE) as u32;
|
||||
|
||||
// Frameless style implemented by manually overriding the non-client area in `WM_NCCALCSIZE`.
|
||||
// Frame-less style implemented by manually overriding the non-client area in `WM_NCCALCSIZE`.
|
||||
if !self.contains(WindowFlags::MARKER_DECORATIONS) {
|
||||
style &= !(WS_CAPTION | WS_SIZEBOX);
|
||||
}
|
||||
@@ -525,7 +525,7 @@ impl CursorFlags {
|
||||
|
||||
// We do this check because calling `set_cursor_clip` incessantly will flood the event
|
||||
// loop with `WM_MOUSEMOVE` events, and `refresh_os_cursor` is called by `set_cursor_flags`
|
||||
// which at times gets called once every iteration of the eventloop.
|
||||
// which at times gets called once every iteration of the event loop.
|
||||
if active_cursor_clip != cursor_clip.map(rect_to_tuple) {
|
||||
util::set_cursor_clip(cursor_clip)?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user