ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/keyboard.C
(Generate patch)

Comparing rxvt-unicode/src/keyboard.C (file contents):
Revision 1.12 by root, Sat Feb 12 18:55:04 2005 UTC vs.
Revision 1.15 by root, Sun Apr 17 22:36:13 2005 UTC

5 5
6#include <cstring> 6#include <cstring>
7 7
8#include "keyboard.h" 8#include "keyboard.h"
9#include "command.h" 9#include "command.h"
10
11/* an intro to the data structure:
12 *
13 * vector keymap[] is grouped.
14 *
15 * inside each group, elements are sorted by the criteria given by compare_priority().
16 * the lookup of keysym is done in two steps:
17 * 1) locate the group corresponds to the keysym;
18 * 2) do a linear search inside the group.
19 *
20 * array hash[] effectively defines a map from a keysym to a group in keymap[].
21 *
22 * each group has its address(the index of first group element in keymap[]),
23 * which is computed and stored in hash[].
24 * hash[] stores the addresses in the form of:
25 * index: 0 I1 I2 I3 In
26 * value: 0...0, A1...A1, A2...A2, A3...A3, ..., An...An
27 * where
28 * A1 = 0;
29 * Ai+1 = N1 + N2 + ... + Ni.
30 * it is computed from hash_budget_size[]:
31 * index: 0 I1 I2 I3 In
32 * value: 0...0, N1, 0...0, N2, 0...0, N3, ..., Nn, 0...0
33 * 0...0, 0.......0, N1.....N1, N1+N2...N1+N2, ... (the compution of hash[])
34 * or we can say
35 * hash_budget_size[Ii] = Ni; hash_budget_size[elsewhere] = 0,
36 * where
37 * set {I1, I2, ..., In} = { hashkey of keymap[0]->keysym, ..., keymap[keymap.size-1]->keysym }
38 * where hashkey of keymap[i]->keysym = keymap[i]->keysym & KEYSYM_HASH_MASK
39 * n(the number of groups) = the number of non-zero member of hash_budget_size[];
40 * Ni(the size of group i) = hash_budget_size[Ii].
41 */
10 42
11#if STOCK_KEYMAP 43#if STOCK_KEYMAP
12//////////////////////////////////////////////////////////////////////////////// 44////////////////////////////////////////////////////////////////////////////////
13// default keycode translation map and keyevent handlers 45// default keycode translation map and keyevent handlers
14 46
228bool 260bool
229keyboard_manager::dispatch (rxvt_term *term, KeySym keysym, unsigned int state) 261keyboard_manager::dispatch (rxvt_term *term, KeySym keysym, unsigned int state)
230{ 262{
231 assert (hash[0] == 0 && "register_done() need to be called"); 263 assert (hash[0] == 0 && "register_done() need to be called");
232 264
265 state &= OtherModMask; // mask out uninteresting modifiers
266
233 if (state & term->ModMetaMask) state |= MetaMask; 267 if (state & term->ModMetaMask) state |= MetaMask;
234 if (state & term->ModNumLockMask) state |= NumLockMask; 268 if (state & term->ModNumLockMask) state |= NumLockMask;
235 if (state & term->ModLevel3Mask) state |= Level3Mask; 269 if (state & term->ModLevel3Mask) state |= Level3Mask;
236 270
237 if (!!(term->priv_modes & PrivMode_aplKP) != !!(state & ShiftMask)) 271 if (!!(term->priv_modes & PrivMode_aplKP) != !!(state & ShiftMask))
425 for (; index < end; ++index) 459 for (; index < end; ++index)
426 { 460 {
427 keysym_t *key = keymap [index]; 461 keysym_t *key = keymap [index];
428 462
429 if (key->keysym <= keysym && keysym < key->keysym + key->range 463 if (key->keysym <= keysym && keysym < key->keysym + key->range
464#if 0 // disabled because the custom ekymap does not know the builtin keymap
430 // match only the specified bits in state and ignore others 465 // match only the specified bits in state and ignore others
431 && (key->state & state) == key->state) 466 && (key->state & state) == key->state
467#else // re-enable this part once the builtin keymap is handled here, too
468 && key->state == state
469#endif
470 )
432 return index; 471 return index;
433 } 472 }
434 473
435 return -1; 474 return -1;
436} 475}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines