void gc_im_init(GtkWidget *window) { GcomprisProperties *properties = gc_prop_get (); /* set IMContext */ properties->context = gtk_im_multicontext_new (); if(gc_profile_get_current()) { GHashTable *init_im = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); init_im = gc_db_conf_with_table_get (gc_profile_get_current()->profile_id, -1, init_im ); properties->default_context = g_hash_table_lookup ( init_im, "default_im"); if (properties->default_context) g_setenv ("GTK_IM_MODULE", properties->default_context, TRUE); } gtk_im_context_set_client_window (properties->context, window->window); g_signal_connect (G_OBJECT (properties->context), "commit", G_CALLBACK(im_context_commit_callback), NULL); g_signal_connect (G_OBJECT (properties->context), "preedit-changed", G_CALLBACK(im_context_preedit_callback), NULL); g_signal_connect (GTK_WIDGET (window), "focus-in-event", G_CALLBACK(window_focus_callback), NULL); g_signal_connect (GTK_WIDGET (window), "focus-out-event", G_CALLBACK(window_focus_callback), NULL); }
void gimp_text_tool_editor_halt (GimpTextTool *text_tool) { GimpTextOptions *options = GIMP_TEXT_TOOL_GET_OPTIONS (text_tool); if (text_tool->style_overlay) { gtk_widget_destroy (text_tool->style_overlay); text_tool->style_overlay = NULL; text_tool->style_editor = NULL; } g_signal_handlers_disconnect_by_func (options, gimp_text_tool_options_notify, text_tool); if (text_tool->editor_dialog) { g_signal_handlers_disconnect_by_func (text_tool->editor_dialog, gimp_text_tool_editor_destroy, text_tool); gtk_widget_destroy (text_tool->editor_dialog); } if (text_tool->proxy_text_view) { gtk_widget_destroy (text_tool->offscreen_window); text_tool->offscreen_window = NULL; text_tool->proxy_text_view = NULL; } text_tool->needs_im_reset = TRUE; gimp_text_tool_reset_im_context (text_tool); gtk_im_context_focus_out (text_tool->im_context); gtk_im_context_set_client_window (text_tool->im_context, NULL); }
static void handleWidgetRealize(GtkWidget* widget, GtkInputMethodFilter* filter) { GdkWindow* window = gtk_widget_get_window(widget); ASSERT(window); gtk_im_context_set_client_window(filter->context(), window); }
static VALUE rg_set_client_window(VALUE self, VALUE gdkwindow) { gtk_im_context_set_client_window(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow))); return self; }
struct nsgtk_treeview * nsgtk_treeview_create(unsigned int flags, GtkWindow *window, GtkScrolledWindow *scrolled, GtkDrawingArea *drawing_area, struct sslcert_session_data *ssl_data) { struct nsgtk_treeview *tv; assert(drawing_area != NULL); tv = malloc(sizeof(struct nsgtk_treeview)); if (tv == NULL) { LOG("malloc failed"); nsgtk_warning("NoMemory", 0); return NULL; } tv->tree_flags = flags; if (tv->tree_flags == TREE_SSLCERT) { tv->ssl_data = ssl_data; ssl_current_session = tv->ssl_data; } tv->window = window; tv->scrolled = scrolled; tv->drawing_area = drawing_area; tv->input_method = gtk_im_multicontext_new(); tv->tree = tree_create(flags, &nsgtk_tree_callbacks, tv); tv->mouse_state = 0; tv->mouse_pressed = false; nsgtk_widget_override_background_color(GTK_WIDGET(drawing_area), GTK_STATE_NORMAL, 0, 0xffff, 0xffff, 0xffff); nsgtk_connect_draw_event(GTK_WIDGET(drawing_area), G_CALLBACK(nsgtk_tree_window_draw_event), tv); #define CONNECT(obj, sig, callback, ptr) \ g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr)) CONNECT(drawing_area, "button-press-event", nsgtk_tree_window_button_press_event, tv); CONNECT(drawing_area, "button-release-event", nsgtk_tree_window_button_release_event, tv); CONNECT(drawing_area, "motion-notify-event", nsgtk_tree_window_motion_notify_event, tv); CONNECT(drawing_area, "key-press-event", nsgtk_tree_window_keypress_event, tv); CONNECT(drawing_area, "key-release-event", nsgtk_tree_window_keyrelease_event, tv); /* input method */ gtk_im_context_set_client_window(tv->input_method, nsgtk_widget_get_window(GTK_WIDGET(tv->window))); gtk_im_context_set_use_preedit(tv->input_method, FALSE); /* input method signals */ CONNECT(tv->input_method, "commit", nsgtk_tree_window_input_method_commit, tv); return tv; }
static gboolean fcitx_im_context_filter_keypress(GtkIMContext *context, GdkEventKey *event) { FcitxLog(LOG_LEVEL, "fcitx_im_context_filter_keypress"); FcitxIMContext *fcitxcontext = FCITX_IM_CONTEXT(context); /* check this first, since we use key snooper, most key will be handled. */ if (fcitx_client_is_valid(fcitxcontext->client) ) { /* XXX it is a workaround for some applications do not set client window. */ if (fcitxcontext->client_window == NULL && event->window != NULL) { gtk_im_context_set_client_window((GtkIMContext *)fcitxcontext, event->window); /* set_cursor_location_internal() will get origin from X server, * it blocks UI. So delay it to idle callback. */ g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, (GSourceFunc) _set_cursor_location_internal, g_object_ref(fcitxcontext), (GDestroyNotify) g_object_unref); } } if (G_UNLIKELY(event->state & FcitxKeyState_HandledMask)) return TRUE; if (G_UNLIKELY(event->state & FcitxKeyState_IgnoredMask)) return gtk_im_context_filter_keypress(fcitxcontext->slave, event); if (fcitx_client_is_valid(fcitxcontext->client) && fcitxcontext->has_focus) { _request_surrounding_text (fcitxcontext); fcitxcontext->time = event->time; if (_use_sync_mode) { int ret = fcitx_client_process_key_sync(fcitxcontext->client, event->keyval, event->hardware_keycode, event->state, (event->type == GDK_KEY_PRESS) ? (FCITX_PRESS_KEY) : (FCITX_RELEASE_KEY), event->time); if (ret <= 0) { event->state |= FcitxKeyState_IgnoredMask; return gtk_im_context_filter_keypress(fcitxcontext->slave, event); } else { event->state |= FcitxKeyState_HandledMask; return TRUE; } } else { ProcessKeyStruct* pks = g_malloc0(sizeof(ProcessKeyStruct)); pks->context = fcitxcontext; pks->event = (GdkEventKey *) gdk_event_copy((GdkEvent *) event); fcitx_client_process_key(fcitxcontext->client, _fcitx_im_context_process_key_cb, pks, event->keyval, event->hardware_keycode, event->state, (event->type == GDK_KEY_PRESS) ? (FCITX_PRESS_KEY) : (FCITX_RELEASE_KEY), event->time); event->state |= FcitxKeyState_HandledMask; return TRUE; } } else { return gtk_im_context_filter_keypress(fcitxcontext->slave, event); } return FALSE; }