Darwin: Removed support for darwinSwapAltMeta
(cherry picked from commit 3d153c8fa40986d194b7701f5eafa0080e32399a)
This commit is contained in:
		
							parent
							
								
									89c3dfe41e
								
							
						
					
					
						commit
						3839756061
					
				| 
						 | 
				
			
			@ -100,7 +100,6 @@ int                     darwinDesiredDepth = -1;
 | 
			
		|||
int                     darwinDesiredRefresh = -1;
 | 
			
		||||
char                    *darwinKeymapFile = "USA.keymapping";
 | 
			
		||||
int                     darwinSyncKeymap = FALSE;
 | 
			
		||||
int                     darwinSwapAltMeta = FALSE;
 | 
			
		||||
 | 
			
		||||
// modifier masks for faking mouse buttons
 | 
			
		||||
int                     darwinFakeMouse2Mask = NX_ALTERNATEMASK;
 | 
			
		||||
| 
						 | 
				
			
			@ -766,11 +765,6 @@ int ddxProcessArgument( int argc, char *argv[], int i )
 | 
			
		|||
        return 2;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ( !strcmp( argv[i], "-swapAltMeta" ) ) {
 | 
			
		||||
        darwinSwapAltMeta = 1;
 | 
			
		||||
        return 1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ( !strcmp( argv[i], "-keymap" ) ) {
 | 
			
		||||
        if ( i == argc-1 ) {
 | 
			
		||||
            FatalError( "-keymap must be followed by a filename\n" );
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,7 @@
 | 
			
		|||
#ifndef _DARWIN_H
 | 
			
		||||
#define _DARWIN_H
 | 
			
		||||
 | 
			
		||||
// #include "dix-config.h" // This makes us crash for some reason...
 | 
			
		||||
//#include "dix-config.h" // This crashes us for some reason...
 | 
			
		||||
#define SHAPE
 | 
			
		||||
 | 
			
		||||
#include <IOKit/IOTypes.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -113,7 +113,6 @@ extern int              darwinMouseAccelChange;
 | 
			
		|||
extern int              darwinFakeButtons;
 | 
			
		||||
extern int              darwinFakeMouse2Mask;
 | 
			
		||||
extern int              darwinFakeMouse3Mask;
 | 
			
		||||
extern int              darwinSwapAltMeta;
 | 
			
		||||
extern char            *darwinKeymapFile;
 | 
			
		||||
extern int              darwinSyncKeymap;
 | 
			
		||||
extern unsigned int     darwinDesiredWidth, darwinDesiredHeight;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -58,10 +58,7 @@
 | 
			
		|||
 | 
			
		||||
// Define this to get a diagnostic output to stderr which is helpful
 | 
			
		||||
// in determining how the X server is interpreting the Darwin keymap.
 | 
			
		||||
#undef DUMP_DARWIN_KEYMAP
 | 
			
		||||
 | 
			
		||||
/* Define this to use Alt for Mode_switch. */
 | 
			
		||||
//#define ALT_IS_MODE_SWITCH 1
 | 
			
		||||
#define DUMP_DARWIN_KEYMAP
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -77,9 +74,6 @@
 | 
			
		|||
#define MetaMask        Mod2Mask
 | 
			
		||||
#define FunctionMask    Mod3Mask
 | 
			
		||||
 | 
			
		||||
// FIXME: It would be nice to support some of the extra keys in XF86keysym.h,
 | 
			
		||||
// at least the volume controls that now ship on every Apple keyboard.
 | 
			
		||||
 | 
			
		||||
#define UK(a)           NoSymbol    // unknown symbol
 | 
			
		||||
 | 
			
		||||
static KeySym const next_to_x[256] = {
 | 
			
		||||
| 
						 | 
				
			
			@ -513,7 +507,7 @@ Bool DarwinParseNXKeyMapping(
 | 
			
		|||
                        break;
 | 
			
		||||
                    case NX_MODIFIERKEY_ALTERNATE:
 | 
			
		||||
                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
 | 
			
		||||
                                (left ? XK_Mode_switch : XK_Alt_R);
 | 
			
		||||
                                (left ? XK_Alt_L : XK_Alt_R);
 | 
			
		||||
                        break;
 | 
			
		||||
                    case NX_MODIFIERKEY_COMMAND:
 | 
			
		||||
                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
 | 
			
		||||
| 
						 | 
				
			
			@ -638,27 +632,23 @@ Bool DarwinParseNXKeyMapping(
 | 
			
		|||
    return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DarwinBuildModifierMaps
 | 
			
		||||
 *      Use the keyMap field of keyboard info structure to populate
 | 
			
		||||
 *      the modMap and modifierKeycodes fields.
 | 
			
		||||
 */
 | 
			
		||||
static void
 | 
			
		||||
DarwinBuildModifierMaps(
 | 
			
		||||
    darwinKeyboardInfo *info)
 | 
			
		||||
{
 | 
			
		||||
DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
 | 
			
		||||
    int i;
 | 
			
		||||
    KeySym *k;
 | 
			
		||||
 | 
			
		||||
    memset(info->modMap, NoSymbol, sizeof(info->modMap));
 | 
			
		||||
    memset(info->modifierKeycodes, 0, sizeof(info->modifierKeycodes));
 | 
			
		||||
 | 
			
		||||
    for (i = 0; i < NUM_KEYCODES; i++)
 | 
			
		||||
    {
 | 
			
		||||
    for (i = 0; i < NUM_KEYCODES; i++) {
 | 
			
		||||
        k = info->keyMap + i * GLYPHS_PER_KEY;
 | 
			
		||||
 | 
			
		||||
        switch (k[0]) {
 | 
			
		||||
        switch (*k) {
 | 
			
		||||
            case XK_Shift_L:
 | 
			
		||||
                info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
 | 
			
		||||
                info->modMap[MIN_KEYCODE + i] = ShiftMask;
 | 
			
		||||
| 
						 | 
				
			
			@ -728,34 +718,9 @@ DarwinBuildModifierMaps(
 | 
			
		|||
                info->modMap[MIN_KEYCODE + i] = Mod3Mask;
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (darwinSwapAltMeta)
 | 
			
		||||
        {
 | 
			
		||||
            switch (k[0])
 | 
			
		||||
            {
 | 
			
		||||
            case XK_Alt_L:
 | 
			
		||||
                k[0] = XK_Meta_L;
 | 
			
		||||
                break;
 | 
			
		||||
            case XK_Alt_R:
 | 
			
		||||
                k[0] = XK_Meta_R;
 | 
			
		||||
                break;
 | 
			
		||||
            case XK_Meta_L:
 | 
			
		||||
                k[0] = XK_Alt_L;
 | 
			
		||||
                break;
 | 
			
		||||
            case XK_Meta_R:
 | 
			
		||||
                k[0] = XK_Alt_R;
 | 
			
		||||
                break;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if ALT_IS_MODE_SWITCH
 | 
			
		||||
        if (k[0] == XK_Alt_L)
 | 
			
		||||
            k[0] = XK_Mode_switch;
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DarwinLoadKeyboardMapping
 | 
			
		||||
 *  Load the keyboard map from a file or system and convert
 | 
			
		||||
| 
						 | 
				
			
			@ -764,9 +729,17 @@ DarwinBuildModifierMaps(
 | 
			
		|||
static void
 | 
			
		||||
DarwinLoadKeyboardMapping(KeySymsRec *keySyms)
 | 
			
		||||
{
 | 
			
		||||
    int i;
 | 
			
		||||
    KeySym *k;
 | 
			
		||||
 | 
			
		||||
    memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
 | 
			
		||||
 | 
			
		||||
    /* TODO: Clean this up
 | 
			
		||||
     * DarwinModeReadSystemKeymap is in quartz/quartzKeyboard.c
 | 
			
		||||
     * DarwinParseNXKeyMapping is here
 | 
			
		||||
     */
 | 
			
		||||
    if (!DarwinParseNXKeyMapping(&keyInfo)) {
 | 
			
		||||
        DEBUG_LOG("DarwinParseNXKeyMapping returned 0... running DarwinModeReadSystemKeymap().\n");
 | 
			
		||||
        if (!DarwinModeReadSystemKeymap(&keyInfo)) {
 | 
			
		||||
            FatalError("Could not build a valid keymap.");
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -775,20 +748,18 @@ DarwinLoadKeyboardMapping(KeySymsRec *keySyms)
 | 
			
		|||
    DarwinBuildModifierMaps(&keyInfo);
 | 
			
		||||
 | 
			
		||||
#ifdef DUMP_DARWIN_KEYMAP
 | 
			
		||||
    ErrorF("Darwin -> X converted keyboard map\n");
 | 
			
		||||
    for (i = 0, k = info->keyMap; i < NX_NUMKEYCODES;
 | 
			
		||||
    DEBUG_LOG("Darwin -> X converted keyboard map\n");
 | 
			
		||||
    for (i = 0, k = keyInfo.keyMap; i < NX_NUMKEYCODES;
 | 
			
		||||
         i++, k += GLYPHS_PER_KEY)
 | 
			
		||||
    {
 | 
			
		||||
        int j;
 | 
			
		||||
        ErrorF("0x%02x:", i);
 | 
			
		||||
        for (j = 0; j < GLYPHS_PER_KEY; j++) {
 | 
			
		||||
            if (k[j] == NoSymbol) {
 | 
			
		||||
                ErrorF("\tNoSym");
 | 
			
		||||
                DEBUG_LOG("0x%02x:\tNoSym\n", i);
 | 
			
		||||
            } else {
 | 
			
		||||
                ErrorF("\t0x%x", k[j]);
 | 
			
		||||
                DEBUG_LOG("0x%02x:\t0x%lx\n", i, k[j]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        ErrorF("\n");
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -936,32 +907,6 @@ int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide)
 | 
			
		|||
    return key;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DarwinModifierNXMaskToNXKeyCode
 | 
			
		||||
 *      Returns 0 if mask is not a known modifier mask.
 | 
			
		||||
 */
 | 
			
		||||
int DarwinModifierNXMaskToNXKeyCode(int mask)
 | 
			
		||||
{
 | 
			
		||||
  switch (mask) {
 | 
			
		||||
  case NX_ALPHASHIFTMASK:       return XK_Caps_Lock;
 | 
			
		||||
  case NX_SHIFTMASK: ErrorF("Warning: Received NX_SHIFTMASK, treating as NX_DEVICELSHIFTKEYMASK\n");
 | 
			
		||||
  case NX_DEVICELSHIFTKEYMASK:  return NX_MODIFIERKEY_SHIFT; //XK_Shift_L;
 | 
			
		||||
  case NX_DEVICERSHIFTKEYMASK:  return NX_MODIFIERKEY_RSHIFT; //XK_Shift_R;
 | 
			
		||||
  case NX_CONTROLMASK: ErrorF("Warning: Received NX_CONTROLMASK, treating as NX_DEVICELCTLKEYMASK\n");
 | 
			
		||||
  case NX_DEVICELCTLKEYMASK:    return XK_Control_L;
 | 
			
		||||
  case NX_DEVICERCTLKEYMASK:    return XK_Control_R;
 | 
			
		||||
  case NX_ALTERNATEMASK: ErrorF("Warning: Received NX_ALTERNATEMASK, treating as NX_DEVICELALTKEYMASK\n");
 | 
			
		||||
  case NX_DEVICELALTKEYMASK:    return XK_Alt_L;
 | 
			
		||||
  case NX_DEVICERALTKEYMASK:    return XK_Alt_R;
 | 
			
		||||
  case NX_COMMANDMASK: ErrorF("Warning: Received NX_COMMANDMASK, treating as NX_DEVICELCMDKEYMASK\n");
 | 
			
		||||
  case NX_DEVICELCMDKEYMASK:    return XK_Meta_L;
 | 
			
		||||
  case NX_DEVICERCMDKEYMASK:    return XK_Meta_R;
 | 
			
		||||
  case NX_NUMERICPADMASK:       return XK_Num_Lock;
 | 
			
		||||
  case NX_HELPMASK:             return XK_Help;
 | 
			
		||||
  case NX_SECONDARYFNMASK:      return XK_Control_L; // this seems very wrong, but is what the old code did
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DarwinModifierNXMaskToNXKey
 | 
			
		||||
 *      Returns -1 if mask is not a known modifier mask.
 | 
			
		||||
| 
						 | 
				
			
			@ -997,7 +942,7 @@ int DarwinModifierNXMaskToNXKey(int mask)
 | 
			
		|||
    return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char * DarwinModifierNXMaskTostring(int mask)
 | 
			
		||||
const char *DarwinModifierNXMaskTostring(int mask)
 | 
			
		||||
{
 | 
			
		||||
    switch (mask) {
 | 
			
		||||
        case NX_ALPHASHIFTMASK:      return "NX_ALPHASHIFTMASK";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -612,9 +612,6 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
 | 
			
		|||
    quartzXpluginOptions = [self prefs_get_integer:@PREFS_XP_OPTIONS
 | 
			
		||||
                            default:quartzXpluginOptions];
 | 
			
		||||
#endif
 | 
			
		||||
	
 | 
			
		||||
    darwinSwapAltMeta = [self prefs_get_boolean:@PREFS_SWAP_ALT_META
 | 
			
		||||
                         default:darwinSwapAltMeta];
 | 
			
		||||
    darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS
 | 
			
		||||
                         default:darwinFakeButtons];
 | 
			
		||||
    if (darwinFakeButtons) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue