Skip to content

Commit

Permalink
Wayland: Fix infinite loop causing bad performance when using IME via…
Browse files Browse the repository at this point in the history
… fcitx5 due to a change in fcitx5

Fix #7396
  • Loading branch information
kovidgoyal committed Apr 28, 2024
1 parent cc5e4e9 commit aecf07b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ Detailed list of changes

- :ac:`focus_visible_window`: Fix selecting with mouse click leaving keyboard in unusable state (:iss:`7390`)

- Wayland: Fix infinite loop causing bad performance when using IME via fcitx5 due to a change in fcitx5 (:iss:`7396`)

0.34.1 [2024-04-19]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
7 changes: 5 additions & 2 deletions glfw/wl_text_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ static struct zwp_text_input_manager_v3* text_input_manager;
static char *pending_pre_edit = NULL;
static char *current_pre_edit = NULL;
static char *pending_commit = NULL;
static bool ime_focused = false;
static int last_cursor_left = 0, last_cursor_top = 0, last_cursor_width = 0, last_cursor_height = 0;
uint32_t commit_serial = 0;

Expand All @@ -31,6 +32,7 @@ static void
text_input_enter(void *data UNUSED, struct zwp_text_input_v3 *txt_input, struct wl_surface *surface UNUSED) {
debug("text-input: enter event\n");
if (txt_input) {
ime_focused = true;
zwp_text_input_v3_enable(txt_input);
zwp_text_input_v3_set_content_type(txt_input, ZWP_TEXT_INPUT_V3_CONTENT_HINT_NONE, ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_TERMINAL);
commit();
Expand All @@ -41,6 +43,7 @@ static void
text_input_leave(void *data UNUSED, struct zwp_text_input_v3 *txt_input, struct wl_surface *surface UNUSED) {
debug("text-input: leave event\n");
if (txt_input) {
ime_focused = false;
zwp_text_input_v3_disable(txt_input);
commit();
}
Expand Down Expand Up @@ -150,8 +153,8 @@ _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev) {
if (!text_input) return;
switch(ev->type) {
case GLFW_IME_UPDATE_FOCUS:
debug("\ntext-input: updating IME focus state, focused: %d\n", ev->focused);
if (ev->focused) {
debug("\ntext-input: updating IME focus state, ime_focused: %d ev->focused: %d\n", ime_focused, ev->focused);
if (ime_focused) {
zwp_text_input_v3_enable(text_input);
zwp_text_input_v3_set_content_type(text_input, ZWP_TEXT_INPUT_V3_CONTENT_HINT_NONE, ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_TERMINAL);
} else {
Expand Down

0 comments on commit aecf07b

Please sign in to comment.