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

@ -622,8 +622,12 @@ impl WaylandWindowStatePtr {
let mut bounds: Option<Bounds<Pixels>> = None;
if let Some(mut input_handler) = state.input_handler.take() {
drop(state);
if let Some(range) = input_handler.selected_text_range() {
bounds = input_handler.bounds_for_range(range);
if let Some(selection) = input_handler.selected_text_range(true) {
bounds = input_handler.bounds_for_range(if selection.reversed {
selection.range.start..selection.range.start
} else {
selection.range.end..selection.range.end
});
}
self.state.borrow_mut().input_handler = Some(input_handler);
}
@ -1006,6 +1010,13 @@ impl PlatformWindow for WaylandWindow {
}
}
fn update_ime_position(&self, bounds: Bounds<Pixels>) {
let state = self.borrow();
let client = state.client.clone();
drop(state);
client.update_ime_position(bounds);
}
fn gpu_specs(&self) -> Option<GPUSpecs> {
self.borrow().renderer.gpu_specs().into()
}