… | |
… | |
80 | { |
80 | { |
81 | // (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 |
82 | int ca = ecb_popcount32 (a->state /* & OtherModMask */); |
82 | int ca = ecb_popcount32 (a->state /* & OtherModMask */); |
83 | int cb = ecb_popcount32 (b->state /* & OtherModMask */); |
83 | int cb = ecb_popcount32 (b->state /* & OtherModMask */); |
84 | |
84 | |
85 | if (ca != cb) |
|
|
86 | return ca - cb; |
85 | return ca - cb; |
87 | //else if (a->state != b->state) // this behavior is to be discussed |
|
|
88 | // return b->state - a->state; |
|
|
89 | else |
|
|
90 | return 0; |
|
|
91 | } |
86 | } |
92 | |
87 | |
93 | //////////////////////////////////////////////////////////////////////////////// |
88 | //////////////////////////////////////////////////////////////////////////////// |
94 | keyboard_manager::keyboard_manager () |
89 | keyboard_manager::keyboard_manager () |
95 | { |
90 | { |
… | |
… | |
181 | ++hash_bucket_size [hashkey]; |
176 | ++hash_bucket_size [hashkey]; |
182 | } |
177 | } |
183 | |
178 | |
184 | // now we know the size of each bucket |
179 | // now we know the size of each bucket |
185 | // compute the index of each bucket |
180 | // compute the index of each bucket |
186 | hash [0] = 0; |
|
|
187 | for (index = 0, i = 1; i < KEYSYM_HASH_BUCKETS; ++i) |
181 | for (index = 0, i = 0; i < KEYSYM_HASH_BUCKETS; ++i) |
188 | { |
182 | { |
189 | index += hash_bucket_size [i - 1]; |
|
|
190 | hash [i] = index; |
183 | hash [i] = index; |
|
|
184 | index += hash_bucket_size [i]; |
191 | } |
185 | } |
192 | |
186 | |
193 | // and allocate just enough space |
187 | // and allocate just enough space |
194 | simplevec <keysym_t *> sorted_keymap (index + hash_bucket_size [i - 1], 0); |
188 | simplevec <keysym_t *> sorted_keymap (index, 0); |
195 | |
189 | |
196 | memset (hash_bucket_size, 0, sizeof (hash_bucket_size)); |
190 | memset (hash_bucket_size, 0, sizeof (hash_bucket_size)); |
197 | |
191 | |
198 | // fill in sorted_keymap |
192 | // fill in sorted_keymap |
199 | // it is sorted in each bucket |
193 | // it is sorted in each bucket |