+#ifdef __WXGTK20__
+static void gtk_wxwindow_commit_cb (GtkIMContext *context,
+ const gchar *str,
+ wxWindow *window)
+{
+ bool ret = FALSE;
+
+ wxKeyEvent event( wxEVT_KEY_DOWN );
+
+#if wxUSE_UNICODE
+ event.m_uniChar = g_utf8_get_char( str );
+
+ // Backward compatible for ISO-8859
+ if (event.m_uniChar < 256)
+ event.m_keyCode = event.m_uniChar;
+#else
+ gunichar uniChar = g_utf8_get_char( str );
+ // We cannot handle Unicode in non-Unicode mode
+ if (uniChar > 255) return;
+
+ event.m_keyCode = uniChar;
+#endif
+
+
+ // TODO: We still need to set all the extra attributes of the
+ // event, modifiers and such...
+
+
+ // Implement OnCharHook by checking ancestor top level windows
+ wxWindow *parent = window;
+ while (parent && !parent->IsTopLevel())
+ parent = parent->GetParent();
+ if (parent)
+ {
+ event.SetEventType( wxEVT_CHAR_HOOK );
+ ret = parent->GetEventHandler()->ProcessEvent( event );
+ }
+
+ if (!ret)
+ {
+ event.SetEventType(wxEVT_CHAR);
+ ret = window->GetEventHandler()->ProcessEvent( event );
+ }
+}
+#endif
+
+