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.56 by sf-exg, Mon Dec 5 12:22:50 2011 UTC vs.
Revision 1.61 by sf-exg, Sat Apr 26 15:05:17 2014 UTC

24#include "../config.h" 24#include "../config.h"
25#include "rxvt.h" 25#include "rxvt.h"
26 26
27#ifdef KEYSYM_RESOURCE 27#ifdef KEYSYM_RESOURCE
28 28
29#include <cstring> 29#include <string.h>
30 30
31#include "rxvtperl.h" 31#include "rxvtperl.h"
32#include "keyboard.h" 32#include "keyboard.h"
33#include "command.h"
34 33
35/* an intro to the data structure: 34/* an intro to the data structure:
36 * 35 *
37 * vector keymap[] is grouped. 36 * vector keymap[] is grouped.
38 * 37 *
81{ 80{
82 // (the more '1's in state; the less range): the greater priority 81 // (the more '1's in state; the less range): the greater priority
83 int ca = ecb_popcount32 (a->state /* & OtherModMask */); 82 int ca = ecb_popcount32 (a->state /* & OtherModMask */);
84 int cb = ecb_popcount32 (b->state /* & OtherModMask */); 83 int cb = ecb_popcount32 (b->state /* & OtherModMask */);
85 84
86 if (ca != cb)
87 return ca - cb; 85 return ca - cb;
88//else if (a->state != b->state) // this behavior is to be discussed
89// return b->state - a->state;
90 else
91 return 0;
92} 86}
93 87
94//////////////////////////////////////////////////////////////////////////////// 88////////////////////////////////////////////////////////////////////////////////
95keyboard_manager::keyboard_manager () 89keyboard_manager::keyboard_manager ()
96{ 90{
128 keymap.push_back (key); 122 keymap.push_back (key);
129 hash[0] = 3; 123 hash[0] = 3;
130} 124}
131 125
132bool 126bool
133keyboard_manager::dispatch (rxvt_term *term, KeySym keysym, unsigned int state) 127keyboard_manager::dispatch (rxvt_term *term, KeySym keysym, unsigned int state, const char *kbuf, int len)
134{ 128{
135 assert (("register_done() need to be called", hash[0] == 0)); 129 assert (("register_done() need to be called", hash[0] == 0));
136 130
137 state &= OtherModMask; // mask out uninteresting modifiers 131 state &= OtherModMask; // mask out uninteresting modifiers
138 132
169 163
170void 164void
171keyboard_manager::register_done () 165keyboard_manager::register_done ()
172{ 166{
173 unsigned int i, index, hashkey; 167 unsigned int i, index, hashkey;
174 vector <keysym_t *> sorted_keymap;
175 uint16_t hash_bucket_size[KEYSYM_HASH_BUCKETS]; // size of each bucket 168 uint16_t hash_bucket_size[KEYSYM_HASH_BUCKETS]; // size of each bucket
176 169
177 memset (hash_bucket_size, 0, sizeof (hash_bucket_size)); 170 memset (hash_bucket_size, 0, sizeof (hash_bucket_size));
178 171
179 // determine hash bucket size 172 // determine hash bucket size
183 ++hash_bucket_size [hashkey]; 176 ++hash_bucket_size [hashkey];
184 } 177 }
185 178
186 // now we know the size of each bucket 179 // now we know the size of each bucket
187 // compute the index of each bucket 180 // compute the index of each bucket
188 hash [0] = 0;
189 for (index = 0, i = 1; i < KEYSYM_HASH_BUCKETS; ++i) 181 for (index = 0, i = 0; i < KEYSYM_HASH_BUCKETS; ++i)
190 { 182 {
191 index += hash_bucket_size [i - 1];
192 hash [i] = index; 183 hash [i] = index;
184 index += hash_bucket_size [i];
193 } 185 }
194 186
195 // and allocate just enough space 187 // and allocate just enough space
196 sorted_keymap.insert (sorted_keymap.begin (), index + hash_bucket_size [i - 1], 0); 188 simplevec <keysym_t *> sorted_keymap (index, 0);
197 189
198 memset (hash_bucket_size, 0, sizeof (hash_bucket_size)); 190 memset (hash_bucket_size, 0, sizeof (hash_bucket_size));
199 191
200 // fill in sorted_keymap 192 // fill in sorted_keymap
201 // it is sorted in each bucket 193 // it is sorted in each bucket

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines