]>
Commit | Line | Data |
---|---|---|
0a7814d6 AG |
1 | To: vim-dev@vim.org |
2 | Subject: patch 7.1.095 | |
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 7.1.095 | |
11 | Problem: The FocusLost and FocusGained autocommands are triggered | |
12 | asynchronously in the GUI. This may cause arbitrary problems. | |
13 | Solution: Put the focus event in the input buffer and handle it when ready | |
14 | for it. | |
15 | Files: src/eval.c, src/getchar.c, src/gui.c, src/gui_gtk_x11.c, | |
16 | src/keymap.h | |
17 | ||
18 | ||
19 | *** ../vim-7.1.094/src/eval.c Thu Aug 30 11:10:38 2007 | |
20 | --- src/eval.c Mon Sep 3 22:48:09 2007 | |
21 | *************** | |
22 | *** 9912,9929 **** | |
23 | ||
24 | ++no_mapping; | |
25 | ++allow_keys; | |
26 | ! if (argvars[0].v_type == VAR_UNKNOWN) | |
27 | ! /* getchar(): blocking wait. */ | |
28 | ! n = safe_vgetc(); | |
29 | ! else if (get_tv_number_chk(&argvars[0], &error) == 1) | |
30 | ! /* getchar(1): only check if char avail */ | |
31 | ! n = vpeekc(); | |
32 | ! else if (error || vpeekc() == NUL) | |
33 | ! /* illegal argument or getchar(0) and no char avail: return zero */ | |
34 | ! n = 0; | |
35 | ! else | |
36 | ! /* getchar(0) and char avail: return char */ | |
37 | ! n = safe_vgetc(); | |
38 | --no_mapping; | |
39 | --allow_keys; | |
40 | ||
41 | --- 9912,9935 ---- | |
42 | ||
43 | ++no_mapping; | |
44 | ++allow_keys; | |
45 | ! for (;;) | |
46 | ! { | |
47 | ! if (argvars[0].v_type == VAR_UNKNOWN) | |
48 | ! /* getchar(): blocking wait. */ | |
49 | ! n = safe_vgetc(); | |
50 | ! else if (get_tv_number_chk(&argvars[0], &error) == 1) | |
51 | ! /* getchar(1): only check if char avail */ | |
52 | ! n = vpeekc(); | |
53 | ! else if (error || vpeekc() == NUL) | |
54 | ! /* illegal argument or getchar(0) and no char avail: return zero */ | |
55 | ! n = 0; | |
56 | ! else | |
57 | ! /* getchar(0) and char avail: return char */ | |
58 | ! n = safe_vgetc(); | |
59 | ! if (n == K_IGNORE) | |
60 | ! continue; | |
61 | ! break; | |
62 | ! } | |
63 | --no_mapping; | |
64 | --allow_keys; | |
65 | ||
66 | *** ../vim-7.1.094/src/getchar.c Thu May 10 18:43:02 2007 | |
67 | --- src/getchar.c Wed Aug 29 22:38:49 2007 | |
68 | *************** | |
69 | *** 1596,1603 **** | |
70 | continue; | |
71 | } | |
72 | #endif | |
73 | - | |
74 | #ifdef FEAT_GUI | |
75 | /* Translate K_CSI to CSI. The special key is only used to avoid | |
76 | * it being recognized as the start of a special key. */ | |
77 | if (c == K_CSI) | |
78 | --- 1596,1610 ---- | |
79 | continue; | |
80 | } | |
81 | #endif | |
82 | #ifdef FEAT_GUI | |
83 | + /* The caller doesn't need to know that the focus event is delayed | |
84 | + * until getting a character. */ | |
85 | + if (c == K_FOCUSGAINED || c == K_FOCUSLOST) | |
86 | + { | |
87 | + ui_focus_change(c == K_FOCUSGAINED); | |
88 | + continue; | |
89 | + } | |
90 | + | |
91 | /* Translate K_CSI to CSI. The special key is only used to avoid | |
92 | * it being recognized as the start of a special key. */ | |
93 | if (c == K_CSI) | |
94 | *** ../vim-7.1.094/src/gui.c Thu Aug 30 13:51:52 2007 | |
95 | --- src/gui.c Thu Aug 30 14:10:48 2007 | |
96 | *************** | |
97 | *** 4519,4525 **** | |
98 | xim_set_focus(in_focus); | |
99 | # endif | |
100 | ||
101 | ! ui_focus_change(in_focus); | |
102 | #endif | |
103 | } | |
104 | ||
105 | --- 4519,4536 ---- | |
106 | xim_set_focus(in_focus); | |
107 | # endif | |
108 | ||
109 | ! /* Put events in the input queue only when allowed. | |
110 | ! * ui_focus_change() isn't called directly, because it invokes | |
111 | ! * autocommands and that must not happen asynchronously. */ | |
112 | ! if (!hold_gui_events) | |
113 | ! { | |
114 | ! char_u bytes[3]; | |
115 | ! | |
116 | ! bytes[0] = CSI; | |
117 | ! bytes[1] = KS_EXTRA; | |
118 | ! bytes[2] = in_focus ? (int)KE_FOCUSGAINED : (int)KE_FOCUSLOST; | |
119 | ! add_to_input_buf(bytes, 3); | |
120 | ! } | |
121 | #endif | |
122 | } | |
123 | ||
124 | *** ../vim-7.1.094/src/gui_gtk_x11.c Tue Jun 19 18:07:52 2007 | |
125 | --- src/gui_gtk_x11.c Wed Aug 29 22:43:34 2007 | |
126 | *************** | |
127 | *** 813,822 **** | |
128 | if (blink_state == BLINK_NONE) | |
129 | gui_mch_start_blink(); | |
130 | ||
131 | ! /* make sure keyboard input goes to the draw area (if this is focus for a window) */ | |
132 | if (widget != gui.drawarea) | |
133 | gtk_widget_grab_focus(gui.drawarea); | |
134 | ||
135 | return TRUE; | |
136 | } | |
137 | ||
138 | --- 813,827 ---- | |
139 | if (blink_state == BLINK_NONE) | |
140 | gui_mch_start_blink(); | |
141 | ||
142 | ! /* make sure keyboard input goes to the draw area (if this is focus for a | |
143 | ! * window) */ | |
144 | if (widget != gui.drawarea) | |
145 | gtk_widget_grab_focus(gui.drawarea); | |
146 | ||
147 | + /* make sure the input buffer is read */ | |
148 | + if (gtk_main_level() > 0) | |
149 | + gtk_main_quit(); | |
150 | + | |
151 | return TRUE; | |
152 | } | |
153 | ||
154 | *************** | |
155 | *** 828,833 **** | |
156 | --- 833,842 ---- | |
157 | ||
158 | if (blink_state != BLINK_NONE) | |
159 | gui_mch_stop_blink(); | |
160 | + | |
161 | + /* make sure the input buffer is read */ | |
162 | + if (gtk_main_level() > 0) | |
163 | + gtk_main_quit(); | |
164 | ||
165 | return TRUE; | |
166 | } | |
167 | *** ../vim-7.1.094/src/keymap.h Sat May 5 19:34:22 2007 | |
168 | --- src/keymap.h Wed Aug 29 22:17:51 2007 | |
169 | *************** | |
170 | *** 254,259 **** | |
171 | --- 254,261 ---- | |
172 | , KE_DROP /* DnD data is available */ | |
173 | , KE_CURSORHOLD /* CursorHold event */ | |
174 | , KE_NOP /* doesn't do something */ | |
175 | + , KE_FOCUSGAINED /* focus gained */ | |
176 | + , KE_FOCUSLOST /* focus lost */ | |
177 | }; | |
178 | ||
179 | /* | |
180 | *************** | |
181 | *** 445,450 **** | |
182 | --- 447,454 ---- | |
183 | #define K_CMDWIN TERMCAP2KEY(KS_EXTRA, KE_CMDWIN) | |
184 | ||
185 | #define K_DROP TERMCAP2KEY(KS_EXTRA, KE_DROP) | |
186 | + #define K_FOCUSGAINED TERMCAP2KEY(KS_EXTRA, KE_FOCUSGAINED) | |
187 | + #define K_FOCUSLOST TERMCAP2KEY(KS_EXTRA, KE_FOCUSLOST) | |
188 | ||
189 | #define K_CURSORHOLD TERMCAP2KEY(KS_EXTRA, KE_CURSORHOLD) | |
190 | ||
191 | *** ../vim-7.1.094/src/version.c Thu Aug 30 19:36:52 2007 | |
192 | --- src/version.c Wed Sep 5 21:42:41 2007 | |
193 | *************** | |
194 | *** 668,669 **** | |
195 | --- 668,671 ---- | |
196 | { /* Add new patch number below this line */ | |
197 | + /**/ | |
198 | + 95, | |
199 | /**/ | |
200 | ||
201 | -- | |
202 | ARTHUR: Who are you? | |
203 | TALL KNIGHT: We are the Knights Who Say "Ni"! | |
204 | BEDEVERE: No! Not the Knights Who Say "Ni"! | |
205 | "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD | |
206 | ||
207 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
208 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
209 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
210 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |