From 98659da6e93b143512b8a915506e0246fd2f880e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kai=20Gro=C3=9Fjohann?= Date: Fri, 15 Feb 2002 09:36:05 +0000 Subject: [PATCH] (Vx_alt_keysym, Vx_hyper_keysym, Vx_meta_keysym) (Vx_super_keysym): New variables. (syms_of_xterm): DEFVAR_LISP them. (x_x_to_emacs_modifiers, x_emacs_to_x_modifiers): Use the variables to determine which keys to use for the various modifiers. --- etc/NEWS | 8 +++++ src/ChangeLog | 11 +++++- src/alloc.c | 2 +- src/xterm.c | 99 +++++++++++++++++++++++++++++++++++++++++++++------ 4 files changed, 107 insertions(+), 13 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 06e6553a54b..8f60e988658 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -396,6 +396,14 @@ The new variable `w32-pass-extra-mouse-buttons-to-system' controls whether Emacs should handle the extra buttons itself (the default), or pass them to Windows to be handled with system-wide functions. +** Under X11, it is possible to swap Alt and Meta (and Super and Hyper). +The new variables `x-alt-keysym', `x-hyper-keysym', `x-meta-keysym', +and `x-super-keysym' can be used to choose which keysyms Emacs should +use for the modifiers. For example, the following two lines swap +Meta and Alt: + (setq x-alt-keysym 'meta) + (setq x-meta-keysym 'alt) + --- ** A French translation of the `Emacs Survival Guide' is available. diff --git a/src/ChangeLog b/src/ChangeLog index 98891632cb9..26cc2b8d1c4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2002-02-15 Kai Gro,A_(Bjohann + + * xterm.c (Vx_alt_keysym, Vx_hyper_keysym, Vx_meta_keysym) + (Vx_super_keysym): New variables. + (syms_of_xterm): DEFVAR_LISP them. + (x_x_to_emacs_modifiers, x_emacs_to_x_modifiers): Use the + variables to determine which keys to use for the various + modifiers. + 2002-02-13 Kim F. Storm * window.c: (Vmode_line_in_non_selected_windows): Removed. @@ -94,7 +103,7 @@ * floatfns.c (Fround): Doc fix. -2002-02-08 Pavel Jan,Bm(Bk +2002-02-08 Pavel Jan,Am(Bk * sysdep.c (init_system_name): Put unused variable `p' in #if 0. diff --git a/src/alloc.c b/src/alloc.c index 0ab1820e83a..d83a6bbf2ee 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -396,7 +396,7 @@ struct gcpro *gcprolist; /* Addresses of staticpro'd variables. */ -#define NSTATICS 1024 +#define NSTATICS 1026 Lisp_Object *staticvec[NSTATICS] = {0}; /* Index of next unused slot in staticvec. */ diff --git a/src/xterm.c b/src/xterm.c index 6f53a8ed848..e6382539c3a 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -381,6 +381,11 @@ extern int errno; extern int extra_keyboard_modifiers; +/* The keysyms to use for the various modifiers. */ + +Lisp_Object Vx_alt_keysym, Vx_hyper_keysym, Vx_meta_keysym, Vx_super_keysym; +static Lisp_Object Qalt, Qhyper, Qmeta, Qsuper, Qmodifier_value; + static Lisp_Object Qvendor_specific_keysyms; extern XrmDatabase x_load_resources P_ ((Display *, char *, char *, char *)); @@ -6422,12 +6427,28 @@ x_x_to_emacs_modifiers (dpyinfo, state) struct x_display_info *dpyinfo; unsigned int state; { + EMACS_UINT mod_meta = meta_modifier; + EMACS_UINT mod_alt = alt_modifier; + EMACS_UINT mod_hyper = hyper_modifier; + EMACS_UINT mod_super = super_modifier; + Lisp_Object tem; + + tem = Fget (Vx_alt_keysym, Qmodifier_value); + if (! EQ (tem, Qnil)) mod_alt = XUINT (tem); + tem = Fget (Vx_meta_keysym, Qmodifier_value); + if (! EQ (tem, Qnil)) mod_meta = XUINT (tem); + tem = Fget (Vx_hyper_keysym, Qmodifier_value); + if (! EQ (tem, Qnil)) mod_hyper = XUINT (tem); + tem = Fget (Vx_super_keysym, Qmodifier_value); + if (! EQ (tem, Qnil)) mod_super = XUINT (tem); + + return ( ((state & (ShiftMask | dpyinfo->shift_lock_mask)) ? shift_modifier : 0) - | ((state & ControlMask) ? ctrl_modifier : 0) - | ((state & dpyinfo->meta_mod_mask) ? meta_modifier : 0) - | ((state & dpyinfo->alt_mod_mask) ? alt_modifier : 0) - | ((state & dpyinfo->super_mod_mask) ? super_modifier : 0) - | ((state & dpyinfo->hyper_mod_mask) ? hyper_modifier : 0)); + | ((state & ControlMask) ? ctrl_modifier : 0) + | ((state & dpyinfo->meta_mod_mask) ? mod_meta : 0) + | ((state & dpyinfo->alt_mod_mask) ? mod_alt : 0) + | ((state & dpyinfo->super_mod_mask) ? mod_super : 0) + | ((state & dpyinfo->hyper_mod_mask) ? mod_hyper : 0)); } static unsigned int @@ -6435,12 +6456,29 @@ x_emacs_to_x_modifiers (dpyinfo, state) struct x_display_info *dpyinfo; unsigned int state; { - return ( ((state & alt_modifier) ? dpyinfo->alt_mod_mask : 0) - | ((state & super_modifier) ? dpyinfo->super_mod_mask : 0) - | ((state & hyper_modifier) ? dpyinfo->hyper_mod_mask : 0) - | ((state & shift_modifier) ? ShiftMask : 0) - | ((state & ctrl_modifier) ? ControlMask : 0) - | ((state & meta_modifier) ? dpyinfo->meta_mod_mask : 0)); + EMACS_UINT mod_meta = meta_modifier; + EMACS_UINT mod_alt = alt_modifier; + EMACS_UINT mod_hyper = hyper_modifier; + EMACS_UINT mod_super = super_modifier; + + Lisp_Object tem; + + tem = Fget (Vx_alt_keysym, Qmodifier_value); + if (! EQ (tem, Qnil)) mod_alt = XUINT (tem); + tem = Fget (Vx_meta_keysym, Qmodifier_value); + if (! EQ (tem, Qnil)) mod_meta = XUINT (tem); + tem = Fget (Vx_hyper_keysym, Qmodifier_value); + if (! EQ (tem, Qnil)) mod_hyper = XUINT (tem); + tem = Fget (Vx_super_keysym, Qmodifier_value); + if (! EQ (tem, Qnil)) mod_super = XUINT (tem); + + + return ( ((state & mod_alt) ? dpyinfo->alt_mod_mask : 0) + | ((state & mod_super) ? dpyinfo->super_mod_mask : 0) + | ((state & mod_hyper) ? dpyinfo->hyper_mod_mask : 0) + | ((state & shift_modifier) ? ShiftMask : 0) + | ((state & ctrl_modifier) ? ControlMask : 0) + | ((state & mod_meta) ? dpyinfo->meta_mod_mask : 0)); } /* Convert a keysym to its name. */ @@ -15035,6 +15073,45 @@ Otherwise, value is a symbol describing the X toolkit. */); staticpro (&last_mouse_motion_frame); last_mouse_motion_frame = Qnil; + + Qmodifier_value = intern ("modifier-value"); + Qalt = intern ("alt"); + Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); + Qhyper = intern ("hyper"); + Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier)); + Qmeta = intern ("meta"); + Fput (Qmeta, Qmodifier_value, make_number (meta_modifier)); + Qsuper = intern ("super"); + Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); + + DEFVAR_LISP ("x-alt-keysym", &Vx_alt_keysym, + doc: /* Which keys Emacs uses for the alt modifier. +This should be one of the symbols `alt', `hyper', `meta', `super'. +For example, `alt' means use the Alt_L and Alt_R keysyms. The default +is nil, which is the same as `alt'. */); + Vx_alt_keysym = Qnil; + + DEFVAR_LISP ("x-hyper-keysym", &Vx_hyper_keysym, + doc: /* Which keys Emacs uses for the hyper modifier. +This should be one of the symbols `alt', `hyper', `meta', `super'. +For example, `hyper' means use the Hyper_L and Hyper_R keysyms. The +default is nil, which is the same as `hyper'. */); + Vx_hyper_keysym = Qnil; + + DEFVAR_LISP ("x-meta-keysym", &Vx_meta_keysym, + doc: /* Which keys Emacs uses for the meta modifier. +This should be one of the symbols `alt', `hyper', `meta', `super'. +For example, `meta' means use the Meta_L and Meta_R keysyms. The +default is nil, which is the same as `meta'. */); + Vx_meta_keysym = Qnil; + + DEFVAR_LISP ("x-super-keysym", &Vx_super_keysym, + doc: /* Which keys Emacs uses for the super modifier. +This should be one of the symbols `alt', `hyper', `meta', `super'. +For example, `super' means use the Super_L and Super_R keysyms. The +default is nil, which is the same as `super'. */); + Vx_super_keysym = Qnil; + } #endif /* HAVE_X_WINDOWS */ -- 2.39.2