comparison src/w32term.c @ 14462:599a3ae1e8ea

(convert_to_key_event, is_dead_key): New functions. (w32_read-socket): Convert console modifiers to Emacs modifiers. Use console input routines to unify keyboard support. (x_make_frame_visible): Make frame foreground window.
author Geoff Voelker <voelker@cs.washington.edu>
date Fri, 02 Feb 1996 02:00:56 +0000
parents fb2ce4ebc871
children a538ad05bce1
comparison
equal deleted inserted replaced
14461:4fe9540be594 14462:599a3ae1e8ea
2216 /* Record the last 100 characters stored 2216 /* Record the last 100 characters stored
2217 to help debug the loss-of-chars-during-GC problem. */ 2217 to help debug the loss-of-chars-during-GC problem. */
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.
2224 2255
2225 Events representing keys are stored in buffer BUFP, 2256 Events representing keys are stored in buffer BUFP,
2317 if (temp_index == sizeof temp_buffer / sizeof (short)) 2348 if (temp_index == sizeof temp_buffer / sizeof (short))
2318 temp_index = 0; 2349 temp_index = 0;
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++;
2326 numchars--; 2357 numchars--;
2327 count++; 2358 count++;
2333 2364
2334 if (f && !f->iconified) 2365 if (f && !f->iconified)
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 {
2352 abort (); 2399 abort ();
2353 } 2400 }
3281 /* We test FRAME_GARBAGED_P here to make sure we don't 3328 /* We test FRAME_GARBAGED_P here to make sure we don't
3282 call x_set_offset a second time 3329 call x_set_offset a second time
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
3294 /* Synchronize to ensure Emacs knows the frame is visible 3344 /* Synchronize to ensure Emacs knows the frame is visible
3295 before we do anything else. We do this loop with input not blocked 3345 before we do anything else. We do this loop with input not blocked