mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 14:21:31 +11:00
Miscellaneous small changes (#1238)
* Use a slice instead of a new object * Remove unnecessary 'into_iter' * Use 'and_then' instead of 'map_or'
This commit is contained in:
parent
6608a0241d
commit
05a1f4280c
|
@ -208,7 +208,7 @@ pub fn scancode_to_keycode(scancode: c_ushort) -> Option<VirtualKeyCode> {
|
|||
// While F1-F20 have scancodes we can match on, we have to check against UTF-16
|
||||
// constants for the rest.
|
||||
// https://developer.apple.com/documentation/appkit/1535851-function-key_unicodes?preferredLanguage=occ
|
||||
pub fn check_function_keys(string: &String) -> Option<VirtualKeyCode> {
|
||||
pub fn check_function_keys(string: &str) -> Option<VirtualKeyCode> {
|
||||
if let Some(ch) = string.encode_utf16().next() {
|
||||
return Some(match ch {
|
||||
0xf718 => VirtualKeyCode::F21,
|
||||
|
|
|
@ -248,7 +248,6 @@ impl MonitorHandle {
|
|||
assert!(!array.is_null(), "failed to get list of display modes");
|
||||
let array_count = CFArrayGetCount(array);
|
||||
let modes: Vec<_> = (0..array_count)
|
||||
.into_iter()
|
||||
.map(move |i| {
|
||||
let mode = CFArrayGetValueAtIndex(array, i) as *mut _;
|
||||
ffi::CGDisplayModeRetain(mode);
|
||||
|
|
|
@ -520,10 +520,7 @@ fn retrieve_keycode(event: id) -> Option<VirtualKeyCode> {
|
|||
#[inline]
|
||||
fn get_code(ev: id, raw: bool) -> Option<VirtualKeyCode> {
|
||||
let characters = get_characters(ev, raw);
|
||||
characters
|
||||
.chars()
|
||||
.next()
|
||||
.map_or(None, |c| char_to_keycode(c))
|
||||
characters.chars().next().and_then(|c| char_to_keycode(c))
|
||||
}
|
||||
|
||||
// Cmd switches Roman letters for Dvorak-QWERTY layout, so we try modified characters first.
|
||||
|
|
Loading…
Reference in a new issue