From 623d8654bacbc8db264f2cf9a76aead20be26889 Mon Sep 17 00:00:00 2001 From: Bryan Tan Date: Wed, 15 Sep 2021 22:11:35 -0700 Subject: [PATCH] Fix some non-English IMEs not working on Windows Previously, the input context window was set in the paint method. Some non-English IMEs (e.g., for Chinese) did not trigger any input method callbacks since no window was initially set. This only seemed to happen on Windows. Note that the GTK docs state: > This window is used in order to correctly position status windows, and may also be used for purposes internal to the input method. (https://docs.gtk.org/gtk3/method.IMContext.set_client_window.html) --- src/gui/TextEditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/TextEditor.cpp b/src/gui/TextEditor.cpp index e877e838..db4a7a9f 100644 --- a/src/gui/TextEditor.cpp +++ b/src/gui/TextEditor.cpp @@ -38,6 +38,7 @@ TextEditor::TextEditor(XojPageView* gui, GtkWidget* widget, Text* text, bool own g_object_get(settings, "gtk-cursor-blink-timeout", &this->cursorBlinkTimeout, nullptr); this->imContext = gtk_im_multicontext_new(); + gtk_im_context_set_client_window(this->imContext, gtk_widget_get_window(this->widget)); gtk_im_context_focus_in(this->imContext); g_signal_connect(this->imContext, "commit", G_CALLBACK(iMCommitCallback), this); @@ -1048,7 +1049,6 @@ void TextEditor::paint(cairo_t* cr, GdkRectangle* repaintRect, double zoom) { cairo_stroke(cr); // Notify the IM of the app's window and cursor position. - gtk_im_context_set_client_window(this->imContext, gtk_widget_get_window(this->widget)); GdkRectangle cursorRect; cursorRect.x = static_cast(zoom * x0 + x1 + zoom * cX); cursorRect.y = static_cast(zoom * y0 + y1 + zoom * cY);