* xterm.c (x_find_modifier_meanings): If there are no
authorJim Blandy <jimb@redhat.com>
Sat, 3 Oct 1992 05:10:14 +0000 (05:10 +0000)
committerJim Blandy <jimb@redhat.com>
Sat, 3 Oct 1992 05:10:14 +0000 (05:10 +0000)
modifiers containing a Meta_ keysym, use the Alt keysyms to
denote meta.
(construct_mouse_click): Set the down_modifier bit on mouse
button press events.
(XTread_socket): When processing keypress events, use
x_meta_mod_mask when processing ordinary ASCII characters, not
just when processing function keys and other non-ASCII events.
(XTread_socket): If we receive a MappingNotify event with the
`request' member set to `MappingModifier', then call
x_find_modifier_meanings to refresh x_meta_mod_mask.

src/xterm.c

index 3fd7445..be9f87b 100644 (file)
@@ -1448,10 +1448,11 @@ static int x_meta_mod_mask;
 static void
 x_find_modifier_meanings ()
 {
-  KeyCode min_code, max_code;
+  int min_code, max_code;
   KeySym *syms;
   int syms_per_code;
   XModifierKeymap *mods;
+  int alt_mod_mask = 0;
 
   x_meta_mod_mask = 0;
   
@@ -1480,20 +1481,31 @@ x_find_modifier_meanings ()
 
            for (code_col = 0; code_col < syms_per_code; code_col++)
              {
-               int sym = syms[(code * syms_per_code) + code_col];
+               int sym = syms[((code - min_code) * syms_per_code) + code_col];
 
-               if (sym == XK_Meta_L || sym == XK_Meta_R)
+               switch (sym)
                  {
+                 case XK_Meta_L:
+                 case XK_Meta_R:
                    x_meta_mod_mask |= (1 << row);
                    break;
+
+                 case XK_Alt_L:
+                 case XK_Alt_R:
+                   alt_mod_mask |= (1 << row);
+                   break;
                  }
              }
          }
        }
   }
 
+  /* If we couldn't find any meta keys, accept any alt keys as meta keys.  */
+  if (! x_meta_mod_mask)
+    x_meta_mod_mask = alt_mod_mask;
+
   XFree ((char *) syms);
-  XFreeModifierMap (mods);
+  XFreeModifiermap (mods);
 }
 
 
@@ -1535,7 +1547,9 @@ construct_mouse_click (result, event, f, part, prefix)
   XSET (result->code, Lisp_Int, event->button);
   result->timestamp = event->time;
   result->modifiers = (x_convert_modifiers (event->state)
-                      | (event->type == ButtonRelease ? up_modifier : 0));
+                      | (event->type == ButtonRelease
+                         ? up_modifier 
+                         : down_modifier));
 
   /* Notice if the mouse is still grabbed.  */
   if (event->type == ButtonPress)
@@ -2061,7 +2075,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
 
                      if (nbytes == 1)
                        {
-                         if (modifiers & Mod1Mask)
+                         if (modifiers & x_meta_mod_mask)
                            *copy_buffer |= METABIT;
                          bufp->kind = ascii_keystroke;
                          XSET (bufp->code, Lisp_Int, *copy_buffer);
@@ -2390,6 +2404,8 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
            /* Someone has changed the keyboard mapping - flush the
               local cache.  */
            XRefreshKeyboardMapping (&event.xmapping);
+         else if (event.xmapping.request == MappingModifier)
+           x_find_modifier_meanings ();
          break;
 
        default: