linux: Fix IME panel position while enumerating input methods (#12495)

Release Notes:

- N/A

This updates the IME position every time the selection changes, this is
probably only useful when you enumerate languages with your IME.

TODO:
- ~There is a rare chance that the ime panel is not updated because the
window input handler is None.~
- ~Update IME panel in vim mode.~
- ~Update IME panel when leaving Buffer search input.~

---------

Co-authored-by: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
Fernando Tagawa 2024-08-28 23:58:40 -03:00 committed by GitHub
parent e6d5f4406f
commit 8e8927db4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 244 additions and 55 deletions

View file

@ -312,6 +312,23 @@ impl WaylandClientStatePtr {
}
}
pub fn update_ime_position(&self, bounds: Bounds<Pixels>) {
let client = self.get_client();
let mut state = client.borrow_mut();
if state.composing || state.text_input.is_none() {
return;
}
let text_input = state.text_input.as_ref().unwrap();
text_input.set_cursor_rectangle(
bounds.origin.x.0 as i32,
bounds.origin.y.0 as i32,
bounds.size.width.0 as i32,
bounds.size.height.0 as i32,
);
text_input.commit();
}
pub fn drop_window(&self, surface_id: &ObjectId) {
let mut client = self.get_client();
let mut state = client.borrow_mut();
@ -1353,6 +1370,7 @@ impl Dispatch<zwp_text_input_v3::ZwpTextInputV3, ()> for WaylandClientStatePtr {
}
}
} else {
state.composing = false;
drop(state);
window.handle_ime(ImeInput::DeleteText);
}