Bug 41607 - keypad(mac) is not really mac
Summary: keypad(mac) is not really mac
Status: RESOLVED FIXED
Alias: None
Product: xkeyboard-config
Classification: Unclassified
Component: General (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: xkb
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 8280
Blocks:
  Show dependency treegraph
 
Reported: 2011-10-09 02:58 UTC by Rimas Kudelis
Modified: 2011-10-16 13:41 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Make numpad(mac) always enter Level2, regardless of NumLock and other modifiers (1.94 KB, patch)
2011-10-15 05:09 UTC, Rimas Kudelis
Details | Splinter Review

Description Rimas Kudelis 2011-10-09 02:58:49 UTC
Here's the definition of keypad(mac):

// On Mac keypads, level 1 and 2 are swapped
partial xkb_types "mac" {
    type "KEYPAD" {
        modifiers = Shift+NumLock;
        map[None] = Level2;
        map[Shift] = Level1;
        map[NumLock] = Level1;
        map[Shift+NumLock] = Level2;
        level_name[Level2] = "Base";
        level_name[Level1] = "Number";
    };
    include "extra(mac_keypad)"
};

From my experience, this is incorrect. AFAIK, on Macs (at least on Intel ones), NumLock key simply does not exist, and the numeric keypad keys enter numbers at least in both normal and Shift (if not in all) layers. NumLock is replaced by a Clear key instead.

My suggestions:
1) if desired, rename the current definition to 'keypad(invert)' or 'keypad(swap)' or something similar.

2) define keypad(mac) somewhat like this:
// Mac keypads enter numbers regardless of NumLock state
partial xkb_types "mac" {
    type "KEYPAD" {
        modifiers = LevelThree;
        map[None] = Level2;
        map[LevelThree] = Level1;
        level_name[Level2] = "Number";
        level_name[Level1] = "AltGr";
    };
    include "extra(mac_keypad)"
};

This would make arrow keys still accessible using L3Shift, which I'm not sure is really needed, since I'm not sure whether or not Apple keyboard layouts actually do that (can check on Monday). Alternatively, this definition could be edited to enter Level3 and Level4 symbols in appropriate layers or be as small as this:

// Mac keypads enter numbers regardless of NumLock state
partial xkb_types "mac" {
    type "KEYPAD" {
        modifiers = None;
        map[None] = Level2;
        level_name[Level2] = "Number";
    };
    include "extra(mac_keypad)"
};

Since NumLock becomes effectively unused in this situation, it's probably worth to also define it as Clear or XF86Clear here.

By the way, why are Clear and XF86Clear both used, even in symbols/macintosh_vndr/apple? Shouldn't this be unified somehow?
Comment 1 Sergey V. Udaltsov 2011-10-09 05:33:22 UTC
Actually, that type was introduced in the patch for the bug #8280.
Comment 2 Rimas Kudelis 2011-10-14 00:21:04 UTC
OK, I checked the layout files that I have and also looked at what my mac at work does.

The conclusion is that the numpad ALWAYS enters digits on Mac, regardless of the layer (in some combinations, however, that is being interpreted as a shortcut and not typed). That is, I can enter e.g. digit 1 by pressing:
1
Shift+1
Alt+1
Shift+Alt+1
Shift+Ctrl+1
Alt+Ctrl+1
Shift+Alt+Ctrl+1

The digit is not being echoed when I press Ctrl+1 and with any combination involving the Cmd key (which is obviously treated as a keyboard shortcut).

So, my conclusion is what I said in Comment #0: we can either make those keys ALWAYS enter digits, or we can cheat a bit and provide cursor control keys in some levels, but in any case, NumLock can, and probably should, be simply ignored.
Comment 3 Sergey V. Udaltsov 2011-10-14 14:30:53 UTC
> So, my conclusion is what I said in Comment #0: we can either make those keys
> ALWAYS enter digits, or we can cheat a bit and provide cursor control keys in
> some levels, but in any case, NumLock can, and probably should, be simply
> ignored.
Let's follow the rules set by Apple. Always digits.
Comment 4 Rimas Kudelis 2011-10-15 05:09:04 UTC
Created attachment 52362 [details] [review]
Make numpad(mac) always enter Level2, regardless of NumLock and other modifiers

This patch:
* Makes numpad(mac) type always enter Level2, regardless of NumLock and other modifiers. I called the level 'Number', but I'm not sure where exactly level_name is used. Perhaps it should be called 'Base' instead.
* drops extra(mac_keypad) type. If one wants to use NumLock (which is nonexistant on Macs), then they should just use it as intended, and make it on by default. Simple reversing of NumLock's effect just doesn't make much sense IMO.
* (hardly related) replaces a reference to XF86Clear with one to Clear in symbols/macintosh_vndr/apple. It doesn't make sense for apple(laptop) and apple(alukbd) to use inconsistent Clears.


Is it possible to automatically make NumLock key become a Clear when numpad(mac) is in use? If not, I think it's fine too. In that case perhaps a preference specifying how the NumLock key works should be introduced.
Comment 5 Rimas Kudelis 2011-10-15 06:08:32 UTC
I think it would probably make sense to actually avoid mentioning Mac here at all, or at least to make the text more descriptive. For example:

Current: Numeric keypad keys work as with Mac
Suggestion: Numeric keypad keys always enter digits (like on Mac)
Comment 6 Sergey V. Udaltsov 2011-10-16 13:41:54 UTC
Fair enough. committed. thank you!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.