Mercurial > emacs
annotate src/w32inevt.c @ 23801:119fd94ae526
(w32_last_error): Fix cut+paste error.
author | Geoff Voelker <voelker@cs.washington.edu> |
---|---|
date | Wed, 02 Dec 1998 23:00:29 +0000 |
parents | 3d02c8b4b525 |
children | aa5a4d0b1591 |
rev | line source |
---|---|
16884
36babc489b0c
Change all uses of win95, winnt, and win32
Geoff Voelker <voelker@cs.washington.edu>
parents:
16588
diff
changeset
|
1 /* Input event support for Emacs on the Microsoft W32 API. |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
2 Copyright (C) 1992, 1993, 1995 Free Software Foundation, Inc. |
9907 | 3 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
4 This file is part of GNU Emacs. |
9907 | 5 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
6 GNU Emacs is free software; you can redistribute it and/or modify |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
7 it under the terms of the GNU General Public License as published by |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
9 any later version. |
9907 | 10 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
11 GNU Emacs is distributed in the hope that it will be useful, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
14 GNU General Public License for more details. |
9907 | 15 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
17 along with GNU Emacs; see the file COPYING. If not, write to |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
19 Boston, MA 02111-1307, USA. |
9907 | 20 |
21 Drew Bliss 01-Oct-93 | |
22 Adapted from ntkbd.c by Tim Fleehart | |
23 */ | |
24 | |
25 | |
26 #include "config.h" | |
27 | |
28 #include <stdlib.h> | |
29 #include <stdio.h> | |
30 #include <windows.h> | |
31 | |
32 #include "lisp.h" | |
33 #include "frame.h" | |
34 #include "blockinput.h" | |
35 #include "termhooks.h" | |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
36 #include "w32heap.h" |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
37 #include "w32term.h" |
9907 | 38 |
39 /* stdin, from ntterm */ | |
40 extern HANDLE keyboard_handle; | |
41 | |
42 /* Info for last mouse motion */ | |
43 static COORD movement_pos; | |
44 static DWORD movement_time; | |
45 | |
46 /* from keyboard.c */ | |
47 extern void reinvoke_input_signal (void); | |
48 | |
49 /* from dispnew.c */ | |
50 extern int change_frame_size (FRAME_PTR, int, int, int, int); | |
51 | |
15460
be07c4433554
(Vwin32_alt_is_meta): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
15144
diff
changeset
|
52 /* from w32fns.c */ |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15784
diff
changeset
|
53 extern Lisp_Object Vw32_alt_is_meta; |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
54 extern unsigned int map_keypad_keys (unsigned int, unsigned int); |
15460
be07c4433554
(Vwin32_alt_is_meta): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
15144
diff
changeset
|
55 |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
56 /* from w32term */ |
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
57 extern Lisp_Object Vw32_capslock_is_shiftlock; |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
58 extern Lisp_Object Vw32_enable_caps_lock; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
59 extern Lisp_Object Vw32_enable_num_lock; |
21611
1a4fc4d9ca9a
(Vw32_recognize_altgr): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19710
diff
changeset
|
60 extern Lisp_Object Vw32_recognize_altgr; |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
61 extern Lisp_Object Vw32_pass_lwindow_to_system; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
62 extern Lisp_Object Vw32_pass_rwindow_to_system; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
63 extern Lisp_Object Vw32_lwindow_modifier; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
64 extern Lisp_Object Vw32_rwindow_modifier; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
65 extern Lisp_Object Vw32_apps_modifier; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
66 extern Lisp_Object Vw32_scroll_lock_modifier; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
67 extern unsigned int w32_key_to_modifier (int key); |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
68 |
9907 | 69 /* Event queue */ |
70 #define EVENT_QUEUE_SIZE 50 | |
71 static INPUT_RECORD event_queue[EVENT_QUEUE_SIZE]; | |
72 static INPUT_RECORD *queue_ptr = event_queue, *queue_end = event_queue; | |
73 | |
74 static int | |
75 fill_queue (BOOL block) | |
76 { | |
77 BOOL rc; | |
78 DWORD events_waiting; | |
79 | |
80 if (queue_ptr < queue_end) | |
81 return queue_end-queue_ptr; | |
82 | |
83 if (!block) | |
84 { | |
85 /* Check to see if there are some events to read before we try | |
86 because we can't block. */ | |
87 if (!GetNumberOfConsoleInputEvents (keyboard_handle, &events_waiting)) | |
88 return -1; | |
89 if (events_waiting == 0) | |
90 return 0; | |
91 } | |
92 | |
93 rc = ReadConsoleInput (keyboard_handle, event_queue, EVENT_QUEUE_SIZE, | |
94 &events_waiting); | |
95 if (!rc) | |
96 return -1; | |
97 queue_ptr = event_queue; | |
98 queue_end = event_queue + events_waiting; | |
99 return (int) events_waiting; | |
100 } | |
101 | |
102 /* In a generic, multi-frame world this should take a console handle | |
103 and return the frame for it | |
104 | |
105 Right now, there's only one frame so return it. */ | |
106 static FRAME_PTR | |
107 get_frame (void) | |
108 { | |
109 return selected_frame; | |
110 } | |
111 | |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
112 /* Translate console modifiers to emacs modifiers. |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
113 German keyboard support (Kai Morgan Zeise 2/18/95). */ |
15144
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
114 int |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
115 w32_kbd_mods_to_emacs (DWORD mods, WORD key) |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
116 { |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
117 int retval = 0; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
118 |
21611
1a4fc4d9ca9a
(Vw32_recognize_altgr): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19710
diff
changeset
|
119 /* If we recognize right-alt and left-ctrl as AltGr, and it has been |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
120 pressed, first remove those modifiers. */ |
21611
1a4fc4d9ca9a
(Vw32_recognize_altgr): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19710
diff
changeset
|
121 if (!NILP (Vw32_recognize_altgr) |
1a4fc4d9ca9a
(Vw32_recognize_altgr): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19710
diff
changeset
|
122 && (mods & (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED)) |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
123 == (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
124 mods &= ~ (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED); |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
125 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
126 if (mods & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED)) |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15784
diff
changeset
|
127 retval = ((NILP (Vw32_alt_is_meta)) ? alt_modifier : meta_modifier); |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
128 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
129 if (mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
130 { |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
131 retval |= ctrl_modifier; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
132 if ((mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
133 == (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
134 retval |= meta_modifier; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
135 } |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
136 |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
137 if (mods & LEFT_WIN_PRESSED) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
138 retval |= w32_key_to_modifier (VK_LWIN); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
139 if (mods & RIGHT_WIN_PRESSED) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
140 retval |= w32_key_to_modifier (VK_RWIN); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
141 if (mods & APPS_PRESSED) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
142 retval |= w32_key_to_modifier (VK_APPS); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
143 if (mods & SCROLLLOCK_ON) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
144 retval |= w32_key_to_modifier (VK_SCROLL); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
145 |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
146 /* Just in case someone wanted the original behaviour, make it |
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
147 optional by setting w32-capslock-is-shiftlock to t. */ |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
148 if (NILP (Vw32_capslock_is_shiftlock) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
149 /* Keys that should _not_ be affected by CapsLock. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
150 && ( (key == VK_BACK) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
151 || (key == VK_TAB) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
152 || (key == VK_CLEAR) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
153 || (key == VK_RETURN) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
154 || (key == VK_ESCAPE) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
155 || ((key >= VK_SPACE) && (key <= VK_HELP)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
156 || ((key >= VK_NUMPAD0) && (key <= VK_F24)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
157 || ((key >= VK_NUMPAD_CLEAR) && (key <= VK_NUMPAD_DELETE)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
158 )) |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
159 { |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
160 /* Only consider shift state. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
161 if ((mods & SHIFT_PRESSED) != 0) |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
162 retval |= shift_modifier; |
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
163 } |
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
164 else |
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
165 { |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
166 /* Ignore CapsLock state if not enabled. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
167 if (NILP (Vw32_enable_caps_lock)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
168 mods &= ~CAPSLOCK_ON; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
169 if ((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) != 0) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
170 retval |= shift_modifier; |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
171 } |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
172 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
173 return retval; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
174 } |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
175 |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
176 #if 0 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
177 /* Return nonzero if the virtual key is a dead key. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
178 static int |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
179 is_dead_key (int wparam) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
180 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
181 unsigned int code = MapVirtualKey (wparam, 2); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
182 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
183 /* Windows 95 returns 0x8000, NT returns 0x80000000. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
184 return (code & 0x80008000) ? 1 : 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
185 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
186 #endif |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
187 |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
188 /* The return code indicates key code size. */ |
14463
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
189 int |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15784
diff
changeset
|
190 w32_kbd_patch_key (KEY_EVENT_RECORD *event) |
9907 | 191 { |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
192 unsigned int key_code = event->wVirtualKeyCode; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
193 unsigned int mods = event->dwControlKeyState; |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
194 BYTE keystate[256]; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
195 static BYTE ansi_code[4]; |
15144
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
196 static int isdead = 0; |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
197 |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
198 if (isdead == 2) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
199 { |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
200 event->uChar.AsciiChar = ansi_code[2]; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
201 isdead = 0; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
202 return 1; |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
203 } |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
204 if (event->uChar.AsciiChar != 0) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
205 return 1; |
14463
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
206 |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
207 memset (keystate, 0, sizeof (keystate)); |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
208 keystate[key_code] = 0x80; |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
209 if (mods & SHIFT_PRESSED) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
210 keystate[VK_SHIFT] = 0x80; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
211 if (mods & CAPSLOCK_ON) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
212 keystate[VK_CAPITAL] = 1; |
21611
1a4fc4d9ca9a
(Vw32_recognize_altgr): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19710
diff
changeset
|
213 /* If we recognize right-alt and left-ctrl as AltGr, set the key |
1a4fc4d9ca9a
(Vw32_recognize_altgr): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19710
diff
changeset
|
214 states accordingly before invoking ToAscii. */ |
1a4fc4d9ca9a
(Vw32_recognize_altgr): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19710
diff
changeset
|
215 if (!NILP (Vw32_recognize_altgr) |
1a4fc4d9ca9a
(Vw32_recognize_altgr): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19710
diff
changeset
|
216 && (mods & LEFT_CTRL_PRESSED) && (mods & RIGHT_ALT_PRESSED)) |
14463
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
217 { |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
218 keystate[VK_CONTROL] = 0x80; |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
219 keystate[VK_LCONTROL] = 0x80; |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
220 keystate[VK_MENU] = 0x80; |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
221 keystate[VK_RMENU] = 0x80; |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
222 } |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
223 |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
224 #if 0 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
225 /* Because of an OS bug, ToAscii corrupts the stack when called to |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
226 convert a dead key in console mode on NT4. Unfortunately, trying |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
227 to check for dead keys using MapVirtualKey doesn't work either - |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
228 these functions apparently use internal information about keyboard |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
229 layout which doesn't get properly updated in console programs when |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
230 changing layout (though apparently it gets partly updated, |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
231 otherwise ToAscii wouldn't crash). */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
232 if (is_dead_key (event->wVirtualKeyCode)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
233 return 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
234 #endif |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
235 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
236 /* On NT, call ToUnicode instead and then convert to the current |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
237 locale's default codepage. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
238 if (os_subtype == OS_NT) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
239 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
240 WCHAR buf[128]; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
241 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
242 isdead = ToUnicode (event->wVirtualKeyCode, event->wVirtualScanCode, |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
243 keystate, buf, 128, 0); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
244 if (isdead > 0) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
245 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
246 char cp[20]; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
247 int cpId; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
248 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
249 GetLocaleInfo (GetThreadLocale (), |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
250 LOCALE_IDEFAULTANSICODEPAGE, cp, 20); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
251 cpId = atoi (cp); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
252 isdead = WideCharToMultiByte (cpId, 0, buf, isdead, |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
253 ansi_code, 4, NULL, NULL); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
254 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
255 else |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
256 isdead = 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
257 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
258 else |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
259 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
260 isdead = ToAscii (event->wVirtualKeyCode, event->wVirtualScanCode, |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
261 keystate, (LPWORD) ansi_code, 0); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
262 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
263 |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
264 if (isdead == 0) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
265 return 0; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
266 event->uChar.AsciiChar = ansi_code[0]; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
267 return isdead; |
9907 | 268 } |
15144
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
269 |
9907 | 270 |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
271 extern char *lispy_function_keys[]; |
9907 | 272 |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
273 /* return code -1 means that event_queue_ptr won't be incremented. |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
274 In other word, this event makes two key codes. (by himi) */ |
14463
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
275 int |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
276 key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead) |
9907 | 277 { |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
278 static int faked_key = 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
279 static int mod_key_state = 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
280 int wParam; |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
281 |
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
282 *isdead = 0; |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
283 |
9907 | 284 /* Skip key-up events. */ |
15144
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
285 if (!event->bKeyDown) |
9907 | 286 { |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
287 switch (event->wVirtualKeyCode) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
288 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
289 case VK_LWIN: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
290 mod_key_state &= ~LEFT_WIN_PRESSED; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
291 break; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
292 case VK_RWIN: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
293 mod_key_state &= ~RIGHT_WIN_PRESSED; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
294 break; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
295 case VK_APPS: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
296 mod_key_state &= ~APPS_PRESSED; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
297 break; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
298 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
299 return 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
300 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
301 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
302 /* Ignore keystrokes we fake ourself; see below. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
303 if (faked_key == event->wVirtualKeyCode) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
304 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
305 faked_key = 0; |
9907 | 306 return 0; |
307 } | |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
308 |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
309 /* To make it easier to debug this code, ignore modifier keys! */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
310 switch (event->wVirtualKeyCode) |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
311 { |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
312 case VK_LWIN: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
313 if (NILP (Vw32_pass_lwindow_to_system)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
314 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
315 /* Prevent system from acting on keyup (which opens the Start |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
316 menu if no other key was pressed) by simulating a press of |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
317 Space which we will ignore. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
318 if ((mod_key_state & LEFT_WIN_PRESSED) == 0) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
319 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
320 faked_key = VK_SPACE; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
321 keybd_event (VK_SPACE, (BYTE) MapVirtualKey (VK_SPACE, 0), 0, 0); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
322 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
323 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
324 mod_key_state |= LEFT_WIN_PRESSED; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
325 if (!NILP (Vw32_lwindow_modifier)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
326 return 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
327 break; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
328 case VK_RWIN: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
329 if (NILP (Vw32_pass_rwindow_to_system)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
330 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
331 if ((mod_key_state & RIGHT_WIN_PRESSED) == 0) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
332 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
333 faked_key = VK_SPACE; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
334 keybd_event (VK_SPACE, (BYTE) MapVirtualKey (VK_SPACE, 0), 0, 0); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
335 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
336 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
337 mod_key_state |= RIGHT_WIN_PRESSED; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
338 if (!NILP (Vw32_rwindow_modifier)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
339 return 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
340 break; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
341 case VK_APPS: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
342 mod_key_state |= APPS_PRESSED; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
343 if (!NILP (Vw32_apps_modifier)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
344 return 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
345 break; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
346 case VK_CAPITAL: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
347 /* Decide whether to treat as modifier or function key. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
348 if (NILP (Vw32_enable_caps_lock)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
349 goto disable_lock_key; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
350 return 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
351 case VK_NUMLOCK: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
352 /* Decide whether to treat as modifier or function key. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
353 if (NILP (Vw32_enable_num_lock)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
354 goto disable_lock_key; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
355 return 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
356 case VK_SCROLL: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
357 /* Decide whether to treat as modifier or function key. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
358 if (NILP (Vw32_scroll_lock_modifier)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
359 goto disable_lock_key; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
360 return 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
361 disable_lock_key: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
362 /* Ensure the appropriate lock key state is off (and the |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
363 indicator light as well). */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
364 wParam = event->wVirtualKeyCode; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
365 if (GetAsyncKeyState (wParam) & 0x8000) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
366 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
367 /* Fake another press of the relevant key. Apparently, this |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
368 really is the only way to turn off the indicator. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
369 faked_key = wParam; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
370 keybd_event ((BYTE) wParam, (BYTE) MapVirtualKey (wParam, 0), |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
371 KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
372 keybd_event ((BYTE) wParam, (BYTE) MapVirtualKey (wParam, 0), |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
373 KEYEVENTF_EXTENDEDKEY | 0, 0); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
374 keybd_event ((BYTE) wParam, (BYTE) MapVirtualKey (wParam, 0), |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
375 KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
376 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
377 break; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
378 case VK_MENU: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
379 case VK_CONTROL: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
380 case VK_SHIFT: |
9907 | 381 return 0; |
382 } | |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
383 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
384 /* Recognize state of Windows and Apps keys. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
385 event->dwControlKeyState |= mod_key_state; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
386 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
387 /* Distinguish numeric keypad keys from extended keys. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
388 event->wVirtualKeyCode = |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
389 map_keypad_keys (event->wVirtualKeyCode, |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
390 (event->dwControlKeyState & ENHANCED_KEY)); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
391 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
392 if (lispy_function_keys[event->wVirtualKeyCode] == 0) |
9907 | 393 { |
394 emacs_ev->kind = ascii_keystroke; | |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
395 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
396 if (!NILP (Vw32_recognize_altgr) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
397 && (event->dwControlKeyState & LEFT_CTRL_PRESSED) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
398 && (event->dwControlKeyState & RIGHT_ALT_PRESSED)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
399 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
400 /* Don't try to interpret AltGr key chords; ToAscii seems not |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
401 to process them correctly. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
402 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
403 /* Handle key chords including any modifiers other than shift |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
404 directly, in order to preserve as much modifier information as |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
405 possible. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
406 else if (event->dwControlKeyState |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
407 & ( RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
408 | RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
409 | (!NILP (Vw32_lwindow_modifier) ? LEFT_WIN_PRESSED : 0) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
410 | (!NILP (Vw32_rwindow_modifier) ? RIGHT_WIN_PRESSED : 0) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
411 | (!NILP (Vw32_apps_modifier) ? APPS_PRESSED : 0) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
412 | (!NILP (Vw32_scroll_lock_modifier) ? SCROLLLOCK_ON : 0))) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
413 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
414 /* Don't translate modified alphabetic keystrokes, so the user |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
415 doesn't need to constantly switch layout to type control or |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
416 meta keystrokes when the normal layout translates |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
417 alphabetic characters to non-ascii characters. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
418 if ('A' <= event->wVirtualKeyCode && event->wVirtualKeyCode <= 'Z') |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
419 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
420 event->uChar.AsciiChar = event->wVirtualKeyCode; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
421 if ((event->dwControlKeyState & SHIFT_PRESSED) == 0) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
422 event->uChar.AsciiChar += ('a' - 'A'); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
423 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
424 /* Try to handle unrecognized keystrokes by determining the |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
425 base character (ie. translating the base key plus shift |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
426 modifier). */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
427 else if (event->uChar.AsciiChar == 0) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
428 w32_kbd_patch_key (event); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
429 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
430 if (event->uChar.AsciiChar == 0) |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
431 return 0; |
10007
10fc4417831d
(SET_FRAME, key_event, do_mouse_event): Use accessor macros.
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
432 XSETINT (emacs_ev->code, event->uChar.AsciiChar); |
9907 | 433 } |
434 else | |
435 { | |
436 emacs_ev->kind = non_ascii_keystroke; | |
15144
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
437 XSETINT (emacs_ev->code, event->wVirtualKeyCode); |
9907 | 438 } |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
439 |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
440 XSETFRAME (emacs_ev->frame_or_window, get_frame ()); |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
441 emacs_ev->modifiers = w32_kbd_mods_to_emacs (event->dwControlKeyState, |
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
442 event->wVirtualKeyCode); |
9907 | 443 emacs_ev->timestamp = GetTickCount (); |
444 return 1; | |
445 } | |
446 | |
447 /* Mouse position hook. */ | |
448 void | |
21829
674d44aeeda1
(w32_console_mouse_position): Rename from
Geoff Voelker <voelker@cs.washington.edu>
parents:
21611
diff
changeset
|
449 w32_console_mouse_position (FRAME_PTR *f, |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
450 #ifndef MULE |
21829
674d44aeeda1
(w32_console_mouse_position): Rename from
Geoff Voelker <voelker@cs.washington.edu>
parents:
21611
diff
changeset
|
451 int insist, |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
452 #endif |
21829
674d44aeeda1
(w32_console_mouse_position): Rename from
Geoff Voelker <voelker@cs.washington.edu>
parents:
21611
diff
changeset
|
453 Lisp_Object *bar_window, |
674d44aeeda1
(w32_console_mouse_position): Rename from
Geoff Voelker <voelker@cs.washington.edu>
parents:
21611
diff
changeset
|
454 enum scroll_bar_part *part, |
674d44aeeda1
(w32_console_mouse_position): Rename from
Geoff Voelker <voelker@cs.washington.edu>
parents:
21611
diff
changeset
|
455 Lisp_Object *x, |
674d44aeeda1
(w32_console_mouse_position): Rename from
Geoff Voelker <voelker@cs.washington.edu>
parents:
21611
diff
changeset
|
456 Lisp_Object *y, |
674d44aeeda1
(w32_console_mouse_position): Rename from
Geoff Voelker <voelker@cs.washington.edu>
parents:
21611
diff
changeset
|
457 unsigned long *time) |
9907 | 458 { |
459 BLOCK_INPUT; | |
15144
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
460 |
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
461 #ifndef MULE |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
462 insist = insist; |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
463 #endif |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
464 |
9907 | 465 *f = get_frame (); |
466 *bar_window = Qnil; | |
467 *part = 0; | |
12544
8f17bdb409cf
(win32_mouse_position, mouse_moved_to):
Karl Heuer <kwzh@gnu.org>
parents:
12337
diff
changeset
|
468 selected_frame->mouse_moved = 0; |
9907 | 469 |
470 *x = movement_pos.X; | |
471 *y = movement_pos.Y; | |
472 *time = movement_time; | |
473 | |
474 UNBLOCK_INPUT; | |
475 } | |
476 | |
477 /* Remember mouse motion and notify emacs. */ | |
478 static void | |
479 mouse_moved_to (int x, int y) | |
480 { | |
481 /* If we're in the same place, ignore it */ | |
482 if (x != movement_pos.X || y != movement_pos.Y) | |
483 { | |
12544
8f17bdb409cf
(win32_mouse_position, mouse_moved_to):
Karl Heuer <kwzh@gnu.org>
parents:
12337
diff
changeset
|
484 selected_frame->mouse_moved = 1; |
9907 | 485 movement_pos.X = x; |
486 movement_pos.Y = y; | |
487 movement_time = GetTickCount (); | |
488 } | |
489 } | |
490 | |
491 /* Consoles return button bits in a strange order: | |
492 least significant - Leftmost button | |
493 next - Rightmost button | |
494 next - Leftmost+1 | |
495 next - Leftmost+2... | |
496 | |
497 Assume emacs likes three button mice, so | |
498 Left == 0 | |
499 Middle == 1 | |
500 Right == 2 | |
501 Others increase from there. */ | |
502 | |
503 static int emacs_button_translation[NUM_MOUSE_BUTTONS] = | |
504 { | |
505 0, 2, 1, 3, 4, | |
506 }; | |
507 | |
508 static int | |
509 do_mouse_event (MOUSE_EVENT_RECORD *event, | |
510 struct input_event *emacs_ev) | |
511 { | |
512 static DWORD button_state = 0; | |
513 DWORD but_change, mask; | |
514 int i; | |
515 | |
516 if (event->dwEventFlags == MOUSE_MOVED) | |
517 { | |
518 /* For movement events we just note that the mouse has moved | |
519 so that emacs will generate drag events. */ | |
520 mouse_moved_to (event->dwMousePosition.X, event->dwMousePosition.Y); | |
521 return 0; | |
522 } | |
523 | |
524 /* It looks like the console code sends us a mouse event with | |
525 dwButtonState == 0 when a window is activated. Ignore this case. */ | |
526 if (event->dwButtonState == button_state) | |
527 return 0; | |
528 | |
529 emacs_ev->kind = mouse_click; | |
530 | |
531 /* Find out what button has changed state since the last button event. */ | |
532 but_change = button_state ^ event->dwButtonState; | |
533 mask = 1; | |
534 for (i = 0; i < NUM_MOUSE_BUTTONS; i++, mask <<= 1) | |
535 if (but_change & mask) | |
536 { | |
10007
10fc4417831d
(SET_FRAME, key_event, do_mouse_event): Use accessor macros.
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
537 XSETINT (emacs_ev->code, emacs_button_translation[i]); |
9907 | 538 break; |
539 } | |
540 | |
541 /* If the changed button is out of emacs' range (highly unlikely) | |
542 ignore this event. */ | |
543 if (i == NUM_MOUSE_BUTTONS) | |
544 return 0; | |
545 | |
546 button_state = event->dwButtonState; | |
547 emacs_ev->timestamp = GetTickCount (); | |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
548 emacs_ev->modifiers = w32_kbd_mods_to_emacs (event->dwControlKeyState, 0) | |
9907 | 549 ((event->dwButtonState & mask) ? down_modifier : up_modifier); |
550 | |
10007
10fc4417831d
(SET_FRAME, key_event, do_mouse_event): Use accessor macros.
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
551 XSETFASTINT (emacs_ev->x, event->dwMousePosition.X); |
10fc4417831d
(SET_FRAME, key_event, do_mouse_event): Use accessor macros.
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
552 XSETFASTINT (emacs_ev->y, event->dwMousePosition.Y); |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
553 /* for Mule 2.2 (Based on Emacs 19.28 */ |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
554 #ifdef MULE |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
555 XSET (emacs_ev->frame_or_window, Lisp_Frame, get_frame ()); |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
556 #else |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
557 XSETFRAME (emacs_ev->frame_or_window, get_frame ()); |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
558 #endif |
9907 | 559 |
560 return 1; | |
561 } | |
562 | |
563 static void | |
564 resize_event (WINDOW_BUFFER_SIZE_RECORD *event) | |
565 { | |
566 FRAME_PTR f = get_frame (); | |
567 | |
568 change_frame_size (f, event->dwSize.Y, event->dwSize.X, 0, 1); | |
569 SET_FRAME_GARBAGED (f); | |
570 } | |
571 | |
572 int | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15784
diff
changeset
|
573 w32_console_read_socket (int sd, struct input_event *bufp, int numchars, |
21829
674d44aeeda1
(w32_console_mouse_position): Rename from
Geoff Voelker <voelker@cs.washington.edu>
parents:
21611
diff
changeset
|
574 int expected) |
9907 | 575 { |
576 BOOL no_events = TRUE; | |
577 int nev, ret = 0, add; | |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
578 int isdead; |
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
579 |
9907 | 580 if (interrupt_input_blocked) |
581 { | |
582 interrupt_input_pending = 1; | |
583 return -1; | |
584 } | |
585 | |
586 interrupt_input_pending = 0; | |
587 BLOCK_INPUT; | |
588 | |
589 for (;;) | |
590 { | |
15784
75547616a6fe
(win32_read_socket): Never block reading from input queue.
Richard M. Stallman <rms@gnu.org>
parents:
15460
diff
changeset
|
591 nev = fill_queue (0); |
9907 | 592 if (nev <= 0) |
593 { | |
594 /* If nev == -1, there was some kind of error | |
595 If nev == 0 then waitp must be zero and no events were available | |
596 so return. */ | |
597 UNBLOCK_INPUT; | |
598 return nev; | |
599 } | |
600 | |
601 while (nev > 0 && numchars > 0) | |
602 { | |
603 switch (queue_ptr->EventType) | |
604 { | |
605 case KEY_EVENT: | |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
606 add = key_event (&queue_ptr->Event.KeyEvent, bufp, &isdead); |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
607 if (add == -1) /* 95.7.25 by himi */ |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
608 { |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
609 queue_ptr--; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
610 add = 1; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
611 } |
9907 | 612 bufp += add; |
613 ret += add; | |
614 numchars -= add; | |
615 break; | |
616 | |
617 case MOUSE_EVENT: | |
618 add = do_mouse_event (&queue_ptr->Event.MouseEvent, bufp); | |
619 bufp += add; | |
620 ret += add; | |
621 numchars -= add; | |
622 break; | |
623 | |
624 case WINDOW_BUFFER_SIZE_EVENT: | |
625 resize_event (&queue_ptr->Event.WindowBufferSizeEvent); | |
626 break; | |
627 | |
628 case MENU_EVENT: | |
629 case FOCUS_EVENT: | |
630 /* Internal event types, ignored. */ | |
631 break; | |
632 } | |
633 | |
634 queue_ptr++; | |
635 nev--; | |
636 } | |
637 | |
638 if (ret > 0 || expected == 0) | |
639 break; | |
640 } | |
641 | |
642 UNBLOCK_INPUT; | |
643 return ret; | |
644 } |