Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 153432 - [KeyBindings] Unicode keyboards on Mac OSX produce wrong keys when used with modifiers
Summary: [KeyBindings] Unicode keyboards on Mac OSX produce wrong keys when used with ...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 major with 3 votes (vote)
Target Milestone: 3.5 M5   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 238647 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-08-10 10:22 EDT by Nikolaj Schumacher CLA
Modified: 2009-06-01 14:16 EDT (History)
4 users (show)

See Also:


Attachments
proposed patch (13.17 KB, patch)
2006-08-19 05:44 EDT, Nikolaj Schumacher CLA
no flags Details | Diff
my keyboard layout (38.82 KB, application/octet-stream)
2006-08-30 05:33 EDT, Nikolaj Schumacher CLA
no flags Details
patch for 3325 (17.08 KB, patch)
2007-02-25 14:07 EST, Nikolaj Schumacher CLA
Silenio_Quarti: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolaj Schumacher CLA 2006-08-10 10:22:12 EDT
I use a custom unicode keyboard layout (.keylayout, cf. http://developer.apple.com/technotes/tn2002/tn2056.html).

Typing normal text results in the appropriate letters being printed, but in combination with a modifier, the wrong key events are triggered!
For instance Command+J on my dvorak keyboard will incorrectly copy the selection (presumably because J on a dvorak keyboard is where the C is on a regular keybard).
Comment 1 Paul Webster CLA 2006-08-10 10:31:12 EDT
for fun see what looks like the opposite problem, bug 153238

That's where we only accept the mapped key, not the original hardware key.

PW
Comment 2 Nikolaj Schumacher CLA 2006-08-17 10:48:29 EDT
I now believe this is caused by SWT.
More precisely in org/eclipse/swt/widgets/Widget.java around line 1900 OS.KeyTranslate is called, which should be UCKeyTranslate for unicode keyboards.

I believe the correct way to handle this would be to query KLGetKeyboardLayoutProperty with kKLKind, as that's how I fixed pretty much the same bug in GNU Emacs. (That patch can be found at http://groups.google.com/group/gnu.emacs.bug/browse_thread/thread/91a762947293db61/920d55eaeca19df7) 
Comment 3 Nikolaj Schumacher CLA 2006-08-19 05:44:10 EDT
Created attachment 48220 [details]
proposed patch

I've written a patch that fixes this issue for me.
Comment 4 Steve Northover CLA 2006-08-28 22:20:08 EDT
We should fix this.
Comment 5 Silenio Quarti CLA 2006-08-29 15:14:56 EDT
I am not sure how to reproduce your problem. I am using the SWT Snippet25 and it seems that the output is appropriate when I press Cmd+J with dvorak keyboard. Please could you provide your custom keyboard layout and steps how to reproduce the problem with the custom keyboard layout or with one of the default unicode layouts?

Pressed j
DOWN: stateMask=0x0, keyCode=0x6a 'j', character=0x6a 'j'
UP  : stateMask=0x0, keyCode=0x6a 'j', character=0x6a 'j'

Pressed Shift+j
DOWN: stateMask=0x0, keyCode=0x20000 SHIFT, character=0x0 '\0'
DOWN: stateMask=0x20000 SHIFT, keyCode=0x6a 'j', character=0x4a 'J'
UP  : stateMask=0x20000 SHIFT, keyCode=0x6a 'j', character=0x4a 'J'
UP  : stateMask=0x20000 SHIFT, keyCode=0x20000 SHIFT, character=0x0 '\0'

Pressed Cmd+j
DOWN: stateMask=0x0, keyCode=0x400000 COMMAND, character=0x0 '\0'
DOWN: stateMask=0x400000 COMMAND, keyCode=0x6a 'j', character=0x6a 'j'
UP  : stateMask=0x400000 COMMAND, keyCode=0x400000 COMMAND, character=0x0 '\0'
UP  : stateMask=0x0, keyCode=0x6a 'j', character=0x6a 'j'
Comment 6 Nikolaj Schumacher CLA 2006-08-30 05:33:03 EDT
Created attachment 49045 [details]
my keyboard layout

Drop this file into ~/Library/Keyboard Layouts/ (create if needed), log off and on, and select this keyboard the same way as any other.

What I get with Snippet25 is this:
DOWN: stateMask=0x0, keyCode=0x63 'c', character=0x6a 'j'
UP  : stateMask=0x0, keyCode=0x63 'c', character=0x6a 'j'


Most system keyboards provide both a unicode and classic keyboard resource, which is why this problem doesn't appear with the regular dvorak keyboard.
Comment 7 Nikolaj Schumacher CLA 2007-02-25 14:07:53 EST
Created attachment 59751 [details]
patch for 3325

a new patch that applies cleanly to the current development (3325) version
Comment 8 Bro CLA 2008-07-01 10:03:53 EDT
*** Bug 238647 has been marked as a duplicate of this bug. ***
Comment 9 Mathias De Belder CLA 2009-01-11 10:58:56 EST
I've ran into this bug too. I'm using a custom keyboard layout defined through Ukelele (http://scripts.sil.org/ukelele) to work around the horrible default keyboard layout defined by Apple for AZERTY-type keyboards. The default layout differs substantially from the PC and old typewriter versions and is basically unusable for touch typists or for use in the JDT because most of the interesting "{}[]\|" characters are behind complex, RSI-inducing shortcuts.

Like stated in comment #6, this custom keyboard layout only provides a unicode version. However, this layout works fine in Carbon, Cocoa and AWT/Swing applications. In SWT-apps, the "plain" keys work, but typing CMD-Z actually sends CMD-W to the app, resulting in closing the window instead of undoing a change in the JDT for instance.

Is there something wrong with the proposed patch that it hasn't gone in yet ? Admittedly, there are probably few people affected by this; but for those that are it makes SWT apps with keyboard shortcuts  very user-unfriendly.

Comment 10 Steve Northover CLA 2009-01-12 16:26:08 EST
Silenio, do you have any more on this?
Comment 11 Silenio Quarti CLA 2009-01-20 19:39:45 EST
Fixed > 20090120. Please try the latest and reopen if you still see issues.