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

  • From: John Scipione <jscipione@xxxxxxxxx>
  • To: "haiku-development@xxxxxxxxxxxxx" <haiku-development@xxxxxxxxxxxxx>
  • Date: Tue, 22 Oct 2013 21:10:56 -0400

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.

How do we know if you have a non-latin keymap or not? We go through
each of the letters on your keymap and test if any of them represent
non-latin characters. I've got a function worked out on how to do
that. If you go to this site: http://unicodelookup.com/ and search for
latin it will bring up the latin Unicode code points.

So, a keymap is considered Latin if all letters on the keymap are in
the Latin list.

Cmd+W would translate to whatever character exists on your keymap
where the 'W' key is positioned in US-International, i.e. the third
button on the third row on a 104/105 key keyboard.

Let's look at the example of the Russian keymap:

The close window shortcut would be translated to CMD+ц (Tse). There is
likely no conflict here since it is unlikely that your app is going to
define CMD+ц, the same goes for the other built-in shortcuts.

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().

We're gonna want app windows to be able to accept this message
constant too so that they can adjust their shortcuts accordingly,
they'll just have to make sure to pass the message along to the
BWindow base class when they're done, at least if they want BWindow to
handle the built-in shortcuts.

Other related posts: