mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 21:31:29 +11:00
Stop emitting corporate characters in macOS (#1254)
This commit is contained in:
parent
3d28283a81
commit
35a11ae24f
|
@ -1,6 +1,7 @@
|
||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
- On macOS, fix application termination on `ControlFlow::Exit`
|
- On macOS, fix application termination on `ControlFlow::Exit`
|
||||||
|
- On macOS, stop emitting private corporate characters in `ReceivedCharacter` events.
|
||||||
- On X11, fix misreporting DPI factor at startup.
|
- On X11, fix misreporting DPI factor at startup.
|
||||||
- On X11, fix events not being reported when using `run_return`.
|
- On X11, fix events not being reported when using `run_return`.
|
||||||
- On X11, fix key modifiers being incorrectly reported.
|
- On X11, fix key modifiers being incorrectly reported.
|
||||||
|
|
|
@ -452,7 +452,7 @@ extern "C" fn insert_text(this: &Object, _sel: Sel, string: id, _replacement_ran
|
||||||
//let event: id = msg_send![NSApp(), currentEvent];
|
//let event: id = msg_send![NSApp(), currentEvent];
|
||||||
|
|
||||||
let mut events = VecDeque::with_capacity(characters.len());
|
let mut events = VecDeque::with_capacity(characters.len());
|
||||||
for character in string.chars() {
|
for character in string.chars().filter(|c| !is_corporate_character(*c)) {
|
||||||
events.push_back(Event::WindowEvent {
|
events.push_back(Event::WindowEvent {
|
||||||
window_id: WindowId(get_window_id(state.ns_window)),
|
window_id: WindowId(get_window_id(state.ns_window)),
|
||||||
event: WindowEvent::ReceivedCharacter(character),
|
event: WindowEvent::ReceivedCharacter(character),
|
||||||
|
@ -484,7 +484,10 @@ extern "C" fn do_command_by_selector(this: &Object, _sel: Sel, command: Sel) {
|
||||||
} else {
|
} else {
|
||||||
let raw_characters = state.raw_characters.take();
|
let raw_characters = state.raw_characters.take();
|
||||||
if let Some(raw_characters) = raw_characters {
|
if let Some(raw_characters) = raw_characters {
|
||||||
for character in raw_characters.chars() {
|
for character in raw_characters
|
||||||
|
.chars()
|
||||||
|
.filter(|c| !is_corporate_character(*c))
|
||||||
|
{
|
||||||
events.push_back(Event::WindowEvent {
|
events.push_back(Event::WindowEvent {
|
||||||
window_id: WindowId(get_window_id(state.ns_window)),
|
window_id: WindowId(get_window_id(state.ns_window)),
|
||||||
event: WindowEvent::ReceivedCharacter(character),
|
event: WindowEvent::ReceivedCharacter(character),
|
||||||
|
@ -515,6 +518,21 @@ fn get_characters(event: id, ignore_modifiers: bool) -> String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// As defined in: https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/CORPCHAR.TXT
|
||||||
|
fn is_corporate_character(c: char) -> bool {
|
||||||
|
match c {
|
||||||
|
'\u{F700}'..='\u{F747}'
|
||||||
|
| '\u{F802}'..='\u{F84F}'
|
||||||
|
| '\u{F850}'
|
||||||
|
| '\u{F85C}'
|
||||||
|
| '\u{F85D}'
|
||||||
|
| '\u{F85F}'
|
||||||
|
| '\u{F860}'..='\u{F86B}'
|
||||||
|
| '\u{F870}'..='\u{F8FF}' => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieves a layout-independent keycode given an event.
|
// Retrieves a layout-independent keycode given an event.
|
||||||
fn retrieve_keycode(event: id) -> Option<VirtualKeyCode> {
|
fn retrieve_keycode(event: id) -> Option<VirtualKeyCode> {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -571,7 +589,7 @@ extern "C" fn key_down(this: &Object, _sel: Sel, event: id) {
|
||||||
AppState::queue_event(window_event);
|
AppState::queue_event(window_event);
|
||||||
// Emit `ReceivedCharacter` for key repeats
|
// Emit `ReceivedCharacter` for key repeats
|
||||||
if is_repeat && state.is_key_down {
|
if is_repeat && state.is_key_down {
|
||||||
for character in characters.chars() {
|
for character in characters.chars().filter(|c| !is_corporate_character(*c)) {
|
||||||
AppState::queue_event(Event::WindowEvent {
|
AppState::queue_event(Event::WindowEvent {
|
||||||
window_id,
|
window_id,
|
||||||
event: WindowEvent::ReceivedCharacter(character),
|
event: WindowEvent::ReceivedCharacter(character),
|
||||||
|
|
Loading…
Reference in a new issue