mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-23 02:16:33 +11:00
Fix surrogate pair handling on Windows (#1165)
* Fix surrogate pair handling on Windows * Change high_surrogate to Option<u16> * Format
This commit is contained in:
parent
28a5feef28
commit
c03ef852a4
3 changed files with 27 additions and 6 deletions
|
@ -8,7 +8,8 @@
|
||||||
- On Windows, add touch pressure information for touch events.
|
- On Windows, add touch pressure information for touch events.
|
||||||
- On macOS, differentiate between `CursorIcon::Grab` and `CursorIcon::Grabbing`.
|
- On macOS, differentiate between `CursorIcon::Grab` and `CursorIcon::Grabbing`.
|
||||||
- On Wayland, fix event processing sometimes stalling when using OpenGL with vsync.
|
- On Wayland, fix event processing sometimes stalling when using OpenGL with vsync.
|
||||||
- Officially remove the Emscripten backend
|
- Officially remove the Emscripten backend.
|
||||||
|
- On Windows, fix handling of surrogate pairs when dispatching `ReceivedCharacter`.
|
||||||
- On macOS 10.15, fix freeze upon exiting exclusive fullscreen mode.
|
- On macOS 10.15, fix freeze upon exiting exclusive fullscreen mode.
|
||||||
|
|
||||||
# 0.20.0 Alpha 3 (2019-08-14)
|
# 0.20.0 Alpha 3 (2019-08-14)
|
||||||
|
|
|
@ -1031,11 +1031,29 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
|
|
||||||
winuser::WM_CHAR => {
|
winuser::WM_CHAR => {
|
||||||
use crate::event::WindowEvent::ReceivedCharacter;
|
use crate::event::WindowEvent::ReceivedCharacter;
|
||||||
let chr: char = mem::transmute(wparam as u32);
|
let high_surrogate = 0xD800 <= wparam && wparam <= 0xDBFF;
|
||||||
subclass_input.send_event(Event::WindowEvent {
|
let low_surrogate = 0xDC00 <= wparam && wparam <= 0xDFFF;
|
||||||
window_id: RootWindowId(WindowId(window)),
|
|
||||||
event: ReceivedCharacter(chr),
|
if high_surrogate {
|
||||||
});
|
subclass_input.window_state.lock().high_surrogate = Some(wparam as u16);
|
||||||
|
} else if low_surrogate {
|
||||||
|
let mut window_state = subclass_input.window_state.lock();
|
||||||
|
if let Some(high_surrogate) = window_state.high_surrogate.take() {
|
||||||
|
let pair = [high_surrogate, wparam as u16];
|
||||||
|
if let Some(Ok(chr)) = std::char::decode_utf16(pair.iter().copied()).next() {
|
||||||
|
subclass_input.send_event(Event::WindowEvent {
|
||||||
|
window_id: RootWindowId(WindowId(window)),
|
||||||
|
event: ReceivedCharacter(chr),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let chr: char = mem::transmute(wparam as u32);
|
||||||
|
subclass_input.send_event(Event::WindowEvent {
|
||||||
|
window_id: RootWindowId(WindowId(window)),
|
||||||
|
event: ReceivedCharacter(chr),
|
||||||
|
});
|
||||||
|
}
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ pub struct WindowState {
|
||||||
/// Used to supress duplicate redraw attempts when calling `request_redraw` multiple
|
/// Used to supress duplicate redraw attempts when calling `request_redraw` multiple
|
||||||
/// times in `EventsCleared`.
|
/// times in `EventsCleared`.
|
||||||
pub queued_out_of_band_redraw: bool,
|
pub queued_out_of_band_redraw: bool,
|
||||||
|
pub high_surrogate: Option<u16>,
|
||||||
window_flags: WindowFlags,
|
window_flags: WindowFlags,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,6 +115,7 @@ impl WindowState {
|
||||||
|
|
||||||
fullscreen: None,
|
fullscreen: None,
|
||||||
queued_out_of_band_redraw: false,
|
queued_out_of_band_redraw: false,
|
||||||
|
high_surrogate: None,
|
||||||
window_flags: WindowFlags::empty(),
|
window_flags: WindowFlags::empty(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue