Skip to content

Commit c137f35

Browse files
author
徐扬斌
committed
GTK: Delay IME context focus to fix IME input bugs when there're embedded CEF window.
We need to delay IME context focus in, to avoid confusing the IME framework(be it ibus or fcitx) where the IME focus really is when there're embedded CEF windows.
1 parent 098ae8b commit c137f35

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/gtk/window.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4722,9 +4722,6 @@ bool wxWindowGTK::GTKHandleFocusIn()
47224722
"handling focus_in event for %s",
47234723
wxDumpWindow(this));
47244724

4725-
if (m_imContext)
4726-
gtk_im_context_focus_in(m_imContext);
4727-
47284725
gs_currentFocus = this;
47294726

47304727
if ( gs_pendingFocus )
@@ -4755,6 +4752,18 @@ bool wxWindowGTK::GTKHandleFocusIn()
47554752

47564753
GTKProcessEvent(eventFocus);
47574754

4755+
if (m_imContext)
4756+
{
4757+
// delay gtk_im_context_focus_in to avoid timing conflict with IME framework(fcitx)
4758+
g_idle_add([](gpointer data) -> gboolean {
4759+
GtkIMContext* context = static_cast<GtkIMContext*>(data);
4760+
if (context) {
4761+
gtk_im_context_focus_in(context);
4762+
}
4763+
return G_SOURCE_REMOVE; // only run once
4764+
}, m_imContext);
4765+
}
4766+
47584767
return retval;
47594768
}
47604769

0 commit comments

Comments
 (0)