+#ifdef __WXGTK20__
+static void gtk_wxwindow_commit_cb (GtkIMContext *context,
+ const gchar *str,
+ wxWindow *window)
+{
+ wxKeyEvent event( wxEVT_KEY_DOWN );
+
+ // take modifiers, cursor position, timestamp etc. from the last
+ // key_press_event that was fed into Input Method:
+ if (window->m_imData->lastKeyEvent)
+ {
+ wxFillOtherKeyEventFields(event,
+ window, window->m_imData->lastKeyEvent);
+ }
+
+#if wxUSE_UNICODE
+ const wxWCharBuffer data = wxConvUTF8.cMB2WC( (char*)str );
+#else
+ const wxWCharBuffer wdata = wxConvUTF8.cMB2WC( (char*)str );
+ const wxCharBuffer data = wxConvLocal.cWC2MB( wdata );
+#endif // wxUSE_UNICODE
+ if( !(const wxChar*)data )
+ return;
+
+ bool ret = false;
+
+ // Implement OnCharHook by checking ancestor top level windows
+ wxWindow *parent = window;
+ while (parent && !parent->IsTopLevel())
+ parent = parent->GetParent();
+
+ for( const wxChar* pstr = data; *pstr; pstr++ )
+ {
+#if wxUSE_UNICODE
+ event.m_uniChar = *pstr;
+ // Backward compatible for ISO-8859
+ event.m_keyCode = *pstr < 256 ? event.m_uniChar : 0;
+ wxLogTrace(TRACE_KEYS, _T("IM sent character '%c'"), event.m_uniChar);
+#else
+ event.m_keyCode = *pstr;
+#endif // wxUSE_UNICODE
+ if (parent)
+ {
+ event.SetEventType( wxEVT_CHAR_HOOK );
+ ret = parent->GetEventHandler()->ProcessEvent( event );
+ }
+
+ if (!ret)
+ {
+ event.SetEventType(wxEVT_CHAR);
+ ret = window->GetEventHandler()->ProcessEvent( event );
+ }
+ }
+}
+#endif
+
+