x11: Fix preedit for CJK and partially fix unresponsive keyboard with xim (#17373)

Closes #15833
Related to [#12495
comment](https://github.com/zed-industries/zed/pull/12495#issuecomment-2328356125)

Destroying and recreating the Input context was the only way to reset
the IME but it's making the keyboard unresponsive sometimes due to a XIM
error.

The keyboard will still be unresponsive if you close your IME while
using zed, but I don't know how to fix this.

* Fixed preedit drawing for CJK
* Fixed unresponsive keyboard by properly implementing reset_ic in
`xim-rs`

Release Notes:

- N/A
This commit is contained in:
Fernando Tagawa
2024-09-16 18:46:03 -06:00
committed by GitHub
parent bc5ed1334f
commit d7c45ccf2f
4 changed files with 15 additions and 36 deletions
@@ -48,12 +48,7 @@ impl<C: Client<XEvent = xproto::KeyPressEvent>> ClientHandler<C> for XimHandler
) -> Result<(), ClientError> {
let ic_attributes = client
.build_ic_attributes()
.push(
AttributeName::InputStyle,
InputStyle::PREEDIT_CALLBACKS
| InputStyle::STATUS_NOTHING
| InputStyle::PREEDIT_NONE,
)
.push(AttributeName::InputStyle, InputStyle::PREEDIT_CALLBACKS)
.push(AttributeName::ClientWindow, self.window)
.push(AttributeName::FocusWindow, self.window)
.build();
@@ -110,15 +105,6 @@ impl<C: Client<XEvent = xproto::KeyPressEvent>> ClientHandler<C> for XimHandler
client.disconnect()
}
fn handle_destroy_ic(
&mut self,
client: &mut C,
input_method_id: u16,
_input_context_id: u16,
) -> Result<(), ClientError> {
client.close(input_method_id)
}
fn handle_preedit_draw(
&mut self,
_client: &mut C,