Beispiel #1
0
/* Returns TRUE if the given key value is in upper case. */
int
clip_GDK_KEYVALISUPPER(ClipMachine * ClipMachineMemory)
{
   guint     keyval = INT_OPTION(ClipMachineMemory, 1, 0);

   _clip_retl(ClipMachineMemory, gdk_keyval_is_upper(keyval));
   return 0;
}
/* 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);
}
Beispiel #3
0
bool tmKey::uniToWxk(wxChar uniCode, int& wxk, int& mod) // static
{
#ifdef __WXMSW__
    // Convert key to scan code
    const SHORT scancode = ::VkKeyScan(uniCode);
    const unsigned char vk = LOBYTE(scancode);     // Low eight bits = virtual-key code
    const int state = HIBYTE(scancode);   // The next eight bits = shift state
    if (state & 1) mod |= wxMOD_SHIFT;
    if (state & 2) mod |= wxMOD_CONTROL;
    if (state & 4) mod |= wxMOD_ALT;

    wxk = wxCharCodeMSWToWX(vk, 0);
    if (wxk == 0) {
        // Normal ascii char
        // Note that this is set to the virtual keycode (which does not necessarily
        // correspond to the ascii value). This is needed because keydown events
        // report it in this format.
        wxk = vk;
    }
    return true;
#elif defined(__WXGTK__)
    guint keyval = gdk_unicode_to_keyval(uniCode);
    if (keyval & 0x01000000)
        return false;
    if (gdk_keyval_is_upper(keyval))
    {
        mod |= wxMOD_SHIFT;
        keyval = gdk_keyval_to_lower(keyval);
#ifdef __WXDEBUG__
    wxLogDebug(wxT("uniToWxk(%x - %c) downshifting keycode is %x"), uniCode, uniCode, keyval);
#endif //__WXDEBUG__
    }
    // FIXME not too correct - this is wxChar not wxKeyCode
    wxk = gdk_keyval_to_unicode(keyval);
#ifdef __WXDEBUG__
    wxLogDebug(wxT("uniToWxk(%x - %c) to %x - %c"), uniCode, uniCode, wxk, wxk);
#endif //__WXDEBUG__
    return true;
#else
#error Unknown platform
#endif
}