Esempio n. 1
0
/* Returns TRUE if the given key value is in lower case. */
int
clip_GDK_KEYVALISLOWER(ClipMachine * ClipMachineMemory)
{
   guint     keyval = INT_OPTION(ClipMachineMemory, 1, 0);

   _clip_retl(ClipMachineMemory, gdk_keyval_is_lower(keyval));
   return 0;
}
Esempio n. 2
0
gboolean
bus_test_client_send_key (BusTestClient *client,
                     guint      keysym)
{
    gboolean is_modifier = _is_modifier_key (keysym);
    gint16 keycode;
    guint state;

    if (is_modifier) {
        IDEBUG ("key: %d is modifier.", keysym);
        gboolean is_modifier_set = _is_modifier_set (client, keysym);
        keycode = _get_keysym_to_keycode (keysym);
        state = _get_modifiers_to_mask (client);

        if (is_modifier_set) {
            state |= IBUS_RELEASE_MASK;
        }
        ibus_input_context_process_key_event (client->ibuscontext,
                                              keysym,
                                              keycode,
                                              state);
        _store_modifier_state (client, keysym);
    } else {
        IDEBUG ("key: %d is not modifier.", keysym);
        gboolean is_upper = !gdk_keyval_is_lower (keysym);
        gboolean is_shift_set = _is_shift_set (client);

        if (is_upper && !is_shift_set) {
            _store_modifier_state (client, IBUS_Shift_L);
        }
        keycode = _get_keysym_to_keycode (keysym);
        state = _get_modifiers_to_mask (client);
        ibus_input_context_process_key_event (client->ibuscontext,
                                              keysym,
                                              keycode,
                                              state);
        state |= IBUS_RELEASE_MASK;
        ibus_input_context_process_key_event (client->ibuscontext,
                                              keysym,
                                              keycode,
                                              state);
        if (is_upper && !is_shift_set) {
            _store_modifier_state (client, IBUS_Shift_L);
        }
    }
    return TRUE;
}
/* A key was pressed in locationbar */
static gboolean _interface_tweaks_on_key_press_event(GSignalInvocationHint *inHint,
														guint inNumberParams,
														const GValue *inParams,
														gpointer inUserData)
{
	g_return_val_if_fail(GTK_IS_ENTRY(inUserData), FALSE);

	GtkEntry				*entry=GTK_ENTRY(inUserData);
	GtkWidget				*target;
	GdkEventKey				*event;
	guint					changedSignalID;
	GSList					*handlers;

	/* Get target of this event and check if it is for locationbar entry */
	target=GTK_WIDGET(g_value_get_object(inParams));
	if(target==GTK_WIDGET(entry))
	{
		/* Get key-event data */
		inParams++;
		event=(GdkEventKey*)g_value_get_boxed(inParams);

		/* Check if key-event would _not_ add any characters */
		if(!(gdk_keyval_is_upper(event->keyval)==gdk_keyval_is_lower(event->keyval) &&
				gdk_unicode_to_keyval(gdk_keyval_to_unicode(event->keyval))!=event->keyval))
		{
			/* Get "changed" signal ID */
			changedSignalID=g_signal_lookup("changed", GTK_TYPE_ENTRY);

			/* Block all unblocked signal handlers for "changed" signal, remove selected
			 * text region from entry text and unblock these signal handlers again.
			 * This way we keep Midori's auto-completion working. Otherwise it fetches the
			 * complete entry text with the text portion in selected text region and adds
			 * the pressed key to it which results in a completely wrong text for auto-completion.
			 */
			handlers=_interface_tweaks_block_all_handlers(G_OBJECT(entry), changedSignalID);

			gtk_editable_delete_selection(GTK_EDITABLE(entry));

			_interface_tweaks_unblock_handlers(G_OBJECT(entry), handlers);
			g_slist_free(handlers);
		}
	}

	return(TRUE);
}