diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32term.c | 76 |
1 files changed, 63 insertions, 13 deletions
diff --git a/src/w32term.c b/src/w32term.c index 49a56b0e429..a73cd1905f8 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -2218,6 +2218,37 @@ static Time enter_timestamp; | |||
| 2218 | int temp_index; | 2218 | int temp_index; |
| 2219 | short temp_buffer[100]; | 2219 | short temp_buffer[100]; |
| 2220 | 2220 | ||
| 2221 | extern int key_event (KEY_EVENT_RECORD *, struct input_event *); | ||
| 2222 | |||
| 2223 | /* Map a Win32 WM_CHAR message into a KEY_EVENT_RECORD so that | ||
| 2224 | we can use the same routines to handle input in both console | ||
| 2225 | and window modes. */ | ||
| 2226 | |||
| 2227 | static void | ||
| 2228 | convert_to_key_event (Win32Msg *msgp, KEY_EVENT_RECORD *eventp) | ||
| 2229 | { | ||
| 2230 | eventp->bKeyDown = TRUE; | ||
| 2231 | eventp->wRepeatCount = 1; | ||
| 2232 | eventp->wVirtualKeyCode = msgp->msg.wParam; | ||
| 2233 | eventp->wVirtualScanCode = (msgp->msg.lParam & 0xFF0000) >> 16; | ||
| 2234 | eventp->uChar.AsciiChar = 0; | ||
| 2235 | eventp->dwControlKeyState = msgp->dwModifiers; | ||
| 2236 | } | ||
| 2237 | |||
| 2238 | /* Return nonzero if the virtual key is a dead key. */ | ||
| 2239 | |||
| 2240 | static int | ||
| 2241 | is_dead_key (int wparam) | ||
| 2242 | { | ||
| 2243 | unsigned int code = MapVirtualKey (wparam, 2); | ||
| 2244 | |||
| 2245 | /* Win95 returns 0x8000, NT returns 0x80000000. */ | ||
| 2246 | if ((code & 0x8000) || (code & 0x80000000)) | ||
| 2247 | return 1; | ||
| 2248 | else | ||
| 2249 | return 0; | ||
| 2250 | } | ||
| 2251 | |||
| 2221 | /* Read events coming from the Win32 shell. | 2252 | /* Read events coming from the Win32 shell. |
| 2222 | This routine is called by the SIGIO handler. | 2253 | This routine is called by the SIGIO handler. |
| 2223 | We return as soon as there are no more events to be read. | 2254 | We return as soon as there are no more events to be read. |
| @@ -2319,7 +2350,7 @@ w32_read_socket (sd, bufp, numchars, waitp, expected) | |||
| 2319 | temp_buffer[temp_index++] = msg.msg.wParam; | 2350 | temp_buffer[temp_index++] = msg.msg.wParam; |
| 2320 | bufp->kind = non_ascii_keystroke; | 2351 | bufp->kind = non_ascii_keystroke; |
| 2321 | bufp->code = msg.msg.wParam; | 2352 | bufp->code = msg.msg.wParam; |
| 2322 | bufp->modifiers = msg.dwModifiers; | 2353 | bufp->modifiers = win32_kbd_mods_to_emacs (msg.dwModifiers); |
| 2323 | XSETFRAME (bufp->frame_or_window, f); | 2354 | XSETFRAME (bufp->frame_or_window, f); |
| 2324 | bufp->timestamp = msg.msg.time; | 2355 | bufp->timestamp = msg.msg.time; |
| 2325 | bufp++; | 2356 | bufp++; |
| @@ -2335,17 +2366,33 @@ w32_read_socket (sd, bufp, numchars, waitp, expected) | |||
| 2335 | { | 2366 | { |
| 2336 | if (numchars > 1) | 2367 | if (numchars > 1) |
| 2337 | { | 2368 | { |
| 2369 | int add; | ||
| 2370 | KEY_EVENT_RECORD key, *keyp = &key; | ||
| 2371 | |||
| 2338 | if (temp_index == sizeof temp_buffer / sizeof (short)) | 2372 | if (temp_index == sizeof temp_buffer / sizeof (short)) |
| 2339 | temp_index = 0; | 2373 | temp_index = 0; |
| 2340 | temp_buffer[temp_index++] = msg.msg.wParam; | 2374 | |
| 2341 | bufp->kind = ascii_keystroke; | 2375 | convert_to_key_event (&msg, keyp); |
| 2342 | bufp->code = msg.msg.wParam; | 2376 | add = key_event (keyp, bufp); |
| 2343 | XSETFRAME (bufp->frame_or_window, f); | 2377 | if (add == -1) |
| 2344 | bufp->modifiers = msg.dwModifiers; | 2378 | { |
| 2345 | bufp->timestamp = msg.msg.time; | 2379 | /* The key pressed generated two characters, most likely |
| 2346 | bufp++; | 2380 | an accent character and a key that could not be |
| 2347 | numchars--; | 2381 | combined with it. Prepend the message on the queue |
| 2348 | count++; | 2382 | again to process the second character (which is |
| 2383 | being held internally in key_event), and process | ||
| 2384 | the first character now. */ | ||
| 2385 | prepend_msg (&msg); | ||
| 2386 | add = 1; | ||
| 2387 | } | ||
| 2388 | |||
| 2389 | /* Throw dead keys away. */ | ||
| 2390 | if (is_dead_key (msg.msg.wParam)) | ||
| 2391 | break; | ||
| 2392 | |||
| 2393 | bufp += add; | ||
| 2394 | numchars -= add; | ||
| 2395 | count += add; | ||
| 2349 | } | 2396 | } |
| 2350 | else | 2397 | else |
| 2351 | { | 2398 | { |
| @@ -3283,11 +3330,14 @@ x_make_frame_visible (f) | |||
| 3283 | if we get to x_make_frame_visible a second time | 3330 | if we get to x_make_frame_visible a second time |
| 3284 | before the window gets really visible. */ | 3331 | before the window gets really visible. */ |
| 3285 | if (! FRAME_ICONIFIED_P (f) | 3332 | if (! FRAME_ICONIFIED_P (f) |
| 3286 | && ! f->output_data.win32->asked_for_visible) | 3333 | && ! f->output_data.win32->asked_for_visible) |
| 3287 | x_set_offset (f, f->output_data.win32->left_pos, f->output_data.win32->top_pos, 0); | 3334 | { |
| 3335 | x_set_offset (f, f->output_data.win32->left_pos, | ||
| 3336 | f->output_data.win32->top_pos, 0); | ||
| 3337 | SetForegroundWindow (FRAME_WIN32_WINDOW (f)); | ||
| 3338 | } | ||
| 3288 | 3339 | ||
| 3289 | f->output_data.win32->asked_for_visible = 1; | 3340 | f->output_data.win32->asked_for_visible = 1; |
| 3290 | |||
| 3291 | ShowWindow (FRAME_WIN32_WINDOW (f), SW_SHOW); | 3341 | ShowWindow (FRAME_WIN32_WINDOW (f), SW_SHOW); |
| 3292 | } | 3342 | } |
| 3293 | 3343 | ||