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.7 by root, Sun Jan 16 23:55:42 2005 UTC vs.
Revision 1.22 by root, Mon Jan 9 22:41:41 2006 UTC

3 3
4#ifdef KEYSYM_RESOURCE 4#ifdef KEYSYM_RESOURCE
5 5
6#include <cstring> 6#include <cstring>
7 7
8#include "rxvtperl.h"
8#include "keyboard.h" 9#include "keyboard.h"
9#include "command.h" 10#include "command.h"
10 11
12/* an intro to the data structure:
13 *
14 * vector keymap[] is grouped.
15 *
16 * inside each group, elements are sorted by the criteria given by compare_priority().
17 * the lookup of keysym is done in two steps:
18 * 1) locate the group corresponds to the keysym;
19 * 2) do a linear search inside the group.
20 *
21 * array hash[] effectively defines a map from a keysym to a group in keymap[].
22 *
23 * each group has its address(the index of first group element in keymap[]),
24 * which is computed and stored in hash[].
25 * hash[] stores the addresses in the form of:
26 * index: 0 I1 I2 I3 In
27 * value: 0...0, A1...A1, A2...A2, A3...A3, ..., An...An
28 * where
29 * A1 = 0;
30 * Ai+1 = N1 + N2 + ... + Ni.
31 * it is computed from hash_budget_size[]:
32 * index: 0 I1 I2 I3 In
33 * value: 0...0, N1, 0...0, N2, 0...0, N3, ..., Nn, 0...0
34 * 0...0, 0.......0, N1.....N1, N1+N2...N1+N2, ... (the compution of hash[])
35 * or we can say
36 * hash_budget_size[Ii] = Ni; hash_budget_size[elsewhere] = 0,
37 * where
38 * set {I1, I2, ..., In} = { hashkey of keymap[0]->keysym, ..., keymap[keymap.size-1]->keysym }
39 * where hashkey of keymap[i]->keysym = keymap[i]->keysym & KEYSYM_HASH_MASK
40 * n(the number of groups) = the number of non-zero member of hash_budget_size[];
41 * Ni(the size of group i) = hash_budget_size[Ii].
42 */
43
44#if STOCK_KEYMAP
11//////////////////////////////////////////////////////////////////////////////// 45////////////////////////////////////////////////////////////////////////////////
12// default keycode translation map and keyevent handlers 46// default keycode translation map and keyevent handlers
13 47
14keysym_t keyboard_manager::stock_keymap[] = { 48keysym_t keyboard_manager::stock_keymap[] = {
15 /* examples */ 49 /* examples */
16 /* keysym, state, range, handler, str */ 50 /* keysym, state, range, handler, str */
17//{XK_ISO_Left_Tab, 0, 1, NORMAL, "\033[Z"}, 51//{XK_ISO_Left_Tab, 0, 1, keysym_t::STRING, "\033[Z"},
18//{ 'a', 0, 26, RANGE_META8, "a" "%c"}, 52//{ 'a', 0, 26, keysym_t::RANGE_META8, "a" "%c"},
19//{ 'a', ControlMask, 26, RANGE_META8, "" "%c"}, 53//{ 'a', ControlMask, 26, keysym_t::RANGE_META8, "" "%c"},
20//{ XK_Left, 0, 4, LIST, "DACBZ" "\033[Z"}, 54//{ XK_Left, 0, 4, keysym_t::LIST, ".\033[.DACB."},
21//{ XK_Left, ShiftMask, 4, LIST, "dacbZ" "\033[Z"}, 55//{ XK_Left, ShiftMask, 4, keysym_t::LIST, ".\033[.dacb."},
22//{ XK_Left, ControlMask, 4, LIST, "dacbZ" "\033OZ"}, 56//{ XK_Left, ControlMask, 4, keysym_t::LIST, ".\033O.dacb."},
23//{ XK_Tab, ControlMask, 1, NORMAL, "\033<C-Tab>"}, 57//{ XK_Tab, ControlMask, 1, keysym_t::STRING, "\033<C-Tab>"},
24//{ XK_apostrophe, ControlMask, 1, NORMAL, "\033<C-'>"}, 58//{ XK_apostrophe, ControlMask, 1, keysym_t::STRING, "\033<C-'>"},
25//{ XK_slash, ControlMask, 1, NORMAL, "\033<C-/>"}, 59//{ XK_slash, ControlMask, 1, keysym_t::STRING, "\033<C-/>"},
26//{ XK_semicolon, ControlMask, 1, NORMAL, "\033<C-;>"}, 60//{ XK_semicolon, ControlMask, 1, keysym_t::STRING, "\033<C-;>"},
27//{ XK_grave, ControlMask, 1, NORMAL, "\033<C-`>"}, 61//{ XK_grave, ControlMask, 1, keysym_t::STRING, "\033<C-`>"},
28//{ XK_comma, ControlMask, 1, NORMAL, "\033<C-\054>"}, 62//{ XK_comma, ControlMask, 1, keysym_t::STRING, "\033<C-\054>"},
29//{ XK_Return, ControlMask, 1, NORMAL, "\033<C-Return>"}, 63//{ XK_Return, ControlMask, 1, keysym_t::STRING, "\033<C-Return>"},
30//{ XK_Return, ShiftMask, 1, NORMAL, "\033<S-Return>"}, 64//{ XK_Return, ShiftMask, 1, keysym_t::STRING, "\033<S-Return>"},
31//{ ' ', ShiftMask, 1, NORMAL, "\033<S-Space>"}, 65//{ ' ', ShiftMask, 1, keysym_t::STRING, "\033<S-Space>"},
32//{ '.', ControlMask, 1, NORMAL, "\033<C-.>"}, 66//{ '.', ControlMask, 1, keysym_t::STRING, "\033<C-.>"},
33//{ '0', ControlMask, 10, RANGE, "0" "\033<C-%c>"}, 67//{ '0', ControlMask, 10, keysym_t::RANGE, "0" "\033<C-%c>"},
34//{ '0', MetaMask|ControlMask, 10, RANGE, "0" "\033<M-C-%c>"}, 68//{ '0', MetaMask|ControlMask, 10, keysym_t::RANGE, "0" "\033<M-C-%c>"},
35//{ 'a', MetaMask|ControlMask, 26, RANGE, "a" "\033<M-C-%c>"}, 69//{ 'a', MetaMask|ControlMask, 26, keysym_t::RANGE, "a" "\033<M-C-%c>"},
36}; 70};
71#endif
37 72
38static void 73static void
39output_string (rxvt_term *rt, const char *str) 74output_string (rxvt_term *rt, const char *str)
40{ 75{
41 assert (rt && str); 76 if (strncmp (str, "command:", 8) == 0)
42 77 rt->cmd_write (str + 8, strlen (str) - 8);
43 if (strncmp (str, "proto:", 6) == 0) 78 else if (strncmp (str, "perl:", 5) == 0)
44 rt->cmd_write ((unsigned char *)str + 6, strlen (str) - 6); 79 HOOK_INVOKE((rt, HOOK_KEYBOARD_COMMAND, DT_STR, str + 5, DT_END));
45 else 80 else
46 rt->tt_write ((unsigned char *)str, strlen (str)); 81 rt->tt_write (str, strlen (str));
47} 82}
48 83
49static void 84static void
50output_string_meta8 (rxvt_term *rt, unsigned int state, char *buf, int buflen) 85output_string_meta8 (rxvt_term *rt, unsigned int state, char *buf, int buflen)
51{ 86{
58 *ch |= 0x80; 93 *ch |= 0x80;
59 } 94 }
60 else if (rt->meta_char == C0_ESC) /* escape prefix */ 95 else if (rt->meta_char == C0_ESC) /* escape prefix */
61#endif 96#endif
62 { 97 {
63 const unsigned char ch = C0_ESC; 98 const char ch = C0_ESC;
64 rt->tt_write (&ch, 1); 99 rt->tt_write (&ch, 1);
65 } 100 }
66 } 101 }
67 102
68 rt->tt_write ((unsigned char *) buf, buflen); 103 rt->tt_write (buf, buflen);
69} 104}
70 105
71static int 106static int
72format_keyrange_string (const char *str, int keysym_offset, char *buf, int bufsize) 107format_keyrange_string (const char *str, int keysym_offset, char *buf, int bufsize)
73{ 108{
83} 118}
84 119
85//////////////////////////////////////////////////////////////////////////////// 120////////////////////////////////////////////////////////////////////////////////
86// return: #bits of '1' 121// return: #bits of '1'
87#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3) 122#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)
88# define bitcount(n) (__extension__ ({ uint32_t n__ = (n); __builtin_popcount (n); })) 123# define bitcount(n) (__extension__ ({ uint32_t n__ = (n); __builtin_popcount (n__); }))
89#else 124#else
90static int 125static int
91bitcount (uint16_t n) 126bitcount (uint16_t n)
92{ 127{
93 int i; 128 int i;
101 136
102// return: priority_of_a - priority_of_b 137// return: priority_of_a - priority_of_b
103static int 138static int
104compare_priority (keysym_t *a, keysym_t *b) 139compare_priority (keysym_t *a, keysym_t *b)
105{ 140{
106 assert (a && b);
107
108 // (the more '1's in state; the less range): the greater priority 141 // (the more '1's in state; the less range): the greater priority
109 int ca = bitcount (a->state /* & OtherModMask */); 142 int ca = bitcount (a->state /* & OtherModMask */);
110 int cb = bitcount (b->state /* & OtherModMask */); 143 int cb = bitcount (b->state /* & OtherModMask */);
111 144
112 if (ca != cb) 145 if (ca != cb)
157// the string 'trans' is copied to an internal managed buffer, 190// the string 'trans' is copied to an internal managed buffer,
158// so the caller can free memory of 'trans' at any time. 191// so the caller can free memory of 'trans' at any time.
159void 192void
160keyboard_manager::register_user_translation (KeySym keysym, unsigned int state, const char *trans) 193keyboard_manager::register_user_translation (KeySym keysym, unsigned int state, const char *trans)
161{ 194{
162 assert (trans);
163
164 keysym_t *key = new keysym_t; 195 keysym_t *key = new keysym_t;
165 wchar_t *wc = rxvt_mbstowcs (trans); 196 wchar_t *wc = rxvt_mbstowcs (trans);
166printf ("CONV <%s> %x %x %x %x\n", trans, (int)wc[0], (int)wc[1], (int)wc[2], (int)wc[3]);
167 const char *translation = rxvt_wcstoutf8 (wc); 197 char *translation = rxvt_wcstoutf8 (wc);
168 free (wc); 198 free (wc);
169 199
170 if (key && translation) 200 if (key && translation)
171 { 201 {
172 key->keysym = keysym; 202 key->keysym = keysym;
173 key->state = state; 203 key->state = state;
174 key->range = 1; 204 key->range = 1;
175 key->str = translation; 205 key->str = translation;
176 key->type = keysym_t::NORMAL; 206 key->type = keysym_t::STRING;
177 207
178 if (strncmp (translation, "list", 4) == 0 && translation [4]) 208 if (strncmp (translation, "list", 4) == 0 && translation [4])
179 { 209 {
180 char *middle = strchr (translation + 5, translation [4]); 210 char *middle = strchr (translation + 5, translation [4]);
181 char *suffix = strrchr (translation + 5, translation [4]); 211 char *suffix = strrchr (translation + 5, translation [4]);
188 strcpy (translation, translation + 4); 218 strcpy (translation, translation + 4);
189 } 219 }
190 else 220 else
191 rxvt_warn ("cannot parse list-type keysym '%s', treating as normal keysym.\n", translation); 221 rxvt_warn ("cannot parse list-type keysym '%s', treating as normal keysym.\n", translation);
192 } 222 }
223 else if (strncmp (translation, "builtin:", 8) == 0)
224 key->type = keysym_t::BUILTIN;
193 225
194 user_keymap.push_back (key); 226 user_keymap.push_back (key);
195 user_translations.push_back (translation); 227 user_translations.push_back (translation);
196 register_keymap (key); 228 register_keymap (key);
197 } 229 }
204} 236}
205 237
206void 238void
207keyboard_manager::register_keymap (keysym_t *key) 239keyboard_manager::register_keymap (keysym_t *key)
208{ 240{
209 assert (key);
210 assert (key->range >= 1);
211
212 if (keymap.size () == keymap.capacity ()) 241 if (keymap.size () == keymap.capacity ())
213 keymap.reserve (keymap.size () * 2); 242 keymap.reserve (keymap.size () * 2);
214 243
215 keymap.push_back (key); 244 keymap.push_back (key);
216 hash[0] = 3; 245 hash[0] = 3;
217} 246}
218 247
219void 248void
220keyboard_manager::register_done () 249keyboard_manager::register_done ()
221{ 250{
251#if STOCK_KEYMAP
222 unsigned int i, n = sizeof (stock_keymap) / sizeof (keysym_t); 252 int n = sizeof (stock_keymap) / sizeof (keysym_t);
223 253
254 //TODO: shield against repeated calls and empty keymap
224 if (keymap.back () != &stock_keymap[n - 1]) 255 //if (keymap.back () != &stock_keymap[n - 1])
225 for (i = 0; i < n; ++i) 256 for (int i = 0; i < n; ++i)
226 register_keymap (&stock_keymap[i]); 257 register_keymap (&stock_keymap[i]);
258#endif
227 259
228 purge_duplicate_keymap (); 260 purge_duplicate_keymap ();
229 261
230 setup_hash (); 262 setup_hash ();
231} 263}
232 264
233bool 265bool
234keyboard_manager::dispatch (rxvt_term *term, KeySym keysym, unsigned int state) 266keyboard_manager::dispatch (rxvt_term *term, KeySym keysym, unsigned int state)
235{ 267{
236 assert (hash[0] == 0 && "register_done() need to be called"); 268 assert (hash[0] == 0 && "register_done() need to be called");
269
270 state &= OtherModMask; // mask out uninteresting modifiers
237 271
238 if (state & term->ModMetaMask) state |= MetaMask; 272 if (state & term->ModMetaMask) state |= MetaMask;
239 if (state & term->ModNumLockMask) state |= NumLockMask; 273 if (state & term->ModNumLockMask) state |= NumLockMask;
240 if (state & term->ModLevel3Mask) state |= Level3Mask; 274 if (state & term->ModLevel3Mask) state |= Level3Mask;
241 275
246 280
247 if (index >= 0) 281 if (index >= 0)
248 { 282 {
249 const keysym_t &key = *keymap [index]; 283 const keysym_t &key = *keymap [index];
250 284
285 if (key.type != keysym_t::BUILTIN)
286 {
251 int keysym_offset = keysym - key.keysym; 287 int keysym_offset = keysym - key.keysym;
252 288
253 wchar_t *wc = rxvt_utf8towcs (key.str); 289 wchar_t *wc = rxvt_utf8towcs (key.str);
254
255 char *str = rxvt_wcstombs (wc); 290 char *str = rxvt_wcstombs (wc);
256 // TODO: do translations, unescaping etc, here (allow \u escape etc.) 291 // TODO: do (some) translations, unescaping etc, here (allow \u escape etc.)
257 free (wc); 292 free (wc);
258 293
259 switch (key.type) 294 switch (key.type)
260 {
261 case keysym_t::NORMAL:
262 output_string (term, str);
263 break;
264
265 case keysym_t::RANGE:
266 { 295 {
296 case keysym_t::STRING:
297 output_string (term, str);
298 break;
299
300 case keysym_t::RANGE:
301 {
267 char buf[STRING_MAX]; 302 char buf[STRING_MAX];
268 303
269 if (format_keyrange_string (str, keysym_offset, buf, sizeof (buf)) > 0) 304 if (format_keyrange_string (str, keysym_offset, buf, sizeof (buf)) > 0)
305 output_string (term, buf);
306 }
307 break;
308
309 case keysym_t::RANGE_META8:
310 {
311 int len;
312 char buf[STRING_MAX];
313
314 len = format_keyrange_string (str, keysym_offset, buf, sizeof (buf));
315 if (len > 0)
316 output_string_meta8 (term, state, buf, len);
317 }
318 break;
319
320 case keysym_t::LIST:
321 {
322 char buf[STRING_MAX];
323
324 char *prefix, *middle, *suffix;
325
326 prefix = str;
327 middle = strchr (prefix + 1, *prefix);
328 suffix = strrchr (middle + 1, *prefix);
329
330 memcpy (buf, prefix + 1, middle - prefix - 1);
331 buf [middle - prefix - 1] = middle [keysym_offset + 1];
332 strcpy (buf + (middle - prefix), suffix + 1);
333
270 output_string (term, buf); 334 output_string (term, buf);
335 }
336 break;
271 } 337 }
272 break;
273 338
274 case keysym_t::RANGE_META8:
275 {
276 int len;
277 char buf[STRING_MAX];
278
279 len = format_keyrange_string (str, keysym_offset, buf, sizeof (buf));
280 if (len > 0)
281 output_string_meta8 (term, state, buf, len);
282 }
283 break;
284
285 case keysym_t::LIST:
286 {
287 char buf[STRING_MAX];
288
289 char *prefix, *middle, *suffix;
290
291 prefix = str;
292 middle = strchr (prefix + 1, *prefix);
293 suffix = strrchr (middle + 1, *prefix);
294
295 memcpy (buf, prefix + 1, middle - prefix - 1);
296 buf [middle - prefix - 1] = middle [keysym_offset + 1];
297 strcpy (buf + (middle - prefix), suffix + 1);
298
299 output_string (term, buf);
300 }
301 break;
302 }
303
304 free (str); 339 free (str);
305 340
306 return true; 341 return true;
307 } 342 }
308 else
309 { 343 }
310 // fprintf(stderr,"[%x:%x]",state,keysym); 344
311 return false; 345 return false;
312 }
313} 346}
314 347
315// purge duplicate keymap entries 348// purge duplicate keymap entries
316void keyboard_manager::purge_duplicate_keymap () 349void keyboard_manager::purge_duplicate_keymap ()
317{ 350{
327 if (i < keymap.size ()) 360 if (i < keymap.size ())
328 { 361 {
329 keymap[i] = keymap.back (); 362 keymap[i] = keymap.back ();
330 keymap.pop_back (); 363 keymap.pop_back ();
331 } 364 }
365
332 break; 366 break;
333 } 367 }
334 } 368 }
335 } 369 }
336} 370}
344 uint16_t hash_budget_counter[KEYSYM_HASH_BUDGETS]; // #elements in each budget 378 uint16_t hash_budget_counter[KEYSYM_HASH_BUDGETS]; // #elements in each budget
345 379
346 memset (hash_budget_size, 0, sizeof (hash_budget_size)); 380 memset (hash_budget_size, 0, sizeof (hash_budget_size));
347 memset (hash_budget_counter, 0, sizeof (hash_budget_counter)); 381 memset (hash_budget_counter, 0, sizeof (hash_budget_counter));
348 382
349 // count keysyms for corresponding hash budgets 383 // determine hash bucket size
350 for (i = 0; i < keymap.size (); ++i) 384 for (i = 0; i < keymap.size (); ++i)
385 for (int j = min (keymap [i]->range, KEYSYM_HASH_BUDGETS) - 1; j >= 0; --j)
351 { 386 {
352 assert (keymap [i]);
353 hashkey = (keymap [i]->keysym & KEYSYM_HASH_MASK); 387 hashkey = (keymap [i]->keysym + j) & KEYSYM_HASH_MASK;
354 ++hash_budget_size [hashkey]; 388 ++hash_budget_size [hashkey];
355 }
356
357 // keysym A with range>1 is counted one more time for
358 // every keysym B lies in its range
359 for (i = 0; i < keymap.size (); ++i)
360 {
361 if (keymap[i]->range > 1)
362 {
363 for (int j = min (keymap [i]->range, KEYSYM_HASH_BUDGETS) - 1; j > 0; --j)
364 {
365 hashkey = ((keymap [i]->keysym + j) & KEYSYM_HASH_MASK);
366 if (hash_budget_size [hashkey])
367 ++hash_budget_size [hashkey];
368 }
369 } 389 }
370 }
371 390
372 // now we know the size of each budget 391 // now we know the size of each budget
373 // compute the index of each budget 392 // compute the index of each budget
374 hash [0] = 0; 393 hash [0] = 0;
375 for (index = 0, i = 1; i < KEYSYM_HASH_BUDGETS; ++i) 394 for (index = 0, i = 1; i < KEYSYM_HASH_BUDGETS; ++i)
376 { 395 {
377 index += hash_budget_size [i - 1]; 396 index += hash_budget_size [i - 1];
378 hash[i] = (hash_budget_size [i] ? index : hash [i - 1]); 397 hash [i] = index;
379 } 398 }
380 399
381 // and allocate just enough space 400 // and allocate just enough space
382 //sorted_keymap.reserve (hash[i - 1] + hash_budget_size[i - 1]);
383 sorted_keymap.insert (sorted_keymap.begin (), index + hash_budget_size [i - 1], 0); 401 sorted_keymap.insert (sorted_keymap.begin (), index + hash_budget_size [i - 1], 0);
384 402
385 // fill in sorted_keymap 403 // fill in sorted_keymap
386 // it is sorted in each budget 404 // it is sorted in each budget
387 for (i = 0; i < keymap.size (); ++i) 405 for (i = 0; i < keymap.size (); ++i)
388 {
389 for (int j = min (keymap [i]->range, KEYSYM_HASH_BUDGETS) - 1; j >= 0; --j) 406 for (int j = min (keymap [i]->range, KEYSYM_HASH_BUDGETS) - 1; j >= 0; --j)
390 { 407 {
391 hashkey = ((keymap [i]->keysym + j) & KEYSYM_HASH_MASK); 408 hashkey = (keymap [i]->keysym + j) & KEYSYM_HASH_MASK;
392 409
393 if (hash_budget_size [hashkey])
394 {
395 index = hash [hashkey] + hash_budget_counter [hashkey]; 410 index = hash [hashkey] + hash_budget_counter [hashkey];
396 411
397 while (index > hash [hashkey] 412 while (index > hash [hashkey]
398 && compare_priority (keymap [i], sorted_keymap [index - 1]) > 0) 413 && compare_priority (keymap [i], sorted_keymap [index - 1]) > 0)
399 { 414 {
400 sorted_keymap [index] = sorted_keymap [index - 1]; 415 sorted_keymap [index] = sorted_keymap [index - 1];
401 --index; 416 --index;
402 } 417 }
403 418
404 sorted_keymap [index] = keymap [i]; 419 sorted_keymap [index] = keymap [i];
405 ++hash_budget_counter [hashkey]; 420 ++hash_budget_counter [hashkey];
406 }
407 } 421 }
408 }
409 422
410 keymap.swap (sorted_keymap); 423 keymap.swap (sorted_keymap);
411 424
412#if defined (DEBUG_STRICT) || defined (DEBUG_KEYBOARD) 425#if defined (DEBUG_STRICT) || defined (DEBUG_KEYBOARD)
413 // check for invariants 426 // check for invariants
434 int index = find_keysym (a->keysym + j, a->state); 447 int index = find_keysym (a->keysym + j, a->state);
435 448
436 assert (index >= 0); 449 assert (index >= 0);
437 keysym_t *b = keymap [index]; 450 keysym_t *b = keymap [index];
438 assert (i == (signed) index || // the normally expected result 451 assert (i == (signed) index || // the normally expected result
439 (a->keysym + j) >= b->keysym && (a->keysym + j) <= (b->keysym + b->range) && compare_priority (a, b) <= 0); // is effectively the same 452 (a->keysym + j) >= b->keysym && (a->keysym + j) <= (b->keysym + b->range) && compare_priority (a, b) <= 0); // is effectively the same or a closer match
440 } 453 }
441 } 454 }
442#endif 455#endif
443} 456}
444 457
445int 458int
446keyboard_manager::find_keysym (KeySym keysym, unsigned int state) 459keyboard_manager::find_keysym (KeySym keysym, unsigned int state)
447{ 460{
448 int hashkey = keysym & KEYSYM_HASH_MASK; 461 int hashkey = keysym & KEYSYM_HASH_MASK;
449 unsigned int index = hash [hashkey]; 462 unsigned int index = hash [hashkey];
463 unsigned int end = hashkey < KEYSYM_HASH_BUDGETS - 1
464 ? hash [hashkey + 1]
465 : keymap.size ();
450 466
451 for (; index < keymap.size (); ++index) 467 for (; index < end; ++index)
452 { 468 {
453 keysym_t *key = keymap [index]; 469 keysym_t *key = keymap [index];
454 assert (key);
455 470
456 if (key->keysym <= keysym && key->keysym + key->range > keysym 471 if (key->keysym <= keysym && keysym < key->keysym + key->range
457 // match only the specified bits in state and ignore others 472 // match only the specified bits in state and ignore others
458 && (key->state & state) == key->state) 473 && (key->state & state) == key->state)
459 return index; 474 return index;
460 else if (key->keysym > keysym && key->range == 1)
461 return -1;
462 } 475 }
463 476
464 return -1; 477 return -1;
465} 478}
466 479

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines