Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 103596 | Differences between
and this patch

Collapse All | Expand All

(-)src/macterm.c.orig (-47 / +199 lines)
Lines 87-100 Link Here
87
#include "atimer.h"
87
#include "atimer.h"
88
#include "keymap.h"
88
#include "keymap.h"
89
89
90
/* Set of macros that handle mapping of Mac modifier keys to emacs.  */
90
/* Set of macros that handle mapping of Mac modifier keys to emacs.  
91
#define macCtrlKey     (NILP (Vmac_reverse_ctrl_meta) ? controlKey :	\
91
    If any of the newer-style mac_*_modifier variables is set, these 
92
			(NILP (Vmac_command_key_is_meta) ? optionKey : cmdKey))
92
    macros are basically out of function.
93
 */
94
 
95
#define macOldModifierSetting   (  NILP(Vmac_control_modifier) && \
96
				   NILP(Vmac_option_modifier) && \
97
				   NILP(Vmac_command_modifier)   )
98
 
99
#define macCtrlKey     (macOldModifierSetting ? \
100
 			(NILP(Vmac_reverse_ctrl_meta) ? controlKey :	\
101
 			       (NILP(Vmac_command_key_is_meta) ? \
102
				optionKey : cmdKey)) :		 \
103
 			controlKey)
93
#define macShiftKey    (shiftKey)
104
#define macShiftKey    (shiftKey)
94
#define macMetaKey     (NILP (Vmac_reverse_ctrl_meta) ?			\
105
 
95
			(NILP (Vmac_command_key_is_meta) ? optionKey : cmdKey) \
106
#define macMetaKey     (macOldModifierSetting ? \
96
			: controlKey)
107
 			(NILP(Vmac_reverse_ctrl_meta) ?		\
97
#define macAltKey      (NILP (Vmac_command_key_is_meta) ? cmdKey : optionKey)
108
 			 (NILP(Vmac_command_key_is_meta) ? optionKey : \
109
			  cmdKey) : controlKey) :		       \
110
 			(cmdKey | controlKey | optionKey))
111
 
112
#define macAltKey     (macOldModifierSetting ?  \
113
			(NILP(Vmac_command_key_is_meta) ? \
114
			 cmdKey : optionKey) : optionKey)
115
 
116
#define macCmdKey (cmdKey)
98
117
99
118
100
/* Non-nil means Emacs uses toolkit scroll bars.  */
119
/* Non-nil means Emacs uses toolkit scroll bars.  */
Lines 206-212 Link Here
206
225
207
/* The keysyms to use for the various modifiers.  */
226
/* The keysyms to use for the various modifiers.  */
208
227
209
static Lisp_Object Qalt, Qhyper, Qsuper, Qmodifier_value;
228
static Lisp_Object Qalt, Qhyper, Qsuper, Qctrl, Qmeta, Qmodifier_value;
210
229
211
extern int inhibit_window_system;
230
extern int inhibit_window_system;
212
231
Lines 7294-7306 Link Here
7294
/* Contains the string "reverse", which is a constant for mouse button emu.*/
7313
/* Contains the string "reverse", which is a constant for mouse button emu.*/
7295
Lisp_Object Qreverse;
7314
Lisp_Object Qreverse;
7296
7315
7297
/* True if using command key as meta key.  */
7316
/* True if using command key as meta key.  
7317
   Deprecated; only use if macOldModifierSetting evaluates to true. */
7298
Lisp_Object Vmac_command_key_is_meta;
7318
Lisp_Object Vmac_command_key_is_meta;
7299
7319
7320
/* Modifier associated with the control key, or nil for normal behavior. */
7321
Lisp_Object Vmac_control_modifier;
7322
7300
/* Modifier associated with the option key, or nil for normal behavior. */
7323
/* Modifier associated with the option key, or nil for normal behavior. */
7301
Lisp_Object Vmac_option_modifier;
7324
Lisp_Object Vmac_option_modifier;
7302
7325
7303
/* True if the ctrl and meta keys should be reversed.  */
7326
/* Modifier associated with the command key, or nil for normal behavior. */
7327
Lisp_Object Vmac_command_modifier;
7328
7329
/* True if the ctrl and meta keys should be reversed. 
7330
	Deprecated; only use if macOldModifierSetting evaluates to true. */
7304
Lisp_Object Vmac_reverse_ctrl_meta;
7331
Lisp_Object Vmac_reverse_ctrl_meta;
7305
7332
7306
/* True if the option and command modifiers should be used to emulate
7333
/* True if the option and command modifiers should be used to emulate
Lines 7320-7325 Link Here
7320
   for processing before Emacs sees it.  */
7347
   for processing before Emacs sees it.  */
7321
Lisp_Object Vmac_pass_control_to_system;
7348
Lisp_Object Vmac_pass_control_to_system;
7322
7349
7350
/* If  non-nil, the Mac \"Option\" key can be used to compose
7351
       characters as handled by the system and depending on the
7352
       keyboard layout chosen. Only if the Mac \"Command\" or \"Ctrl\" key
7353
       is depressed at the same time, Emacs evaluates the combination using
7354
       whatever modifier is set in mac-option-modifier.  */
7355
Lisp_Object Vmac_pass_option_to_system;
7356
7323
/* Points to the variable `inev' in the function XTread_socket.  It is
7357
/* Points to the variable `inev' in the function XTread_socket.  It is
7324
   used for passing an input event to the function back from
7358
   used for passing an input event to the function back from
7325
   Carbon/Apple event handlers.  */
7359
   Carbon/Apple event handlers.  */
Lines 7377-7393 Link Here
7377
  unsigned int result = 0;
7411
  unsigned int result = 0;
7378
  if (mods & macShiftKey)
7412
  if (mods & macShiftKey)
7379
    result |= shift_modifier;
7413
    result |= shift_modifier;
7380
  if (mods & macCtrlKey)
7414
7381
    result |= ctrl_modifier;
7415
  if (macOldModifierSetting)   /* compatibility with old-style modifier keys */
7382
  if (mods & macMetaKey)
7416
    {
7383
    result |= meta_modifier;
7417
      if (mods & macCtrlKey)
7384
  if (NILP (Vmac_command_key_is_meta) && (mods & macAltKey))
7418
	result |= ctrl_modifier;
7385
    result |= alt_modifier;
7419
      if (mods & macMetaKey)
7386
  if (!NILP (Vmac_option_modifier) && (mods & optionKey)) {
7420
	result |= meta_modifier;
7387
      Lisp_Object val = Fget(Vmac_option_modifier, Qmodifier_value);
7421
7388
      if (!NILP(val))
7422
      if ( ( NILP(Vmac_pass_option_to_system) || 
7423
	     ( /* only for ctrl/cmd combos if option is handled by system */
7424
	      (mods & cmdKey) || (mods & controlKey) 
7425
	       )
7426
	     ) &&
7427
	   !NILP (Vmac_command_key_is_meta) &&
7428
	   (mods & macAltKey) 
7429
	)
7430
	result |= alt_modifier;
7431
    } else
7432
    {
7433
      /* new-style modifier keys */ 
7434
7435
      /* if Vmac_pass_option_to_system is NIL, we fully process the Option
7436
	 key. Otherwise, we only process it if an additional Ctrl or Command
7437
	 is pressed. That way the system may convert the character to a 
7438
	 composed one.
7439
      */
7440
7441
      if (
7442
	  (mods & optionKey) &&
7443
	  (
7444
	   ( NILP(Vmac_pass_option_to_system) || 
7445
	     ( 
7446
	      (mods & cmdKey) || (mods & controlKey) 
7447
	       )
7448
	     )
7449
	   )
7450
	  )
7451
	{
7452
	  if (!NILP (Vmac_option_modifier)) {
7453
	    Lisp_Object val = Fget(Vmac_option_modifier, Qmodifier_value);
7454
	    if (!NILP(val))
7455
	      result |= XUINT(val);
7456
	  } else { /* default behavior if modifier variable is set to nil: 
7457
		      do NOT assume alt modifier, because the OS already 
7458
		      sends a modified key (e.g. option-l -> @ 
7459
		      on German keyboard) */
7460
	      
7461
	      result |= alt_modifier;  
7462
	  }
7463
7464
	}
7465
      if (!NILP (Vmac_command_modifier) && (mods & cmdKey)) {
7466
	Lisp_Object val = Fget(Vmac_command_modifier, Qmodifier_value);
7467
	if (!NILP(val))
7389
          result |= XUINT(val);
7468
          result |= XUINT(val);
7390
  }
7469
      } else { /* default behavior if modifier variable is not set: 
7470
		  assign hyper*/
7471
	if (mods & macCmdKey)
7472
	  result |= hyper_modifier;
7473
      }
7474
      if (!NILP (Vmac_control_modifier) && (mods & controlKey)) {
7475
	Lisp_Object val = Fget(Vmac_control_modifier, Qmodifier_value);
7476
	if (!NILP(val))
7477
          result |= XUINT(val);
7478
      } else { /* default behavior if modifier variable is not set */
7479
	if (mods & macCtrlKey)
7480
	  result |= ctrl_modifier;
7481
      }
7482
    }
7391
7483
7392
  return result;
7484
  return result;
7393
}
7485
}
Lines 9299-9307 Link Here
9299
		 || !(er.modifiers & cmdKey))
9391
		 || !(er.modifiers & cmdKey))
9300
		&& (!NILP (Vmac_pass_control_to_system)
9392
		&& (!NILP (Vmac_pass_control_to_system)
9301
		    || !(er.modifiers & controlKey))
9393
		    || !(er.modifiers & controlKey))
9302
		&& (!NILP (Vmac_command_key_is_meta)
9394
		&& (!NILP (Vmac_pass_option_to_system)
9303
		    && NILP (Vmac_option_modifier)
9395
		    || (macOldModifierSetting ?
9304
		    || !(er.modifiers & optionKey)))
9396
		    ((!NILP (Vmac_command_key_is_meta)
9397
		      && NILP (Vmac_option_modifier)
9398
		      || !(er.modifiers & optionKey)))
9399
			:  !(er.modifiers & optionKey))
9400
		    )
9401
		)
9305
	      if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
9402
	      if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
9306
		  != eventNotHandledErr)
9403
		  != eventNotHandledErr)
9307
		break;
9404
		break;
Lines 9350-9359 Link Here
9350
		inev.kind = NON_ASCII_KEYSTROKE_EVENT;
9447
		inev.kind = NON_ASCII_KEYSTROKE_EVENT;
9351
	      }
9448
	      }
9352
	    else
9449
	    else
