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)
upstream-master
Bryan Tan 5 years ago committed by Bryan Tan
parent f59c3c4a40
commit 623d8654ba
  1. 2
      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<int>(zoom * x0 + x1 + zoom * cX);
cursorRect.y = static_cast<int>(zoom * y0 + y1 + zoom * cY);

Loading…
Cancel
Save