Skip to content

Commit

Permalink
Fix xim bug (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
Riey authored Feb 24, 2021
1 parent 8806e30 commit 9a2cd62
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

* Fix cho-jung bug `웬 + ㅊ$ㅜ = 웬ㅊ`
* Fix composable jungseong bug `ㅇ + $ㅆ$ㅜ + $ㅊ$ㅔ + = 웇`
* Fix xim bug [#304](https://github.com/Riey/kime/issues/304)

## 1.1.2

Expand Down
16 changes: 8 additions & 8 deletions src/frontends/wayland/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,25 +225,25 @@ impl KimeContext {
self.engine.update_hangul_state();
}

let bypass = ret & InputResult_CONSUMED == 0;

if ret & InputResult_HAS_PREEDIT != 0 {
self.preedit(self.engine.preedit_str().into());
} else {
self.clear_preedit();
}

if ret & InputResult_NEED_RESET != 0 {
self.commit_string(self.engine.commit_str().into());
self.engine.reset();
} else if ret & InputResult_NEED_FLUSH != 0 {
if ret & InputResult_NEED_RESET | InputResult_NEED_FLUSH != 0 {
self.commit_string(self.engine.commit_str().into());
self.engine.flush();

if ret & InputResult_NEED_RESET != 0 {
self.engine.reset();
} else {
self.engine.flush();
}
}

self.commit();

if bypass {
if ret & InputResult_CONSUMED == 0 {
// Bypassed key's repeat will be handled by the clients.
//
// Reference:
Expand Down
23 changes: 13 additions & 10 deletions src/frontends/xim/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ impl KimeHandler {
return Ok(());
}

if user_ic.user_data.engine.preedit_str().is_empty() {
return Ok(());
}

if let Some(pe) = user_ic.user_data.pe.as_mut() {
// Draw in server (already have pe_window)
let pe = self.preedit_windows.get_mut(pe).unwrap();
Expand Down Expand Up @@ -196,7 +200,7 @@ impl ServerHandler<X11rbServer<XCBConnection>> for KimeHandler {
server: &mut X11rbServer<XCBConnection>,
user_ic: &mut xim::UserInputContext<KimeData>,
) -> Result<(), xim::ServerError> {
log::trace!("spot: {:?}", user_ic.ic.preedit_spot());
log::debug!("spot: {:?}", user_ic.ic.preedit_spot());

self.clear_preedit(server, user_ic)?;
self.preedit(server, user_ic)?;
Expand Down Expand Up @@ -277,18 +281,17 @@ impl ServerHandler<X11rbServer<XCBConnection>> for KimeHandler {
self.clear_preedit(server, user_ic)?;
}

if ret & InputResult_NEED_FLUSH != 0 {
user_ic.user_data.engine.flush();
}

if ret & InputResult_NEED_RESET != 0 {
if ret & InputResult_NEED_RESET | InputResult_NEED_FLUSH != 0 {
self.commit(server, user_ic)?;
user_ic.user_data.engine.reset();
}

let bypass = ret & InputResult_CONSUMED == 0;
if ret & InputResult_NEED_RESET != 0 {
user_ic.user_data.engine.reset();
} else {
user_ic.user_data.engine.flush();
}
}

Ok(!bypass)
Ok(ret & InputResult_CONSUMED != 0)
}

fn handle_destory_ic(
Expand Down

0 comments on commit 9a2cd62

Please sign in to comment.