aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Blandy1992-09-30 11:57:51 +0000
committerJim Blandy1992-09-30 11:57:51 +0000
commit28430d3c3bba5ee29ea37a222062a0d639c7986c (patch)
treeb7fafc43baf641e43dd3bbc8afd615b29ea73752 /src
parenta5ca2b75400ef3026661de8f2e51f8b91c0e607e (diff)
downloademacs-28430d3c3bba5ee29ea37a222062a0d639c7986c.tar.gz
emacs-28430d3c3bba5ee29ea37a222062a0d639c7986c.zip
* xterm.c (x_meta_mod_mask): New variable, indicating which X
modifier bits denote meta keys. (x_find_modifier_meanings): New function, to set x_meta_mod_mask. (x_convert_modifiers): Use that. (x_term_init): Call x_find_modifier_meanings. * xterm.c (XTread_socket): Pass PropertyNotify events from the root window to x_invalidate_cut_buffer_cache. (x_term_init): Call x_watch_cut_buffer_cache here.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c95
1 files changed, 91 insertions, 4 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 956e784bf0f..3fd74453882 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1428,6 +1428,75 @@ pixel_to_glyph_coords (f, pix_x, pix_y, x, y, bounds)
1428/* Any buttons grabbed. */ 1428/* Any buttons grabbed. */
1429unsigned int x_mouse_grabbed; 1429unsigned int x_mouse_grabbed;
1430 1430
1431/* Which modifier keys are on which modifier bits?
1432
1433 With each keystroke, X returns eight bits indicating which modifier
1434 keys were held down when the key was pressed. The low three bits
1435 indicate the state of the shift, shift lock, caps lock, and control
1436 keys; their interpretation is fixed. However, the interpretation
1437 of the other five modifier bits depends on what keys are attached
1438 to them. If the Meta_L and Meta_R keysyms are on mod5, then mod5
1439 is the meta bit.
1440
1441 x_meta_mod_mask is a mask containing the bits used for the meta key.
1442 It may have more than one bit set, if more than one modifier bit
1443 has meta keys on it. Basically, if EVENT is a KeyPress event,
1444 the meta key is pressed if (EVENT.state & x_meta_mod_mask) != 0. */
1445static int x_meta_mod_mask;
1446
1447/* Initialize mode_switch_bit and modifier_meaning. */
1448static void
1449x_find_modifier_meanings ()
1450{
1451 KeyCode min_code, max_code;
1452 KeySym *syms;
1453 int syms_per_code;
1454 XModifierKeymap *mods;
1455
1456 x_meta_mod_mask = 0;
1457
1458 XDisplayKeycodes (x_current_display, &min_code, &max_code);
1459 syms = XGetKeyboardMapping (x_current_display,
1460 min_code, max_code - min_code + 1,
1461 &syms_per_code);
1462 mods = XGetModifierMapping (x_current_display);
1463
1464 /* If CapsLock is on the lock modifier, then only letters should be
1465 affected; since XLookupString takes care of this for us, the lock
1466 modifier shouldn't set shift_modifier. However, if ShiftLock is
1467 on the lock modifier, then lock should mean shift. */
1468 {
1469 int row, col; /* The row and column in the modifier table. */
1470
1471 for (row = 3; row < 8; row++)
1472 for (col = 0; col < mods->max_keypermod; col++)
1473 {
1474 KeyCode code =
1475 mods->modifiermap[(row * mods->max_keypermod) + col];
1476
1477 /* Are any of this keycode's keysyms a meta key? */
1478 {
1479 int code_col;
1480
1481 for (code_col = 0; code_col < syms_per_code; code_col++)
1482 {
1483 int sym = syms[(code * syms_per_code) + code_col];
1484
1485 if (sym == XK_Meta_L || sym == XK_Meta_R)
1486 {
1487 x_meta_mod_mask |= (1 << row);
1488 break;
1489 }
1490 }
1491 }
1492 }
1493 }
1494
1495 XFree ((char *) syms);
1496 XFreeModifierMap (mods);
1497}
1498
1499
1431/* Convert a set of X modifier bits to the proper form for a 1500/* Convert a set of X modifier bits to the proper form for a
1432 struct input_event modifiers value. */ 1501 struct input_event modifiers value. */
1433 1502
@@ -1437,7 +1506,7 @@ x_convert_modifiers (state)
1437{ 1506{
1438 return ( ((state & (ShiftMask | LockMask)) ? shift_modifier : 0) 1507 return ( ((state & (ShiftMask | LockMask)) ? shift_modifier : 0)
1439 | ((state & ControlMask) ? ctrl_modifier : 0) 1508 | ((state & ControlMask) ? ctrl_modifier : 0)
1440 | ((state & Mod1Mask) ? meta_modifier : 0)); 1509 | ((state & x_meta_mod_mask) ? meta_modifier : 0));
1441} 1510}
1442 1511
1443extern struct frame *x_window_to_scrollbar (); 1512extern struct frame *x_window_to_scrollbar ();
@@ -1802,9 +1871,20 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
1802 break; 1871 break;
1803 1872
1804 case PropertyNotify: 1873 case PropertyNotify:
1805 /* If we were to do this synchronously, there'd be no worry 1874
1806 about re-selecting. */ 1875 /* If we're being told about a root window property, then it's
1807 x_send_incremental (event); 1876 a cut buffer change. */
1877 if (event.xproperty.window == ROOT_WINDOW)
1878 x_invalidate_cut_buffer_cache (&event.xproperty);
1879
1880 /* Otherwise, we're probably handling an incremental
1881 selection transmission. */
1882 else
1883 {
1884 /* If we were to do this synchronously, there'd be no worry
1885 about re-selecting. */
1886 x_send_incremental (event);
1887 }
1808 break; 1888 break;
1809 1889
1810 case Expose: 1890 case Expose:
@@ -3665,7 +3745,14 @@ x_term_init (display_name)
3665 + 2); 3745 + 2);
3666 sprintf (x_id_name, "%s@%s", XSTRING (invocation_name)->data, hostname); 3746 sprintf (x_id_name, "%s@%s", XSTRING (invocation_name)->data, hostname);
3667 } 3747 }
3748
3749 /* Figure out which modifier bits mean what. */
3750 x_find_modifier_meanings ();
3668 3751
3752 /* Watch for PropertyNotify events on the root window; we use them
3753 to figure out when to invalidate our cache of the cut buffers. */
3754 x_watch_cut_buffer_cache ();
3755
3669 dup2 (ConnectionNumber (x_current_display), 0); 3756 dup2 (ConnectionNumber (x_current_display), 0);
3670 3757
3671#ifndef SYSV_STREAMS 3758#ifndef SYSV_STREAMS