]>
Commit | Line | Data |
---|---|---|
05649561 AG |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 6.2.248 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 6.2.248 | |
11 | Problem: GTK: When XIM is enabled normal "2" and keypad "2" cannot be | |
12 | distinguished. | |
13 | Solution: Detect that XIM changes the keypad key to the expected ASCII | |
14 | character and fall back to the non-XIM code. (Neil Bird) | |
15 | Files: src/gui_gtk_x11.c, src/mbyte.c, src/proto/mbyte.pro | |
16 | ||
17 | ||
18 | *** ../vim-6.2.247/src/gui_gtk_x11.c Fri Feb 6 19:35:39 2004 | |
19 | --- src/gui_gtk_x11.c Mon Feb 9 15:02:41 2004 | |
20 | *************** | |
21 | *** 937,943 **** | |
22 | #endif | |
23 | ||
24 | #ifdef FEAT_XIM | |
25 | ! if (xim_queue_key_press_event(event)) | |
26 | return TRUE; | |
27 | #endif | |
28 | ||
29 | --- 937,943 ---- | |
30 | #endif | |
31 | ||
32 | #ifdef FEAT_XIM | |
33 | ! if (xim_queue_key_press_event(event, TRUE)) | |
34 | return TRUE; | |
35 | #endif | |
36 | ||
37 | *************** | |
38 | *** 1161,1167 **** | |
39 | * With the default IM for instance, you can enter any UCS code point | |
40 | * by holding down CTRL-SHIFT and typing hexadecimal digits. | |
41 | */ | |
42 | ! return xim_queue_key_press_event(event); | |
43 | } | |
44 | #endif | |
45 | ||
46 | --- 1161,1167 ---- | |
47 | * With the default IM for instance, you can enter any UCS code point | |
48 | * by holding down CTRL-SHIFT and typing hexadecimal digits. | |
49 | */ | |
50 | ! return xim_queue_key_press_event(event, FALSE); | |
51 | } | |
52 | #endif | |
53 | ||
54 | *** ../vim-6.2.247/src/mbyte.c Sun Feb 8 15:13:33 2004 | |
55 | --- src/mbyte.c Mon Feb 9 18:45:03 2004 | |
56 | *************** | |
57 | *** 3114,3119 **** | |
58 | --- 3114,3122 ---- | |
59 | add_to_input_buf(backkey, (int)sizeof(backkey)); | |
60 | } | |
61 | ||
62 | + static int xim_expected_char = NUL; | |
63 | + static int xim_ignored_char = FALSE; | |
64 | + | |
65 | /* | |
66 | * Callback invoked when the user finished preediting. | |
67 | * Put the final string into the input buffer. | |
68 | *************** | |
69 | *** 3122,3127 **** | |
70 | --- 3125,3133 ---- | |
71 | static void | |
72 | im_commit_cb(GtkIMContext *context, const gchar *str, gpointer data) | |
73 | { | |
74 | + int slen = (int)strlen(str); | |
75 | + int add_to_input = TRUE; | |
76 | + | |
77 | /* The imhangul module doesn't reset the preedit string before | |
78 | * committing. Call im_delete_preedit() to work around that. */ | |
79 | im_delete_preedit(); | |
80 | *************** | |
81 | *** 3129,3135 **** | |
82 | /* Indicate that preediting has finished */ | |
83 | preedit_start_col = MAXCOL; | |
84 | ||
85 | ! im_add_to_input((char_u *)str, (int)strlen(str)); | |
86 | ||
87 | if (gtk_main_level() > 0) | |
88 | gtk_main_quit(); | |
89 | --- 3135,3163 ---- | |
90 | /* Indicate that preediting has finished */ | |
91 | preedit_start_col = MAXCOL; | |
92 | ||
93 | ! /* Is this a single character that matches a keypad key that's just | |
94 | ! * been pressed? If so, we don't want it to be entered as such - let | |
95 | ! * us carry on processing the raw keycode so that it may be used in | |
96 | ! * mappings as <kSomething> | |
97 | ! */ | |
98 | ! if (xim_expected_char != NUL) | |
99 | ! { | |
100 | ! /* We're currently processing a keypad or other special key */ | |
101 | ! if (slen == 1 && str[0] == xim_expected_char) | |
102 | ! { | |
103 | ! /* It's a match - don't do it here */ | |
104 | ! xim_ignored_char = TRUE; | |
105 | ! add_to_input = FALSE; | |
106 | ! } | |
107 | ! else | |
108 | ! { | |
109 | ! /* Not a match */ | |
110 | ! xim_ignored_char = FALSE; | |
111 | ! } | |
112 | ! } | |
113 | ! | |
114 | ! if (add_to_input) | |
115 | ! im_add_to_input((char_u *)str, slen); | |
116 | ||
117 | if (gtk_main_level() > 0) | |
118 | gtk_main_quit(); | |
119 | *************** | |
120 | *** 3556,3563 **** | |
121 | } | |
122 | ||
123 | int | |
124 | ! xim_queue_key_press_event(GdkEventKey *event) | |
125 | { | |
126 | /* | |
127 | * When typing fFtT, XIM may be activated. Thus it must pass | |
128 | * gtk_im_context_filter_keypress() in Normal mode. | |
129 | --- 3584,3626 ---- | |
130 | } | |
131 | ||
132 | int | |
133 | ! xim_queue_key_press_event(GdkEventKey *event, int down) | |
134 | { | |
135 | + if (down) | |
136 | + { | |
137 | + /* | |
138 | + * Workaround GTK2 XIM 'feature' that always converts keypad keys to | |
139 | + * chars., even when not part of an IM sequence (ref. feature of | |
140 | + * gdk/gdkkeyuni.c). | |
141 | + * Flag any keypad keys that might represent a single char. | |
142 | + * If this (on its own - i.e., not part of an IM sequence) is | |
143 | + * committed while we're processing one of these keys, we can ignore | |
144 | + * that commit and go ahead & process it ourselves. That way we can | |
145 | + * still distinguish keypad keys for use in mappings. | |
146 | + */ | |
147 | + switch (event->keyval) | |
148 | + { | |
149 | + case GDK_KP_Add: xim_expected_char = '+'; break; | |
150 | + case GDK_KP_Subtract: xim_expected_char = '-'; break; | |
151 | + case GDK_KP_Divide: xim_expected_char = '/'; break; | |
152 | + case GDK_KP_Multiply: xim_expected_char = '*'; break; | |
153 | + case GDK_KP_Decimal: xim_expected_char = '.'; break; | |
154 | + case GDK_KP_Equal: xim_expected_char = '='; break; | |
155 | + case GDK_KP_0: xim_expected_char = '0'; break; | |
156 | + case GDK_KP_1: xim_expected_char = '1'; break; | |
157 | + case GDK_KP_2: xim_expected_char = '2'; break; | |
158 | + case GDK_KP_3: xim_expected_char = '3'; break; | |
159 | + case GDK_KP_4: xim_expected_char = '4'; break; | |
160 | + case GDK_KP_5: xim_expected_char = '5'; break; | |
161 | + case GDK_KP_6: xim_expected_char = '6'; break; | |
162 | + case GDK_KP_7: xim_expected_char = '7'; break; | |
163 | + case GDK_KP_8: xim_expected_char = '8'; break; | |
164 | + case GDK_KP_9: xim_expected_char = '9'; break; | |
165 | + default: xim_expected_char = NUL; | |
166 | + } | |
167 | + xim_ignored_char = FALSE; | |
168 | + } | |
169 | + | |
170 | /* | |
171 | * When typing fFtT, XIM may be activated. Thus it must pass | |
172 | * gtk_im_context_filter_keypress() in Normal mode. | |
173 | *************** | |
174 | *** 3603,3609 **** | |
175 | * right now. Unlike with GTK+ 1.2 we cannot rely on the IM module | |
176 | * not doing anything before the activation key was sent. */ | |
177 | if (im_activatekey_keyval == GDK_VoidSymbol || im_is_active) | |
178 | ! return gtk_im_context_filter_keypress(xic, event); | |
179 | } | |
180 | ||
181 | return FALSE; | |
182 | --- 3666,3683 ---- | |
183 | * right now. Unlike with GTK+ 1.2 we cannot rely on the IM module | |
184 | * not doing anything before the activation key was sent. */ | |
185 | if (im_activatekey_keyval == GDK_VoidSymbol || im_is_active) | |
186 | ! { | |
187 | ! int imresult = gtk_im_context_filter_keypress(xic, event); | |
188 | ! | |
189 | ! /* If XIM tried to commit a keypad key as a single char., | |
190 | ! * ignore it so we can use the keypad key 'raw', for mappings. */ | |
191 | ! if (xim_expected_char != NUL && xim_ignored_char) | |
192 | ! /* We had a keypad key, and XIM tried to thieve it */ | |
193 | ! return FALSE; | |
194 | ! else | |
195 | ! /* Normal processing */ | |
196 | ! return imresult; | |
197 | ! } | |
198 | } | |
199 | ||
200 | return FALSE; | |
201 | *************** | |
202 | *** 4797,4804 **** | |
203 | } | |
204 | } | |
205 | ||
206 | int | |
207 | ! xim_queue_key_press_event(GdkEventKey *event) | |
208 | { | |
209 | if (preedit_buf_len <= 0) | |
210 | return FALSE; | |
211 | --- 4871,4879 ---- | |
212 | } | |
213 | } | |
214 | ||
215 | + /*ARGSUSED*/ | |
216 | int | |
217 | ! xim_queue_key_press_event(GdkEventKey *event, int down) | |
218 | { | |
219 | if (preedit_buf_len <= 0) | |
220 | return FALSE; | |
221 | *** ../vim-6.2.247/src/proto/mbyte.pro Sun Jun 1 12:26:16 2003 | |
222 | --- src/proto/mbyte.pro Mon Feb 9 15:02:04 2004 | |
223 | *************** | |
224 | *** 73,79 **** | |
225 | void xim_decide_input_style __ARGS((void)); | |
226 | int im_get_feedback_attr __ARGS((int col)); | |
227 | void xim_reset __ARGS((void)); | |
228 | ! int xim_queue_key_press_event __ARGS((GdkEventKey *event)); | |
229 | void xim_init __ARGS((void)); | |
230 | void im_shutdown __ARGS((void)); | |
231 | int xim_get_status_area_height __ARGS((void)); | |
232 | --- 73,79 ---- | |
233 | void xim_decide_input_style __ARGS((void)); | |
234 | int im_get_feedback_attr __ARGS((int col)); | |
235 | void xim_reset __ARGS((void)); | |
236 | ! int xim_queue_key_press_event __ARGS((GdkEventKey *event, int down)); | |
237 | void xim_init __ARGS((void)); | |
238 | void im_shutdown __ARGS((void)); | |
239 | int xim_get_status_area_height __ARGS((void)); | |
240 | *** ../vim-6.2.247/src/version.c Mon Feb 9 10:33:13 2004 | |
241 | --- src/version.c Mon Feb 9 18:42:45 2004 | |
242 | *************** | |
243 | *** 639,640 **** | |
244 | --- 639,642 ---- | |
245 | { /* Add new patch number below this line */ | |
246 | + /**/ | |
247 | + 248, | |
248 | /**/ | |
249 | ||
250 | -- | |
251 | Warning label on a superhero Halloween costume: | |
252 | "Caution: Cape does not enable user to fly." | |
253 | ||
254 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
255 | /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
256 | \\\ Project leader for A-A-P -- http://www.A-A-P.org /// | |
257 | \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html /// |