Mercurial > emacs
comparison src/w32inevt.c @ 19710:4a6b8c86ad87
Declare externs from other files.
(w32_kbd_mods_to_emacs): New parameter KEY.
Use w32-capslock-is-shiftlock for old behavior.
(key_event): Pass in new parameter to w32_kbd_mods_to_emacs.
(key_event): New parameter isdead. Set isdead if the
key press was done using a dead key.
author | Geoff Voelker <voelker@cs.washington.edu> |
---|---|
date | Wed, 03 Sep 1997 00:52:40 +0000 |
parents | 36babc489b0c |
children | 1a4fc4d9ca9a |
comparison
equal
deleted
inserted
replaced
19709:6b326be52f18 | 19710:4a6b8c86ad87 |
---|---|
47 /* from dispnew.c */ | 47 /* from dispnew.c */ |
48 extern int change_frame_size (FRAME_PTR, int, int, int, int); | 48 extern int change_frame_size (FRAME_PTR, int, int, int, int); |
49 | 49 |
50 /* from w32fns.c */ | 50 /* from w32fns.c */ |
51 extern Lisp_Object Vw32_alt_is_meta; | 51 extern Lisp_Object Vw32_alt_is_meta; |
52 | |
53 /* from w32term */ | |
54 extern Lisp_Object Vw32_capslock_is_shiftlock; | |
52 | 55 |
53 /* Event queue */ | 56 /* Event queue */ |
54 #define EVENT_QUEUE_SIZE 50 | 57 #define EVENT_QUEUE_SIZE 50 |
55 static INPUT_RECORD event_queue[EVENT_QUEUE_SIZE]; | 58 static INPUT_RECORD event_queue[EVENT_QUEUE_SIZE]; |
56 static INPUT_RECORD *queue_ptr = event_queue, *queue_end = event_queue; | 59 static INPUT_RECORD *queue_ptr = event_queue, *queue_end = event_queue; |
94 } | 97 } |
95 | 98 |
96 /* Translate console modifiers to emacs modifiers. | 99 /* Translate console modifiers to emacs modifiers. |
97 German keyboard support (Kai Morgan Zeise 2/18/95). */ | 100 German keyboard support (Kai Morgan Zeise 2/18/95). */ |
98 int | 101 int |
99 w32_kbd_mods_to_emacs (DWORD mods) | 102 w32_kbd_mods_to_emacs (DWORD mods, WORD key) |
100 { | 103 { |
101 int retval = 0; | 104 int retval = 0; |
102 | 105 |
103 /* If AltGr has been pressed, remove it. */ | 106 /* If AltGr has been pressed, remove it. */ |
104 if ((mods & (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED)) | 107 if ((mods & (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED)) |
114 if ((mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) | 117 if ((mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) |
115 == (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) | 118 == (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) |
116 retval |= meta_modifier; | 119 retval |= meta_modifier; |
117 } | 120 } |
118 | 121 |
122 /* Just in case someone wanted the original behaviour, make it | |
123 optional by setting w32-capslock-is-shiftlock to t. */ | |
124 if (NILP (Vw32_capslock_is_shiftlock) | |
125 && ((key == VK_INSERT) | |
126 || (key == VK_DELETE) | |
127 || ((key >= VK_F1) && (key <= VK_F24)) | |
128 || ((key >= VK_PRIOR) && (key <= VK_DOWN)))) | |
129 { | |
130 if ( (mods & SHIFT_PRESSED) == SHIFT_PRESSED) | |
131 retval |= shift_modifier; | |
132 } | |
133 else | |
134 { | |
119 if (((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) == SHIFT_PRESSED) | 135 if (((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) == SHIFT_PRESSED) |
120 || ((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) == CAPSLOCK_ON)) | 136 || ((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) == CAPSLOCK_ON)) |
121 retval |= shift_modifier; | 137 retval |= shift_modifier; |
138 } | |
122 | 139 |
123 return retval; | 140 return retval; |
124 } | 141 } |
125 | 142 |
126 /* The return code indicates key code size. */ | 143 /* The return code indicates key code size. */ |
286 }; | 303 }; |
287 | 304 |
288 /* return code -1 means that event_queue_ptr won't be incremented. | 305 /* return code -1 means that event_queue_ptr won't be incremented. |
289 In other word, this event makes two key codes. (by himi) */ | 306 In other word, this event makes two key codes. (by himi) */ |
290 int | 307 int |
291 key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev) | 308 key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead) |
292 { | 309 { |
293 int map; | 310 int map; |
294 int key_flag = 0; | 311 int key_flag = 0; |
295 static BOOL map_virt_key_init_done; | 312 static BOOL map_virt_key_init_done; |
313 | |
314 *isdead = 0; | |
296 | 315 |
297 /* Skip key-up events. */ | 316 /* Skip key-up events. */ |
298 if (!event->bKeyDown) | 317 if (!event->bKeyDown) |
299 return 0; | 318 return 0; |
300 | 319 |
332 /* ASCII */ | 351 /* ASCII */ |
333 emacs_ev->kind = ascii_keystroke; | 352 emacs_ev->kind = ascii_keystroke; |
334 key_flag = w32_kbd_patch_key (event); /* 95.7.25 by himi */ | 353 key_flag = w32_kbd_patch_key (event); /* 95.7.25 by himi */ |
335 if (key_flag == 0) | 354 if (key_flag == 0) |
336 return 0; | 355 return 0; |
356 if (key_flag < 0) | |
357 *isdead = 1; | |
337 XSETINT (emacs_ev->code, event->uChar.AsciiChar); | 358 XSETINT (emacs_ev->code, event->uChar.AsciiChar); |
338 } | 359 } |
339 #ifdef MULE | 360 #ifdef MULE |
340 /* for IME */ | 361 /* for IME */ |
341 else if (map == -3) | 362 else if (map == -3) |
373 #ifdef MULE | 394 #ifdef MULE |
374 XSET (emacs_ev->frame_or_window, Lisp_Frame, get_frame ()); | 395 XSET (emacs_ev->frame_or_window, Lisp_Frame, get_frame ()); |
375 #else | 396 #else |
376 XSETFRAME (emacs_ev->frame_or_window, get_frame ()); | 397 XSETFRAME (emacs_ev->frame_or_window, get_frame ()); |
377 #endif | 398 #endif |
378 emacs_ev->modifiers = w32_kbd_mods_to_emacs (event->dwControlKeyState); | 399 emacs_ev->modifiers = w32_kbd_mods_to_emacs (event->dwControlKeyState, |
400 event->wVirtualKeyCode); | |
379 emacs_ev->timestamp = GetTickCount (); | 401 emacs_ev->timestamp = GetTickCount (); |
380 if (key_flag == 2) return -1; /* 95.7.25 by himi */ | 402 if (key_flag == 2) return -1; /* 95.7.25 by himi */ |
381 return 1; | 403 return 1; |
382 } | 404 } |
383 | 405 |
480 if (i == NUM_MOUSE_BUTTONS) | 502 if (i == NUM_MOUSE_BUTTONS) |
481 return 0; | 503 return 0; |
482 | 504 |
483 button_state = event->dwButtonState; | 505 button_state = event->dwButtonState; |
484 emacs_ev->timestamp = GetTickCount (); | 506 emacs_ev->timestamp = GetTickCount (); |
485 emacs_ev->modifiers = w32_kbd_mods_to_emacs (event->dwControlKeyState) | | 507 emacs_ev->modifiers = w32_kbd_mods_to_emacs (event->dwControlKeyState, 0) | |
486 ((event->dwButtonState & mask) ? down_modifier : up_modifier); | 508 ((event->dwButtonState & mask) ? down_modifier : up_modifier); |
487 | 509 |
488 XSETFASTINT (emacs_ev->x, event->dwMousePosition.X); | 510 XSETFASTINT (emacs_ev->x, event->dwMousePosition.X); |
489 XSETFASTINT (emacs_ev->y, event->dwMousePosition.Y); | 511 XSETFASTINT (emacs_ev->y, event->dwMousePosition.Y); |
490 /* for Mule 2.2 (Based on Emacs 19.28 */ | 512 /* for Mule 2.2 (Based on Emacs 19.28 */ |
510 w32_console_read_socket (int sd, struct input_event *bufp, int numchars, | 532 w32_console_read_socket (int sd, struct input_event *bufp, int numchars, |
511 int waitp, int expected) | 533 int waitp, int expected) |
512 { | 534 { |
513 BOOL no_events = TRUE; | 535 BOOL no_events = TRUE; |
514 int nev, ret = 0, add; | 536 int nev, ret = 0, add; |
515 | 537 int isdead; |
538 | |
516 if (interrupt_input_blocked) | 539 if (interrupt_input_blocked) |
517 { | 540 { |
518 interrupt_input_pending = 1; | 541 interrupt_input_pending = 1; |
519 return -1; | 542 return -1; |
520 } | 543 } |
537 while (nev > 0 && numchars > 0) | 560 while (nev > 0 && numchars > 0) |
538 { | 561 { |
539 switch (queue_ptr->EventType) | 562 switch (queue_ptr->EventType) |
540 { | 563 { |
541 case KEY_EVENT: | 564 case KEY_EVENT: |
542 add = key_event (&queue_ptr->Event.KeyEvent, bufp); | 565 add = key_event (&queue_ptr->Event.KeyEvent, bufp, &isdead); |
543 if (add == -1) /* 95.7.25 by himi */ | 566 if (add == -1) /* 95.7.25 by himi */ |
544 { | 567 { |
545 queue_ptr--; | 568 queue_ptr--; |
546 add = 1; | 569 add = 1; |
547 } | 570 } |