ashie/gtkimcocoa — pull request #1 by mhutch (2013-05-23 19:03:33+00:00)
Title: Stop beeping on every keypress

When the immodule is enabled, it currently causes a beep on every keypress. I think the problem is that it's passing unhandled commands to NSResponder's doCommandBySelector implementation, which beeps when it can't handle a command.

In GDB I set a breakpoint on NSBeep and found:

Breakpoint 27, 0x96ffa3e1 in NSBeep ()
(gdb) bt
#0 0x96ffa3e1 in NSBeep ()
#1 0x96fc52ba in -[NSResponder doCommandBySelector:] ()
#2 0x0b9fc5d0 in -[GtkCocoaIMClient doCommandBySelector:] (self=0x83e125d0, _cmd=0x97935ddb, aSelector=0x97962526) at GtkCocoaIMClient.c:153
#3 0x97056053 in -[NSTextInputContext doCommandBySelector:] ()
#4 0x97055fcd in -[NSTextInputContext _handleCommand:] ()
#5 0x97050999 in -[NSKeyBindingManager(NSKeyBindingManager_MultiClients) interpretEventAsCommand:forClient:] ()
#6 0x9704fe25 in -[NSTextInputContext handleEvent:] ()
#7 0x9704f895 in -[NSView interpretKeyEvents:] ()
#8 0x0b9fbfc6 in -[GtkCocoaIMClient filterKeyDown:] (self=0x83e125d0, _cmd=0x6f141d5, keyDownEvent=0x8499ef80) at GtkCocoaIMClient.c:60
#9 0x0b9fb767 in filter_keypress (context=0x7d0a8c38, event=0x7d485c18) at gtkimcontextcocoa.c:213
#10 0x029c98c0 in gtk_im_context_filter_keypress (context=0x7d0a8c38, key=0x7d485c18) at gtkimcontext.c:473
#11 0x029ce075 in gtk_im_multicontext_filter_keypress (context=0x7dbeaf30, event=0x7d485c18) at gtkimmulticontext.c:333
#12 0x029c98c0 in gtk_im_context_filter_keypress (context=0x7dbeaf30, key=0x7d485c18) at gtkimcontext.c:473

etc.

And the `aSelector` being passed to the `doCommandBySelector:` is `moveDown:`:

(gdb) p (char *) 0x97962526+8
$1 = 0x9796252e "moveDown:"

The [Apple docs](https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Protocols/NSTextInput_Protocol/Reference/Reference.html) say that although `doCommandBySelector:` is required on NSTextInputClient, it should not chain unhandled commands to its super NSResponder.