Exemplo n.º 1
0
void TextInputGTK::SelectInputMethod()
{
	GtkWidget *menu = gtk_menu_new();
	gtk_im_multicontext_append_menuitems( reinterpret_cast<GtkIMMulticontext *>(mContext), GTK_MENU_SHELL(menu) );
	gtk_menu_popup( GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, 0 );
	gtk_im_context_reset( mContext );
}
Exemplo n.º 2
0
void EditorClient::respondToChangedSelection()
{
    WebKitWebViewPrivate* priv = m_webView->priv;
    Frame* targetFrame = core(m_webView)->focusController()->focusedOrMainFrame();

    if (!targetFrame)
        return;

    if (targetFrame->editor()->ignoreCompositionSelectionChange())
        return;

    GtkClipboard* clipboard = gtk_widget_get_clipboard(GTK_WIDGET(m_webView), GDK_SELECTION_PRIMARY);
    if (targetFrame->selection()->isRange()) {
        GtkTargetList* targetList = webkit_web_view_get_copy_target_list(m_webView);
        gint targetCount;
        GtkTargetEntry* targets = gtk_target_table_new_from_list(targetList, &targetCount);
        gtk_clipboard_set_with_owner(clipboard, targets, targetCount,
                                     clipboard_get_contents_cb, clipboard_clear_contents_cb, G_OBJECT(m_webView));
        gtk_target_table_free(targets, targetCount);
    } else if (gtk_clipboard_get_owner(clipboard) == G_OBJECT(m_webView))
        gtk_clipboard_clear(clipboard);

    if (!targetFrame->editor()->hasComposition())
        return;

    unsigned start;
    unsigned end;
    if (!targetFrame->editor()->getCompositionSelection(start, end)) {
        // gtk_im_context_reset() clears the composition for us.
        gtk_im_context_reset(priv->imContext);
        targetFrame->editor()->confirmCompositionWithoutDisturbingSelection();
    }
}
}


void scim_bridge_client_imcontext_focus_out (GtkIMContext *context)
{
    scim_bridge_pdebugln (8, "scim_bridge_client_imcontext_focus_out ()");

    ScimBridgeClientIMContext *imcontext = SCIM_BRIDGE_CLIENT_IMCONTEXT (context);
    focused_widget = NULL;

    focused_imcontext = imcontext;
    if (imcontext->preedit_shown) {
        if (imcontext->enabled) {
            scim_bridge_client_imcontext_set_preedit_shown (imcontext, FALSE);
            scim_bridge_client_imcontext_update_preedit (imcontext);
        } else {
            gtk_im_context_reset (GTK_IM_CONTEXT (fallback_imcontext));
        }
    }
    if (scim_bridge_client_is_messenger_opened () && imcontext != NULL) {
        if (scim_bridge_client_change_focus (imcontext, FALSE)) {
            scim_bridge_perrorln ("An IOException occurred at scim_bridge_client_imcontext_focus_out ()");
        }
    }
    if (key_snooper_used) {
        gtk_key_snooper_remove (key_snooper_id);
        key_snooper_id = 0;
        key_snooper_used = FALSE;
    }
Exemplo n.º 4
0
void EditorClient::respondToChangedSelection()
{
    g_signal_emit_by_name(m_webView, "selection-changed");

    WebKitWebViewPrivate* priv = m_webView->priv;
    WebCore::Page* corePage = core(m_webView);
    Frame* targetFrame = corePage->focusController()->focusedOrMainFrame();

    if (!targetFrame)
        return;

    if (targetFrame->editor()->ignoreCompositionSelectionChange())
        return;

#if PLATFORM(X11)
    setSelectionPrimaryClipboardIfNeeded(m_webView);
#endif

    if (!targetFrame->editor()->hasComposition())
        return;

    unsigned start;
    unsigned end;
    if (!targetFrame->editor()->getCompositionSelection(start, end)) {
        // gtk_im_context_reset() clears the composition for us.
        gtk_im_context_reset(priv->imContext.get());
        targetFrame->editor()->cancelComposition();
    }
}
Exemplo n.º 5
0
void
gimp_text_tool_reset_im_context (GimpTextTool *text_tool)
{
  if (text_tool->needs_im_reset)
    {
      text_tool->needs_im_reset = FALSE;
      gtk_im_context_reset (text_tool->im_context);
    }
}
Exemplo n.º 6
0
void GtkInputMethodFilter::cancelContextComposition()
{
    m_preventNextCommit = !m_preedit.isEmpty();

    gtk_im_context_reset(m_context.get());

    m_composingTextCurrently = false;
    m_justSentFakeKeyUp = false;
    m_preedit = String();
    m_confirmedComposition = String();
}
Exemplo n.º 7
0
static void
reset_im_context (StIMText *self)
{
  StIMTextPrivate *priv = self->priv;

  if (priv->need_im_reset)
    {
      gtk_im_context_reset (priv->im_context);
      priv->need_im_reset = FALSE;
    }
}
void scim_bridge_client_imcontext_imengine_status_changed (ScimBridgeClientIMContext *imcontext, boolean enabled)
{
    if (imcontext->preedit_shown) {
        if (imcontext->enabled) {
            scim_bridge_client_imcontext_set_preedit_shown (imcontext, FALSE);
            scim_bridge_client_imcontext_update_preedit (imcontext);
        } else {
            gtk_im_context_reset (GTK_IM_CONTEXT (fallback_imcontext));
        }
    }
    imcontext->enabled = enabled;
}
Exemplo n.º 9
0
static void
fcitx_im_context_reset(GtkIMContext *context)
{
    FcitxLog(LOG_LEVEL, "fcitx_im_context_reset");
    FcitxIMContext *fcitxcontext = FCITX_IM_CONTEXT(context);

    if (fcitx_client_is_valid(fcitxcontext->client)) {
        fcitx_client_reset(fcitxcontext->client);
    }

    gtk_im_context_reset(fcitxcontext->slave);
}
Exemplo n.º 10
0
 static gboolean key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
 {

 	update_keyboard_state(event,TRUE);

	if(gtk_im_context_filter_keypress(input_method,event))
		return TRUE;

	if(check_key_action(widget,event))
	{
		gtk_im_context_reset(input_method);
		return TRUE;
	}

	return FALSE;
 }
Exemplo n.º 11
0
void EditorClient::respondToChangedSelection()
{
    WebKitWebViewPrivate* priv = m_webView->priv;

    Frame* targetFrame = core(m_webView)->focusController()->focusedOrMainFrame();
    if (!targetFrame || !targetFrame->editor()->hasComposition())
        return;

    if (targetFrame->editor()->ignoreCompositionSelectionChange())
        return;

    unsigned start;
    unsigned end;
    if (!targetFrame->editor()->getCompositionSelection(start, end)) {
        // gtk_im_context_reset() clears the composition for us.
        gtk_im_context_reset(priv->imContext);
        targetFrame->editor()->confirmCompositionWithoutDisturbingSelection();
    }
}
Exemplo n.º 12
0
void gKey::setActiveControl(gControl *control)
{
	if (_im_control)
	{
		if (!_no_input_method)
		{
			#if DEBUG_IM
			fprintf(stderr, "gtk_im_context_focus_out\n");
			#endif
	  	gtk_im_context_set_client_window (_im_context, 0);
			gtk_im_context_focus_out(_im_context);
		}
		_im_control = NULL;
		_no_input_method = false;
	}
	
	if (control)
	{
		_im_control = control;
		_no_input_method = control->noInputMethod();
		
		if (!_no_input_method)
		{
	  	gtk_im_context_set_client_window (_im_context, _im_window); //gtk_widget_get_window(_im_control->widget));
			gtk_im_context_focus_in(_im_context);
			gtk_im_context_reset(_im_context);
			#if DEBUG_IM
			fprintf(stderr, "gtk_im_context_focus_in: %s\n", gtk_im_multicontext_get_context_id(GTK_IM_MULTICONTEXT(_im_context)));
			if (control->getClass() == Type_gTextBox)
			{
				char *method;
				g_object_get(GTK_ENTRY(control->widget), "im-module", &method, (char *)NULL);
				fprintf(stderr, "GtkEntry im-module: %s\n", method);
			}
			#endif
			//_im_state_required = -1;
		}

		//memset(_key_code, 0, sizeof(uint) * MAX_CODE);
	}
}
Exemplo n.º 13
0
void EditorClient::handleInputMethodMousePress()
{
    Frame* targetFrame = core(m_webView)->focusController()->focusedOrMainFrame();

    if (!targetFrame || !targetFrame->editor()->canEdit())
        return;

    WebKitWebViewPrivate* priv = m_webView->priv;

    // When a mouse press fires, the commit signal happens during a composition.
    // In this case, if the focused node is changed, the commit signal happens in a diffrent node.
    // Therefore, we need to confirm the current compositon and ignore the next commit signal.
    GOwnPtr<gchar> newPreedit(0);
    gtk_im_context_get_preedit_string(priv->imContext.get(), &newPreedit.outPtr(), 0, 0);

    if (g_utf8_strlen(newPreedit.get(), -1)) {
        targetFrame->editor()->confirmComposition();
        m_preventNextCompositionCommit = true;
        gtk_im_context_reset(priv->imContext.get());
    }
}
/* Class functions */
gboolean scim_bridge_client_imcontext_filter_key_event (GtkIMContext *context, GdkEventKey *event)
{
    scim_bridge_pdebugln (8, "scim_bridge_client_imcontext_filter_key_event ()");

    ScimBridgeClientIMContext *imcontext = SCIM_BRIDGE_CLIENT_IMCONTEXT (context);

    boolean ret = FALSE;
    if (imcontext) {
        if (!key_snooper_used) ret = key_snooper(0, event, 0);

        if (imcontext->slave) {
            if (!ret) {
                ret = gtk_im_context_filter_keypress (imcontext->slave, event);
            } else if (imcontext->slave_preedit) {
                imcontext->slave_preedit = FALSE;
                gtk_im_context_reset (imcontext->slave);
            }
        }

    }

    return ret;
}
Exemplo n.º 15
0
static VALUE
rg_reset(VALUE self)
{
    gtk_im_context_reset(_SELF(self));
    return self;
}
Exemplo n.º 16
0
void
gc_im_reset()
{
  GcomprisProperties	*properties = gc_prop_get ();
  gtk_im_context_reset (properties->context);
}
Exemplo n.º 17
0
static gboolean 
nsgtk_tree_window_draw_event(GtkWidget *widget, cairo_t *cr, gpointer data)
{
	struct tree *tree = (struct tree *)data;
	struct redraw_context ctx = {
		.interactive = true,
		.background_images = true,
		.plot = &nsgtk_plotters
	};
	double x1;
	double y1;
	double x2;
	double y2;
	
	current_widget = widget;
	current_cr = cr;
	
	cairo_clip_extents(cr, &x1, &y1, &x2, &y2);

	tree_draw(tree, 0, 0, x1, y1, x2 - x1, y2 - y1, &ctx);
	
	current_widget = NULL;
	
	return FALSE;
}

#else

/* signal handler functions for a tree window */
static gboolean 
nsgtk_tree_window_draw_event(GtkWidget *widget, GdkEventExpose *event, gpointer g)
{
	struct tree *tree = (struct tree *) g;
	struct redraw_context ctx = {
		.interactive = true,
		.background_images = true,
		.plot = &nsgtk_plotters
	};
	int x, y, width, height;
	
	x = event->area.x;
	y = event->area.y;
	width = event->area.width;
	height = event->area.height;
	
	current_widget = widget;
	current_cr = gdk_cairo_create(nsgtk_widget_get_window(widget));
	
	tree_draw(tree, 0, 0, x, y, width, height, &ctx);
	
	current_widget = NULL;
	cairo_destroy(current_cr);
	
	return FALSE;
}

#endif

void nsgtk_tree_window_hide(GtkWidget *widget, gpointer g)
{
}

static gboolean
nsgtk_tree_window_button_press_event(GtkWidget *widget,
		GdkEventButton *event, gpointer g)
{	
	struct nsgtk_treeview *tw = g;
	struct tree *tree = tw->tree;
	
	gtk_im_context_reset(tw->input_method);
	gtk_widget_grab_focus(GTK_WIDGET(tw->drawing_area));

	tw->mouse_pressed = true;	
	tw->mouse_pressed_x = event->x;
	tw->mouse_pressed_y = event->y;

	if (event->type == GDK_2BUTTON_PRESS)
		tw->mouse_state = BROWSER_MOUSE_DOUBLE_CLICK;
	
	switch (event->button) {
		case 1: tw->mouse_state |= BROWSER_MOUSE_PRESS_1; break;
		case 2: tw->mouse_state |= BROWSER_MOUSE_PRESS_2; break;
	}
	/* Handle the modifiers too */
	if (event->state & GDK_SHIFT_MASK)
		tw->mouse_state |= BROWSER_MOUSE_MOD_1;
	if (event->state & GDK_CONTROL_MASK)
		tw->mouse_state |= BROWSER_MOUSE_MOD_2;
	if (event->state & GDK_MOD1_MASK)
		tw->mouse_state |= BROWSER_MOUSE_MOD_3;

	/* Record where we pressed, for use when determining whether to start
	 * a drag in motion notify events. */
	tw->last_x = event->x;
	tw->last_y = event->y;

	tree_mouse_action(tree, tw->mouse_state, event->x, event->y);
	
	return TRUE;
}

static gboolean
nsgtk_tree_window_button_release_event(GtkWidget *widget,
		GdkEventButton *event, gpointer g)
{
	bool shift = event->state & GDK_SHIFT_MASK;
	bool ctrl = event->state & GDK_CONTROL_MASK;
	bool alt = event->state & GDK_MOD1_MASK;
	struct nsgtk_treeview *tw = (struct nsgtk_treeview *) g;
	struct tree *tree = tw->tree;

	/* We consider only button 1 clicks as double clicks.
	* If the mouse state is PRESS then we are waiting for a release to emit
	* a click event, otherwise just reset the state to nothing*/
	if (tw->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) {
		
		if (tw->mouse_state & BROWSER_MOUSE_PRESS_1)
			tw->mouse_state ^= BROWSER_MOUSE_PRESS_1 |
					BROWSER_MOUSE_CLICK_1;
		else if (tw->mouse_state & BROWSER_MOUSE_PRESS_2)
			tw->mouse_state ^= (BROWSER_MOUSE_PRESS_2 |
					BROWSER_MOUSE_CLICK_2 |
					BROWSER_MOUSE_DOUBLE_CLICK);
		
	} else if (tw->mouse_state & BROWSER_MOUSE_PRESS_1) {
		tw->mouse_state ^= (BROWSER_MOUSE_PRESS_1 |
				    BROWSER_MOUSE_CLICK_1);
	} else if (tw->mouse_state & BROWSER_MOUSE_PRESS_2) {
		tw->mouse_state ^= (BROWSER_MOUSE_PRESS_2 |
				    BROWSER_MOUSE_CLICK_2);
	} else if (tw->mouse_state & BROWSER_MOUSE_HOLDING_1) {
		tw->mouse_state ^= (BROWSER_MOUSE_HOLDING_1 |
				    BROWSER_MOUSE_DRAG_ON);
	} else if (tw->mouse_state & BROWSER_MOUSE_HOLDING_2) {
		tw->mouse_state ^= (BROWSER_MOUSE_HOLDING_2 |
				    BROWSER_MOUSE_DRAG_ON);
	}
	
	/* Handle modifiers being removed */
	if (tw->mouse_state & BROWSER_MOUSE_MOD_1 && !shift)
		tw->mouse_state ^= BROWSER_MOUSE_MOD_1;
	if (tw->mouse_state & BROWSER_MOUSE_MOD_2 && !ctrl)
		tw->mouse_state ^= BROWSER_MOUSE_MOD_2;
	if (tw->mouse_state & BROWSER_MOUSE_MOD_3 && !alt)
		tw->mouse_state ^= BROWSER_MOUSE_MOD_3;


	if (tw->mouse_state &
			~(BROWSER_MOUSE_MOD_1 |
			  BROWSER_MOUSE_MOD_2 |
			  BROWSER_MOUSE_MOD_3)) {
		tree_mouse_action(tree, tw->mouse_state,
				event->x, event->y);
	} else {
		tree_drag_end(tree, tw->mouse_state,
				tw->mouse_pressed_x,
				tw->mouse_pressed_y,
				event->x, event->y);
	}

	tw->mouse_state = 0;
	tw->mouse_pressed = false;
				
	return TRUE;	
}

static gboolean
nsgtk_tree_window_motion_notify_event(GtkWidget *widget,
		GdkEventMotion *event, gpointer g)
{
	bool shift = event->state & GDK_SHIFT_MASK;
	bool ctrl = event->state & GDK_CONTROL_MASK;
	bool alt = event->state & GDK_MOD1_MASK;
	struct nsgtk_treeview *tw = (struct nsgtk_treeview *) g;
	struct tree *tree = tw->tree;

	if (tw->mouse_pressed == false)
		return TRUE;

	if ((abs(event->x - tw->last_x) < 5) &&
			(abs(event->y - tw->last_y) < 5)) {
		/* Mouse hasn't moved far enough from press coordinate for this
		 * to be considered a drag. */
		return FALSE;
	} else {
		/* This is a drag, ensure it's always treated as such, even if
		 * we drag back over the press location */
		tw->last_x = INT_MIN;
		tw->last_y = INT_MIN;
	}
	
	if (tw->mouse_state & BROWSER_MOUSE_PRESS_1) {
		/* Start button 1 drag */
		tree_mouse_action(tree, BROWSER_MOUSE_DRAG_1,
				  tw->mouse_pressed_x, tw->mouse_pressed_y);
		/* Replace PRESS with HOLDING and declare drag in progress */
		tw->mouse_state ^= (BROWSER_MOUSE_PRESS_1 |
				BROWSER_MOUSE_HOLDING_1);
		tw->mouse_state |= BROWSER_MOUSE_DRAG_ON;
		return TRUE;
	}
	else if (tw->mouse_state & BROWSER_MOUSE_PRESS_2){
		/* Start button 2s drag */
		tree_mouse_action(tree, BROWSER_MOUSE_DRAG_2,
				  tw->mouse_pressed_x, tw->mouse_pressed_y);
		/* Replace PRESS with HOLDING and declare drag in progress */
		tw->mouse_state ^= (BROWSER_MOUSE_PRESS_2 |
				BROWSER_MOUSE_HOLDING_2);
		tw->mouse_state |= BROWSER_MOUSE_DRAG_ON;
		return TRUE;
	}

	/* Handle modifiers being removed */
	if (tw->mouse_state & BROWSER_MOUSE_MOD_1 && !shift)
		tw->mouse_state ^= BROWSER_MOUSE_MOD_1;
	if (tw->mouse_state & BROWSER_MOUSE_MOD_2 && !ctrl)
		tw->mouse_state ^= BROWSER_MOUSE_MOD_2;
	if (tw->mouse_state & BROWSER_MOUSE_MOD_3 && !alt)
		tw->mouse_state ^= BROWSER_MOUSE_MOD_3;
	
	if (tw->mouse_state & (BROWSER_MOUSE_HOLDING_1 |
			BROWSER_MOUSE_HOLDING_2))
		tree_mouse_action(tree, tw->mouse_state, event->x,
				event->y);
	
	return TRUE;
}