@ -82,34 +82,34 @@ impl KeyboardManager {
if ! self . should_ignore_input ( & settings ) {
// If we have a keyboard event this frame
let mut prev_dead_key = self . prev_dead_key ;
for input_event in self . queued_input_events . iter ( ) {
let mut next_dead_key = self . prev_dead_key ;
match input_event {
InputEvent ::KeyEvent ( key_event ) = > {
// And a key was pressed
if key_event . state = = ElementState ::Pressed {
if let Some ( keybinding ) =
self . maybe_get_keybinding ( key_event , & mut prev_dead_key )
{
if let Some ( keybinding ) = self . maybe_get_keybinding ( key_event ) {
EVENT_AGGREGATOR
. send ( UiCommand ::Serial ( SerialCommand ::Keyboard ( keybinding ) ) ) ;
}
next_dead_key = None ;
} else if key_event . state = = ElementState ::Released {
// dead key detect here
if let Dead ( dead_key ) = key_event . logical_key {
prev_dead_key = dead_key ; //should wait for the next input text_with_all_modifiers, and ignore the next ime.
// should wait for the next input text_with_all_modifiers, and ignore the next ime.
next_dead_key = dead_key ;
}
}
}
InputEvent ::ImeInput ( raw_input ) = > {
if prev_dead_key . is_none ( ) {
if self . prev_dead_key . is_none ( ) {
EVENT_AGGREGATOR
. send ( UiCommand ::Serial ( SerialCommand ::Keyboard ( raw_input . to_string ( ) ) ) ) ;
}
}
}
self . prev_dead_key = next_dead_key ;
}
self . prev_dead_key = prev_dead_key ;
}
// Regardless of whether this was a valid keyboard input or not, rest ignoring and
@ -125,29 +125,23 @@ impl KeyboardManager {
self . ignore_input_this_frame | | ( self . logo & & ! settings . use_logo )
}
fn maybe_get_keybinding (
& self ,
key_event : & KeyEvent ,
prev_dead_key : & mut Option < char > ,
) -> Option < String > {
fn maybe_get_keybinding ( & self , key_event : & KeyEvent ) -> Option < String > {
// Determine if this key event represents a key which won't ever
// present text.
if let Some ( key_text ) = is_control_key ( key_event . logical_key ) {
if prev_dead_key . is_some ( ) {
if self . prev_dead_key . is_some ( ) {
//recover dead key to normal character
let real_char = String ::from ( prev_dead_key . unwrap ( ) ) ;
* prev_dead_key = None ;
let real_char = String ::from ( self . prev_dead_key . unwrap ( ) ) ;
Some ( real_char + & self . format_keybinding_string ( true , true , key_text ) )
} else {
Some ( self . format_keybinding_string ( true , true , key_text ) )
}
} else {
let key_text = if prev_dead_key . is_none ( ) {
let key_text = if self . prev_dead_key . is_none ( ) {
key_event . text
} else {
key_event . text_with_all_modifiers ( )
} ;
* prev_dead_key = None ;
if let Some ( ori_key_text ) = key_text {
let mut key_text = ori_key_text ;
if self . alt {