window: macos: fix lalt-` in default config w/ US layout
lalt-` is technically a dead key combo, so we entered dead key processing, then realized that `send_composed_key_when_left_alt_is_pressed == false` and that we should ignore the dead-key-ness of the combo, but returned a composed result, which had the modifiers discarded. The correct way to handle this is to signal that it wasn't dead after all and to allow the main flow to build the KeyEvent as normal.
This commit is contained in:
1 parent
10ea932965
commit
6afc35507c
1 file changed
+12
@@ -1032,6 +1032,7 @@ fn decoration_to_mask(decorations: WindowDecorations) -> NSWindowStyleMask {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct DeadKeyState {
|
||||
/// The private dead key state preserved from UCKeyTranslate
|
||||
dead_state: u32,
|
||||
@@ -1126,9 +1127,11 @@ extern "C" {
|
||||
fn LMGetKbdType() -> u8;
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum TranslateStatus {
|
||||
Composing(String),
|
||||
Composed(String),
|
||||
NotDead,
|
||||
}
|
||||
|
||||
impl Inner {
|
||||
@@ -1232,6 +1235,8 @@ impl Inner {
|
||||
std::slice::from_raw_parts(unicode_buffer.as_mut_ptr(), length as _)
|
||||
})?;
|
||||
return Ok(TranslateStatus::Composing(composing));
|
||||
} else {
|
||||
return Ok(TranslateStatus::NotDead);
|
||||
}
|
||||
length = 0;
|
||||
unsafe {
|
||||
@@ -1975,6 +1980,13 @@ impl WindowView {
|
||||
inner.events.dispatch(WindowEvent::KeyEvent(event));
|
||||
return;
|
||||
}
|
||||
Ok(TranslateStatus::NotDead) => {
|
||||
// Turned out that while it would have been a dead
|
||||
// key combo, our send_composed_key_when_XXX settings
|
||||
// said otherwise. Let's continue as if it was not
|
||||
// a dead key.
|
||||
unmod
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Failed to translate dead key: {}", e);
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user