Skip to content

Commit

Permalink
Fix gtk reset (#240)
Browse files Browse the repository at this point in the history
* Update lock file

* Fix gtk reset
  • Loading branch information
Riey committed Feb 11, 2021
1 parent 1781140 commit 3a6c231
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 18 deletions.
13 changes: 10 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@
"cargo": {
"args": [
"build",
"-p=kime-xim"
"-p=kime-wayland"
]
},
"env": {
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug"
},
"program": "${cargo:program}",
"args": []
},
Expand All @@ -44,7 +47,9 @@
"preLaunchTask": "build all",
"env": {
"GTK_IM_MODULE": "kime",
"GTK_IM_MODULE_FILE": "${workspaceFolder}/.vscode/immodules.cache"
"GTK_IM_MODULE_FILE": "${workspaceFolder}/.vscode/immodules.cache",
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug",
"G_MESSAGES_DEBUG": "kime"
},
"program": "/usr/lib/firefox/firefox",
"args": ["-g"]
Expand All @@ -56,7 +61,9 @@
"preLaunchTask": "build all",
"env": {
"GTK_IM_MODULE": "kime",
"GTK_IM_MODULE_FILE": "${workspaceFolder}/.vscode/immodules.cache"
"GTK_IM_MODULE_FILE": "${workspaceFolder}/.vscode/immodules.cache",
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug",
"G_MESSAGES_DEBUG": "kime"
},
"program": "gedit",
"args": []
Expand Down
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"type": "shell",
"command": [
"cargo xtask build --mode Debug GTK3 QT5"
"scripts/build.sh -ad"
],
"problemMatcher": [
"$rustc"
Expand Down
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Implement engine hotkeys [#223](https://github.com/Riey/kime/issues/223)
* Implement sebeolsik-sin1995 [#235](https://github.com/Riey/kime/issues/235)
* Implement layout_addons [#239](https://github.com/Riey/kime/issues/239)
* Fix gtk reset doesn't commit preedit char

## 1.0.0-pre3

Expand Down
16 changes: 12 additions & 4 deletions src/frontends/gtk2/src/immodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,30 @@ void commit(KimeImContext *ctx, uint32_t ch) {
void focus_in(GtkIMContext *im) {
KIME_IM_CONTEXT(im);

debug("focus_in");

kime_engine_update_hangul_state(ctx->engine);
}

void reset(GtkIMContext *im) {
KIME_IM_CONTEXT(im);

debug("reset");

uint32_t c = kime_engine_reset(ctx->engine);

if (!c) {
debug("reset %u", c);

if (c) {
update_preedit(ctx, FALSE);
commit(ctx, c);
}
}

void focus_out(GtkIMContext *im) {
debug("focus_out");

reset(im);
}

void put_event(KimeImContext *ctx, EventType *key) {
#if GTK_CHECK_VERSION(3, 98, 4)
gtk_im_context_filter_key(
Expand Down Expand Up @@ -301,7 +309,7 @@ void im_context_class_init(KimeImContextClass *klass, gpointer _data) {
klass->parent.filter_keypress = filter_keypress;
klass->parent.get_preedit_string = get_preedit_string;
klass->parent.focus_in = focus_in;
klass->parent.focus_out = reset;
klass->parent.focus_out = focus_out;

GObjectClass *parent_class = G_OBJECT_CLASS(klass);
parent_class->finalize = im_context_finalize;
Expand Down

0 comments on commit 3a6c231

Please sign in to comment.