9353
	      {
9450
	      { 
9354
		if (er.modifiers & (controlKey |
9451
		if  (er.modifiers & (controlKey | 
9355
				    (NILP (Vmac_command_key_is_meta) ? optionKey
9452
				     (NILP (Vmac_pass_option_to_system) ? optionKey : 0) | 
9356
				     : cmdKey)))
9453
 				     (
9454
 				      (macOldModifierSetting ?  
9455
 				       (NILP (Vmac_command_key_is_meta) ? 
9456
 					optionKey : cmdKey
9457
 					) 
9458
 				       : cmdKey
9459
 				       )
9460
 				      )  
9461
 				     )
9462
 		     )
9357
		  {
9463
		  {
9358
		    /* This code comes from Keyboard Resource,
9464
		    /* This code comes from Keyboard Resource,
9359
		       Appendix C of IM - Text.  This is necessary
9465
		       Appendix C of IM - Text.  This is necessary
Lines 9361-9367 Link Here
9361
		       translation when option or command is pressed.
9467
		       translation when option or command is pressed.
9362
		       It also does not translate correctly
9468
		       It also does not translate correctly
9363
		       control-shift chars like C-% so mask off shift
9469
		       control-shift chars like C-% so mask off shift
9364
		       here also */
9470
		       here also.
9471
9472
		       For combinations with the option key (alt), this is only
9473
		       done if either command or control are used additionally,
9474
		       in which case this isn't handled 
9475
		       or if mac-pass-option-to-system is nil  -- in order
9476
		       to preserve key combinations translated by the OS, such as Alt-3.
9477
		    */
9365
		    int new_modifiers = er.modifiers & 0xe600;
9478
		    int new_modifiers = er.modifiers & 0xe600;
9366
		    /* mask off option and command */
9479
		    /* mask off option and command */
9367
		    int new_keycode = keycode | new_modifiers;
9480
		    int new_keycode = keycode | new_modifiers;
Lines 9370-9388 Link Here
9370
		    inev.code = KeyTranslate (kchr_ptr, new_keycode,
9483
		    inev.code = KeyTranslate (kchr_ptr, new_keycode,
9371
					      &some_state) & 0xff;
9484
					      &some_state) & 0xff;
9372
		  }
9485
		  }
9373
		else if (!NILP (Vmac_option_modifier)
9374
			 && (er.modifiers & optionKey))
9375
		  {
9376
		    /* When using the option key as an emacs modifier,
9377
		       convert the pressed key code back to one
9378
		       without the Mac option modifier applied. */
9379
		    int new_modifiers = er.modifiers & ~optionKey;
9380
		    int new_keycode = keycode | new_modifiers;
9381
		    Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
9382
		    unsigned long some_state = 0;
9383
		    inev.code = KeyTranslate (kchr_ptr, new_keycode,
9384
					      &some_state) & 0xff;
9385
		  }
9386
		else
9486
		else
9387
		  inev.code = er.message & charCodeMask;
9487
		  inev.code = er.message & charCodeMask;
9388
		inev.kind = ASCII_KEYSTROKE_EVENT;
9488
		inev.kind = ASCII_KEYSTROKE_EVENT;
Lines 10002-10007 Link Here
10002
#if TARGET_API_MAC_CARBON
10102
#if TARGET_API_MAC_CARBON
10003
  init_required_apple_events ();
10103
  init_required_apple_events ();
10004
10104
10105
  Qctrl = intern ("ctrl");
10106
  Fput (Qctrl, Qmodifier_value, make_number (ctrl_modifier));
10107
  Qmeta = intern ("meta");
10108
  Fput (Qmeta, Qmodifier_value, make_number (meta_modifier)); 
10005
#if USE_CARBON_EVENTS
10109
#if USE_CARBON_EVENTS
10006
#ifdef MAC_OSX
10110
#ifdef MAC_OSX
10007
  init_service_handler ();
10111
  init_service_handler ();
Lines 10052-10057 Link Here
10052
#ifdef MAC_OSX
10156
#ifdef MAC_OSX
10053
  Fprovide (intern ("mac-carbon"), Qnil);
10157
  Fprovide (intern ("mac-carbon"), Qnil);
10054
#endif
10158
#endif
10159
/* Deprecated variables to configure modifier key assignment.
10160
	Retained for backward-compatibility. */
10161
	
10055
10162
10056
  staticpro (&Qreverse);
10163
  staticpro (&Qreverse);
10057
  Qreverse = intern ("reverse");
10164
  Qreverse = intern ("reverse");
Lines 10078-10096 Link Here
10078
10185
10079
  DEFVAR_LISP ("mac-command-key-is-meta", &Vmac_command_key_is_meta,
10186
  DEFVAR_LISP ("mac-command-key-is-meta", &Vmac_command_key_is_meta,
10080
    doc: /* Non-nil means that the command key is used as the Emacs meta key.
10187
    doc: /* Non-nil means that the command key is used as the Emacs meta key.
10081
Otherwise the option key is used.  */);
10188
Otherwise the option key is used. This variable is DEPRECATED. 
10189
It is only in effect if all of the variables mac-*-modifier are nil. */);
10082
  Vmac_command_key_is_meta = Qt;
10190
  Vmac_command_key_is_meta = Qt;
10191
  
10192
  DEFVAR_LISP ("mac-reverse-ctrl-meta", &Vmac_reverse_ctrl_meta,
10193
    doc: /* Non-nil means that the control and meta keys are reversed.  This is
10194
useful for non-standard keyboard layouts. This variable is DEPRECATED. 
10195
Backwards-compatibility: It is only in effect if none of the variables 
10196
mac-{command|control|option}-modifier is non-nil. */);
10197
  Vmac_reverse_ctrl_meta = Qnil;
10198
10199
10200
/* Variables to configure modifier key assignment.  */
10201
	
10202
  DEFVAR_LISP ("mac-control-modifier", &Vmac_control_modifier,
10203
    doc: /* Modifier to use for the Mac control key.  The value can
10204
be alt, hyper, or super for the respective modifier.  If the value is
10205
nil then the key will act as the normal Mac control modifier.  
10206
Backwards-compatibility: If all values of 
10207
mac-{command|control|option}-modifier are nil, the deprecated
10208
default assignment determined by mac-command-key-is-meta and
10209
mac-reverse-ctrl-meta is used. */);
10210
  Vmac_control_modifier = Qnil;
10083
10211
10084
  DEFVAR_LISP ("mac-option-modifier", &Vmac_option_modifier,
10212
  DEFVAR_LISP ("mac-option-modifier", &Vmac_option_modifier,
10085
    doc: /* Modifier to use for the Mac alt/option key.  The value can
10213
    doc: /* Modifier to use for the Mac alt/option key.  The value can
10086
be alt, hyper, or super for the respective modifier.  If the value is
10214
be alt, hyper, or super for the respective modifier.  If the value is
10087
nil then the key will act as the normal Mac option modifier.  */);
10215
nil then the key will act as the normal Mac option modifier, and the option
10216
key can be used to compose characters depending on the chosen Mac keyboard
10217
setting. 
10218
Note that mac-pass-option-to-system takes precedence over this setting. If 
10219
mac-pass-option-to-system is non-nil, simple key combinations with Option
10220
will be handled by the system in order to produce characters, and only
10221
combinations in conjunction with Command or Control will let Emacs see
10222
the modifier that is assigned to the Option key. 
10223
Backwards-compatibility: If all values of 
10224
mac-{command|control|option}-modifier are nil, the deprecated default 
10225
assignment determined by mac-command-key-is-meta and
10226
mac-reverse-ctrl-meta is used.  */);
10088
  Vmac_option_modifier = Qnil;
10227
  Vmac_option_modifier = Qnil;
10089
10228
10090
  DEFVAR_LISP ("mac-reverse-ctrl-meta", &Vmac_reverse_ctrl_meta,
10229
  DEFVAR_LISP ("mac-command-modifier", &Vmac_command_modifier,
10091
    doc: /* Non-nil means that the control and meta keys are reversed.  This is
10230
    doc: /* Modifier to use for the Mac command key.  The value can
10092
useful for non-standard keyboard layouts.  */);
10231
be alt, hyper, or super for the respective modifier. If the value is
10093
  Vmac_reverse_ctrl_meta = Qnil;
10232
nil then the key will act as the Emacs 'hyper' modifier. 
10233
Backwards-compatibility: If all values of 
10234
mac-{command|control|option}-modifier are nil, the deprecated
10235
default assignment determined by mac-command-key-is-meta and
10236
mac-reverse-ctrl-meta is used.  */);
10237
  Vmac_command_modifier = Qnil;
10094
10238
10095
  DEFVAR_LISP ("mac-emulate-three-button-mouse",
10239
  DEFVAR_LISP ("mac-emulate-three-button-mouse",
10096
	       &Vmac_emulate_three_button_mouse,
10240
	       &Vmac_emulate_three_button_mouse,
Lines 10120-10125 Link Here
10120
Toolbox for processing before Emacs sees it.  */);
10264
Toolbox for processing before Emacs sees it.  */);
10121
  Vmac_pass_control_to_system = Qt;
10265
  Vmac_pass_control_to_system = Qt;
10122
10266
10267
  DEFVAR_LISP ("mac-pass-option-to-system", &Vmac_pass_option_to_system,
10268
   doc: /* If  non-nil, the Mac \"Option\" key can be used to compose
10269
      characters as handled by the system and depending on the
10270
      keyboard layout chosen. Only if the Mac \"Command\" or \"Ctrl\" key
10271
      is depressed at the same time, Emacs evaluates the combination using
10272
      whatever modifier is set in mac-option-modifier.  */);
10273
  Vmac_pass_option_to_system = Qt;
10274
10123
#endif
10275
#endif
10124
10276
10125
  DEFVAR_LISP ("mac-allow-anti-aliasing", &Vmac_use_core_graphics,
10277
  DEFVAR_LISP ("mac-allow-anti-aliasing", &Vmac_use_core_graphics,

Return to bug 103596