Re: Modifier keys



OK, I went ahead and implemented all of this. It is a little bigger
than I might of like but generally went smoothly and seems to be
working well. It's sort of neat to load up a Russian keymap and
be able to use the same Emacs keybindings in both groups, and 
I think it should resolve a lot of less obvious strangeness in key
bindings as well.

The main issue that I know of with this patch is that it doesn't
handle keymap changes while the app is running; to do that, we need
some sort of notification mechanism when a GdkKeymap changes, which
would mean a small API addition, though it could be treated as a GTK+
<=> GDK private API.  (Most of the code is there to handle changes is
in gdkkeymap.c, #ifdef'ed out.)

There are some small changes in the interpretation of key bindings
here. The main one that you might notice is that it used to be
that for typical keyboards:

 Tab                 --  matched [Tab]
 <Shift>Tab          --  matched nothing
 ISO_Left_Tab        --  matched nothing
 <Shift>ISO_Left_Tab --  matched <Shift>[Tab]

While now:

 Tab                 --  matches [Tab]
 <Shift>Tab          --  matches <Shift>[Tab]
 ISO_Left_Tab        --  matches <Shift>[Tab]
 <Shift>ISO_Left_Tab --  matches <Shift>[Tab]

Some parts of GTK+ added a key binding of ISO_Left_Tab where they
only wanted to match an unshifted Tab; these bugs needed to be fixed
with this change. 

I'm planning to commit this patch tomorrow morning after I have
a night or so to think of any problems that it might have. If any
body wants to look this patch over or try it out, I'd certainly 
appriciate it.

Regards,
                                        Owen

ChangeLog:

Wed Feb 20 14:26:47 2002  Owen Taylor  <otaylor redhat com>

	* gtk/gtkkeyhash.[ch]: Implement "fuzzy" key binding lookups;
	allow matches on key and level but not group. Also, implement 
	ignoring "consumed modifiers correctly."

	* gtk/gtkaccelgroup.c gtk/gtkbindings.c: Convert to using
	GtkKeyHash.
	
	* gtk/gtkdebug.h gtk/gtkmain.c: Support GTK_DEBUG=keybindings

	* gdk/x11/gdkevents-x11.c (gdk_event_translate): Fill in
	the group for key release events as well as key press events.

	* gdk/gdkkeys.h gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): 
	Rename unused_modifiers to consumed_modifiers, make the docs and
	non-Xkb implementation match the Xkb implementation.

	* gdk/linux-fb/gdkkeyboard-fb.c gdk/win32/gdkkeys-win32.c: Propagate
	doc and parameter name changes.

	* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
	XkbTranslateKeyCode doesn't handle LockMask, we need to handle
	it ourselves.

	* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): Force
	<Shift>Tab to give GDK_ISO_Left_Tab, since we need consistency
	to allow dealing with ISO_Left_Tab.
	
	* gtk/gtkwindow.c gtk/gtktextview.c gtk/gtkscrolledwindow.c
	gtk/gtkpaned.c gtk/gtkcombo.c  gtk/gtknotebook.c:
	Remove inappropriate uses of GDK_ISO_Left_Tab. (GDK_ISO_Left_Tab
	or <Shift>Tab both are equivalent as a binding specifier.)

	* gtk/gtkbutton.c (gtk_button_class_init): Make ::activate
	GTK_RUN_ACTION, so you can bind an accelerator to it.

	* gtk/gtklabel.c (gtk_label_set_uline_text_internal): Call 
	gdk_unicode_to_keyval on the mnemonic character.

	* tests/testgtk.c: Add a test for the new fuzzy key binding matching.

Attachment: keyhash.diff.gz
Description: Patch adding fuzzy key binding matching



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]