Compare commits

...

3 Commits

View File

@ -102,8 +102,12 @@ pub mod c {
imservice.pending = IMProtocolState { imservice.pending = IMProtocolState {
content_hint: { content_hint: {
ContentHint::from_bits(hint).unwrap_or_else(|| { ContentHint::from_bits(hint).unwrap_or_else(|| {
eprintln!("Warning: received invalid hint flags"); let out = ContentHint::from_bits_truncate(hint);
ContentHint::NONE eprintln!(
"Warning: received hint flags with unknown bits set: 0x{:x}",
hint ^ out.bits(),
);
out
}) })
}, },
content_purpose: { content_purpose: {
@ -142,19 +146,34 @@ pub mod c {
let imservice = check_imservice(imservice, im).unwrap(); let imservice = check_imservice(imservice, im).unwrap();
let active_changed = imservice.current.active ^ imservice.pending.active; let active_changed = imservice.current.active ^ imservice.pending.active;
fn is_visible(state: &IMProtocolState) -> bool {
state.active
&& !state.content_hint.contains(
ContentHint::ON_SCREEN_INPUT_PROVIDED
)
}
let visible_changed = is_visible(&imservice.current)
^ is_visible(&imservice.pending);
imservice.serial += Wrapping(1u32); imservice.serial += Wrapping(1u32);
imservice.current = imservice.pending.clone(); imservice.current = imservice.pending.clone();
imservice.pending = IMProtocolState { imservice.pending = IMProtocolState {
active: imservice.current.active, active: imservice.current.active,
..IMProtocolState::default() ..IMProtocolState::default()
}; };
if active_changed {
if imservice.current.active { if active_changed && imservice.current.active {
eekboard_context_service_show_keyboard(imservice.ui_manager);
eekboard_context_service_set_hint_purpose( eekboard_context_service_set_hint_purpose(
imservice.ui_manager, imservice.ui_manager,
imservice.current.content_hint.bits(), imservice.current.content_hint.bits(),
imservice.current.content_purpose.clone() as u32); imservice.current.content_purpose.clone() as u32,
);
}
if visible_changed {
if is_visible(&imservice.current) {
eekboard_context_service_show_keyboard(imservice.ui_manager);
} else { } else {
eekboard_context_service_hide_keyboard(imservice.ui_manager); eekboard_context_service_hide_keyboard(imservice.ui_manager);
} }
@ -219,6 +238,7 @@ bitflags!{
const SENSITIVE_DATA = 0x80; const SENSITIVE_DATA = 0x80;
const LATIN = 0x100; const LATIN = 0x100;
const MULTILINE = 0x200; const MULTILINE = 0x200;
const ON_SCREEN_INPUT_PROVIDED = 0x400;
} }
} }