[haiku-development] Re: Bug #2499 Shortcuts based on default keymap

  • From: Adrien Destugues <pulkomandy@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 23 Oct 2013 07:48:30 +0200

On 2013-10-23 at 03:10:56 [+0200], John Scipione <jscipione@xxxxxxxxx> 
wrote:
> Hi List,
> 
> I wanted to bounce an idea off of you guys about a solution I've
> thought up to bug #2499
> 
> http://dev.haiku-os.org/ticket/2499
> 
> The problem is that the default shortcuts in BWindow don't work on
> non-latin keymaps because these keys don't exist on that keymap. For
> example the Russian keymap doesn't have a 'W' key, so, Cmd+'W' doesn't
> work to close a window.
> 
> Here is my idea.
> 
> We detect if you have a non-latin keymap, and if so, map these
> shortcuts to letters that appear in the same positions on the default
> US-International keymap rather than mapping them to the letters in the
> current keymap.

Why do that ? Isn't it enough to search for the requested symbol (for each 
shortcut) and act only if it's missing ?

I'd use an algorithm like this:
 - Window requests a shortcut for cmd+W
 - Look for cmd+W in the current keymap
 - If found, assign the shortcut there
 - If not found, look in US international keymap
 - Assign the shortcut at that key position

> There is an additional problem of the mapping changing when you switch
> keymaps as well, that would need to be handled, actually, it's already
> a problem.
> 
> My thought process here is that we add a B_KEYMAP_CHANGED message
> constant similar to B_LOCALE_CHANGED that gets fired when the keymap
> changes. We then update BWindow::MessageReceived() accept this
> constant and when it is received we remove and add the shortcuts as
> long as they aren't already taken, which we can check with
> HasShortcut().

This is more tricky than it looks: when you switch AZERTY/QWERTY for 
example, cmd+Z and cmd+W will have to be swapped. With your proposal this 
won't happen, because they each conflict with the other.


I think this problem needs more thinking and work than just a few tweaks to 
the code. How do other systems/UI toolkits handle it, for example ? 
(someone non-latin keymap user around ? can you tell us what happens in 
Linux,Windows,OS X, ... ?) We may need to introduce a new shortcuts API 
alongside the old one that allows this to work. Without making it too 
painful to handle for app developers.

-- 
Adrien.

Other related posts: