Mercurial > emacs
annotate src/w32inevt.c @ 18360:85a1366cbcec
(customize-menu-create): Return nil if Emacs.
(custom-mode): Handle custom-mode-customize-menu being nil.
(custom-mode-customize-menu): Don't initialize if customize-menu-create
returns nil.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 21 Jun 1997 05:02:47 +0000 |
parents | 36babc489b0c |
children | 4a6b8c86ad87 |
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" | |
36 | |
37 /* stdin, from ntterm */ | |
38 extern HANDLE keyboard_handle; | |
39 | |
40 /* Info for last mouse motion */ | |
41 static COORD movement_pos; | |
42 static DWORD movement_time; | |
43 | |
44 /* from keyboard.c */ | |
45 extern void reinvoke_input_signal (void); | |
46 | |
47 /* from dispnew.c */ | |
48 extern int change_frame_size (FRAME_PTR, int, int, int, int); | |
49 | |
15460
be07c4433554
(Vwin32_alt_is_meta): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
15144
diff
changeset
|
50 /* from w32fns.c */ |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15784
diff
changeset
|
51 extern Lisp_Object Vw32_alt_is_meta; |
15460
be07c4433554
(Vwin32_alt_is_meta): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
15144
diff
changeset
|
52 |
9907 | 53 /* Event queue */ |
54 #define EVENT_QUEUE_SIZE 50 | |
55 static INPUT_RECORD event_queue[EVENT_QUEUE_SIZE]; | |
56 static INPUT_RECORD *queue_ptr = event_queue, *queue_end = event_queue; | |
57 | |
58 static int | |
59 fill_queue (BOOL block) | |
60 { | |
61 BOOL rc; | |
62 DWORD events_waiting; | |
63 | |
64 if (queue_ptr < queue_end) | |
65 return queue_end-queue_ptr; | |
66 | |
67 if (!block) | |
68 { | |
69 /* Check to see if there are some events to read before we try | |
70 because we can't block. */ | |
71 if (!GetNumberOfConsoleInputEvents (keyboard_handle, &events_waiting)) | |
72 return -1; | |
73 if (events_waiting == 0) | |
74 return 0; | |
75 } | |
76 | |
77 rc = ReadConsoleInput (keyboard_handle, event_queue, EVENT_QUEUE_SIZE, | |
78 &events_waiting); | |
79 if (!rc) | |
80 return -1; | |
81 queue_ptr = event_queue; | |
82 queue_end = event_queue + events_waiting; | |
83 return (int) events_waiting; | |
84 } | |
85 | |
86 /* In a generic, multi-frame world this should take a console handle | |
87 and return the frame for it | |
88 | |
89 Right now, there's only one frame so return it. */ | |
90 static FRAME_PTR | |
91 get_frame (void) | |
92 { | |
93 return selected_frame; | |
94 } | |
95 | |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
96 /* Translate console modifiers to emacs modifiers. |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
97 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
|
98 int |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15784
diff
changeset
|
99 w32_kbd_mods_to_emacs (DWORD mods) |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
100 { |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
101 int retval = 0; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
102 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
103 /* If AltGr has been pressed, remove it. */ |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
104 if ((mods & (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
105 == (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
106 mods &= ~ (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED); |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
107 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
108 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
|
109 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
|
110 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
111 if (mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
112 { |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
113 retval |= ctrl_modifier; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
114 if ((mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
115 == (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
116 retval |= meta_modifier; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
117 } |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
118 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
119 if (((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) == SHIFT_PRESSED) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
120 || ((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) == CAPSLOCK_ON)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
121 retval |= shift_modifier; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
122 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
123 return retval; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
124 } |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
125 |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
126 /* 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
|
127 int |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15784
diff
changeset
|
128 w32_kbd_patch_key (KEY_EVENT_RECORD *event) |
9907 | 129 { |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
130 unsigned int key_code = event->wVirtualKeyCode; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
131 unsigned int mods = event->dwControlKeyState; |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
132 BYTE keystate[256]; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
133 static BYTE ansi_code[4]; |
15144
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
134 static int isdead = 0; |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
135 |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
136 if (isdead == 2) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
137 { |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
138 event->uChar.AsciiChar = ansi_code[2]; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
139 isdead = 0; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
140 return 1; |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
141 } |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
142 if (event->uChar.AsciiChar != 0) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
143 return 1; |
14463
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
144 |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
145 memset (keystate, 0, sizeof (keystate)); |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
146 if (mods & SHIFT_PRESSED) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
147 keystate[VK_SHIFT] = 0x80; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
148 if (mods & CAPSLOCK_ON) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
149 keystate[VK_CAPITAL] = 1; |
14463
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
150 if ((mods & LEFT_CTRL_PRESSED) && (mods & RIGHT_ALT_PRESSED)) |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
151 { |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
152 keystate[VK_CONTROL] = 0x80; |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
153 keystate[VK_LCONTROL] = 0x80; |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
154 keystate[VK_MENU] = 0x80; |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
155 keystate[VK_RMENU] = 0x80; |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
156 } |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
157 |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
158 isdead = ToAscii (event->wVirtualKeyCode, event->wVirtualScanCode, |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
159 keystate, (LPWORD) ansi_code, 0); |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
160 if (isdead == 0) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
161 return 0; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
162 event->uChar.AsciiChar = ansi_code[0]; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
163 return isdead; |
9907 | 164 } |
15144
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
165 |
9907 | 166 /* Map virtual key codes into: |
167 -1 - Ignore this key | |
168 -2 - ASCII char | |
169 Other - Map non-ASCII keys into X keysyms so that they are looked up | |
170 correctly in keyboard.c | |
171 | |
172 Return, escape and tab are mapped to ASCII rather than coming back | |
173 as non-ASCII to be more compatible with old-style keyboard support. */ | |
174 | |
175 static int map_virt_key[256] = | |
176 { | |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
177 #ifdef MULE |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
178 -3, |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
179 #else |
9907 | 180 -1, |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
181 #endif |
9907 | 182 -1, /* VK_LBUTTON */ |
183 -1, /* VK_RBUTTON */ | |
184 0x69, /* VK_CANCEL */ | |
185 -1, /* VK_MBUTTON */ | |
186 -1, -1, -1, | |
187 8, /* VK_BACK */ | |
188 -2, /* VK_TAB */ | |
189 -1, -1, | |
190 11, /* VK_CLEAR */ | |
191 -2, /* VK_RETURN */ | |
192 -1, -1, | |
193 -1, /* VK_SHIFT */ | |
194 -1, /* VK_CONTROL */ | |
195 -1, /* VK_MENU */ | |
196 0x13, /* VK_PAUSE */ | |
197 -1, /* VK_CAPITAL */ | |
198 -1, -1, -1, -1, -1, -1, | |
199 -2, /* VK_ESCAPE */ | |
200 -1, -1, -1, -1, | |
201 -2, /* VK_SPACE */ | |
202 0x55, /* VK_PRIOR */ | |
203 0x56, /* VK_NEXT */ | |
204 0x57, /* VK_END */ | |
205 0x50, /* VK_HOME */ | |
206 0x51, /* VK_LEFT */ | |
207 0x52, /* VK_UP */ | |
208 0x53, /* VK_RIGHT */ | |
209 0x54, /* VK_DOWN */ | |
210 0x60, /* VK_SELECT */ | |
211 0x61, /* VK_PRINT */ | |
212 0x62, /* VK_EXECUTE */ | |
213 -1, /* VK_SNAPSHOT */ | |
214 0x63, /* VK_INSERT */ | |
215 0xff, /* VK_DELETE */ | |
216 0x6a, /* VK_HELP */ | |
217 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, /* 0 - 9 */ | |
218 -1, -1, -1, -1, -1, -1, -1, | |
219 -2, -2, -2, -2, -2, -2, -2, -2, /* A - Z */ | |
220 -2, -2, -2, -2, -2, -2, -2, -2, | |
221 -2, -2, -2, -2, -2, -2, -2, -2, | |
222 -2, -2, | |
223 -1, -1, -1, -1, -1, | |
224 0xb0, /* VK_NUMPAD0 */ | |
225 0xb1, /* VK_NUMPAD1 */ | |
226 0xb2, /* VK_NUMPAD2 */ | |
227 0xb3, /* VK_NUMPAD3 */ | |
228 0xb4, /* VK_NUMPAD4 */ | |
229 0xb5, /* VK_NUMPAD5 */ | |
230 0xb6, /* VK_NUMPAD6 */ | |
231 0xb7, /* VK_NUMPAD7 */ | |
232 0xb8, /* VK_NUMPAD8 */ | |
233 0xb9, /* VK_NUMPAD9 */ | |
234 0xaa, /* VK_MULTIPLY */ | |
235 0xab, /* VK_ADD */ | |
236 0xac, /* VK_SEPARATOR */ | |
237 0xad, /* VK_SUBTRACT */ | |
238 0xae, /* VK_DECIMAL */ | |
239 0xaf, /* VK_DIVIDE */ | |
240 0xbe, /* VK_F1 */ | |
241 0xbf, /* VK_F2 */ | |
242 0xc0, /* VK_F3 */ | |
243 0xc1, /* VK_F4 */ | |
244 0xc2, /* VK_F5 */ | |
245 0xc3, /* VK_F6 */ | |
246 0xc4, /* VK_F7 */ | |
247 0xc5, /* VK_F8 */ | |
248 0xc6, /* VK_F9 */ | |
249 0xc7, /* VK_F10 */ | |
250 0xc8, /* VK_F11 */ | |
251 0xc9, /* VK_F12 */ | |
252 0xca, /* VK_F13 */ | |
253 0xcb, /* VK_F14 */ | |
254 0xcc, /* VK_F15 */ | |
255 0xcd, /* VK_F16 */ | |
256 0xce, /* VK_F17 */ | |
257 0xcf, /* VK_F18 */ | |
258 0xd0, /* VK_F19 */ | |
259 0xd1, /* VK_F20 */ | |
260 0xd2, /* VK_F21 */ | |
261 0xd3, /* VK_F22 */ | |
262 0xd4, /* VK_F23 */ | |
263 0xd5, /* VK_F24 */ | |
264 -1, -1, -1, -1, -1, -1, -1, -1, | |
265 0x7f, /* VK_NUMLOCK */ | |
12337
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
266 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x9f */ |
9907 | 267 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xaf */ |
268 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xb9 */ | |
269 -2, /* ; */ | |
270 -2, /* = */ | |
271 -2, /* , */ | |
272 -2, /* \ */ | |
273 -2, /* . */ | |
274 -2, /* / */ | |
275 -2, /* ` */ | |
12337
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
276 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xcf */ |
9907 | 277 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xda */ |
12337
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
278 -2, -2, -2, -2, -2, /* 0xdf */ |
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
279 -2, -2, -2, -2, -2, |
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
280 -1, /* 0xe5 */ |
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
281 -2, /* oxe6 */ |
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
282 -1, -1, /* 0xe8 */ |
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
283 -2, -2, -2, -2, -2, -2, -2, /* 0xef */ |
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
284 -2, -2, -2, -2, -2, -2, |
85bdcc694c7a
(map_virt_key): Mark some additional chars as valid ASCII.
Richard M. Stallman <rms@gnu.org>
parents:
11386
diff
changeset
|
285 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 0xff */ |
9907 | 286 }; |
287 | |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
288 /* 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
|
289 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
|
290 int |
9907 | 291 key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev) |
292 { | |
293 int map; | |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
294 int key_flag = 0; |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
295 static BOOL map_virt_key_init_done; |
9907 | 296 |
297 /* Skip key-up events. */ | |
15144
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
298 if (!event->bKeyDown) |
9907 | 299 return 0; |
300 | |
301 if (event->wVirtualKeyCode > 0xff) | |
302 { | |
303 printf ("Unknown key code %d\n", event->wVirtualKeyCode); | |
304 return 0; | |
305 } | |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
306 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
307 /* Patch needed for German keyboard. Ulrich Leodolter (1/11/95). */ |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
308 if (! map_virt_key_init_done) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
309 { |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
310 short vk; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
311 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
312 if ((vk = VkKeyScan (0x3c)) >= 0 && vk < 256) map_virt_key[vk] = -2; /* less */ |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
313 if ((vk = VkKeyScan (0x3e)) >= 0 && vk < 256) map_virt_key[vk] = -2; /* greater */ |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
314 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
315 map_virt_key_init_done = TRUE; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
316 } |
9907 | 317 |
318 /* BUGBUG - Ignores the repeat count | |
319 It's questionable whether we want to obey the repeat count anyway | |
320 since keys usually aren't repeated unless key events back up in | |
321 the queue. If they're backing up then we don't generally want | |
322 to honor them later since that leads to significant slop in | |
323 cursor motion when the system is under heavy load. */ | |
15144
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
324 |
9907 | 325 map = map_virt_key[event->wVirtualKeyCode]; |
326 if (map == -1) | |
327 { | |
328 return 0; | |
329 } | |
330 else if (map == -2) | |
331 { | |
332 /* ASCII */ | |
333 emacs_ev->kind = ascii_keystroke; | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15784
diff
changeset
|
334 key_flag = w32_kbd_patch_key (event); /* 95.7.25 by himi */ |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
335 if (key_flag == 0) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
336 return 0; |
10007
10fc4417831d
(SET_FRAME, key_event, do_mouse_event): Use accessor macros.
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
337 XSETINT (emacs_ev->code, event->uChar.AsciiChar); |
9907 | 338 } |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
339 #ifdef MULE |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
340 /* for IME */ |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
341 else if (map == -3) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
342 { |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
343 if ((event->dwControlKeyState & NLS_IME_CONVERSION) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
344 && !(event->dwControlKeyState & RIGHT_ALT_PRESSED) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
345 && !(event->dwControlKeyState & LEFT_ALT_PRESSED) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
346 && !(event->dwControlKeyState & RIGHT_CTRL_PRESSED) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
347 && !(event->dwControlKeyState & LEFT_CTRL_PRESSED)) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
348 { |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
349 emacs_ev->kind = ascii_keystroke; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
350 XSETINT (emacs_ev->code, event->uChar.AsciiChar); |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
351 } |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
352 else |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
353 return 0; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
354 } |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
355 #endif |
9907 | 356 else |
357 { | |
358 /* non-ASCII */ | |
359 emacs_ev->kind = non_ascii_keystroke; | |
15144
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
360 #ifdef HAVE_NTGUI |
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
361 /* use Windows keysym map */ |
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
362 XSETINT (emacs_ev->code, event->wVirtualKeyCode); |
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
363 #else |
9907 | 364 /* |
365 * make_lispy_event () now requires non-ascii codes to have | |
366 * the full X keysym values (2nd byte is 0xff). add it on. | |
367 */ | |
368 map |= 0xff00; | |
10007
10fc4417831d
(SET_FRAME, key_event, do_mouse_event): Use accessor macros.
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
369 XSETINT (emacs_ev->code, map); |
15144
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
370 #endif /* HAVE_NTGUI */ |
9907 | 371 } |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
372 /* 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
|
373 #ifdef MULE |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
374 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
|
375 #else |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
376 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
|
377 #endif |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15784
diff
changeset
|
378 emacs_ev->modifiers = w32_kbd_mods_to_emacs (event->dwControlKeyState); |
9907 | 379 emacs_ev->timestamp = GetTickCount (); |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
380 if (key_flag == 2) return -1; /* 95.7.25 by himi */ |
9907 | 381 return 1; |
382 } | |
383 | |
384 /* Mouse position hook. */ | |
385 void | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15784
diff
changeset
|
386 w32_mouse_position (FRAME_PTR *f, |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
387 #ifndef MULE |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
388 int insist, |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
389 #endif |
9907 | 390 Lisp_Object *bar_window, |
391 enum scroll_bar_part *part, | |
392 Lisp_Object *x, | |
393 Lisp_Object *y, | |
394 unsigned long *time) | |
395 { | |
396 BLOCK_INPUT; | |
15144
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
397 |
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
398 #ifndef MULE |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
399 insist = insist; |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
400 #endif |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
401 |
9907 | 402 *f = get_frame (); |
403 *bar_window = Qnil; | |
404 *part = 0; | |
12544
8f17bdb409cf
(win32_mouse_position, mouse_moved_to):
Karl Heuer <kwzh@gnu.org>
parents:
12337
diff
changeset
|
405 selected_frame->mouse_moved = 0; |
9907 | 406 |
407 *x = movement_pos.X; | |
408 *y = movement_pos.Y; | |
409 *time = movement_time; | |
410 | |
411 UNBLOCK_INPUT; | |
412 } | |
413 | |
414 /* Remember mouse motion and notify emacs. */ | |
415 static void | |
416 mouse_moved_to (int x, int y) | |
417 { | |
418 /* If we're in the same place, ignore it */ | |
419 if (x != movement_pos.X || y != movement_pos.Y) | |
420 { | |
12544
8f17bdb409cf
(win32_mouse_position, mouse_moved_to):
Karl Heuer <kwzh@gnu.org>
parents:
12337
diff
changeset
|
421 selected_frame->mouse_moved = 1; |
9907 | 422 movement_pos.X = x; |
423 movement_pos.Y = y; | |
424 movement_time = GetTickCount (); | |
425 } | |
426 } | |
427 | |
428 /* Consoles return button bits in a strange order: | |
429 least significant - Leftmost button | |
430 next - Rightmost button | |
431 next - Leftmost+1 | |
432 next - Leftmost+2... | |
433 | |
434 Assume emacs likes three button mice, so | |
435 Left == 0 | |
436 Middle == 1 | |
437 Right == 2 | |
438 Others increase from there. */ | |
439 | |
440 static int emacs_button_translation[NUM_MOUSE_BUTTONS] = | |
441 { | |
442 0, 2, 1, 3, 4, | |
443 }; | |
444 | |
445 static int | |
446 do_mouse_event (MOUSE_EVENT_RECORD *event, | |
447 struct input_event *emacs_ev) | |
448 { | |
449 static DWORD button_state = 0; | |
450 DWORD but_change, mask; | |
451 int i; | |
452 | |
453 if (event->dwEventFlags == MOUSE_MOVED) | |
454 { | |
455 /* For movement events we just note that the mouse has moved | |
456 so that emacs will generate drag events. */ | |
457 mouse_moved_to (event->dwMousePosition.X, event->dwMousePosition.Y); | |
458 return 0; | |
459 } | |
460 | |
461 /* It looks like the console code sends us a mouse event with | |
462 dwButtonState == 0 when a window is activated. Ignore this case. */ | |
463 if (event->dwButtonState == button_state) | |
464 return 0; | |
465 | |
466 emacs_ev->kind = mouse_click; | |
467 | |
468 /* Find out what button has changed state since the last button event. */ | |
469 but_change = button_state ^ event->dwButtonState; | |
470 mask = 1; | |
471 for (i = 0; i < NUM_MOUSE_BUTTONS; i++, mask <<= 1) | |
472 if (but_change & mask) | |
473 { | |
10007
10fc4417831d
(SET_FRAME, key_event, do_mouse_event): Use accessor macros.
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
474 XSETINT (emacs_ev->code, emacs_button_translation[i]); |
9907 | 475 break; |
476 } | |
477 | |
478 /* If the changed button is out of emacs' range (highly unlikely) | |
479 ignore this event. */ | |
480 if (i == NUM_MOUSE_BUTTONS) | |
481 return 0; | |
482 | |
483 button_state = event->dwButtonState; | |
484 emacs_ev->timestamp = GetTickCount (); | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15784
diff
changeset
|
485 emacs_ev->modifiers = w32_kbd_mods_to_emacs (event->dwControlKeyState) | |
9907 | 486 ((event->dwButtonState & mask) ? down_modifier : up_modifier); |
487 | |
10007
10fc4417831d
(SET_FRAME, key_event, do_mouse_event): Use accessor macros.
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
488 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
|
489 XSETFASTINT (emacs_ev->y, event->dwMousePosition.Y); |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
490 /* 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
|
491 #ifdef MULE |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
492 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
|
493 #else |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
494 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
|
495 #endif |
9907 | 496 |
497 return 1; | |
498 } | |
499 | |
500 static void | |
501 resize_event (WINDOW_BUFFER_SIZE_RECORD *event) | |
502 { | |
503 FRAME_PTR f = get_frame (); | |
504 | |
505 change_frame_size (f, event->dwSize.Y, event->dwSize.X, 0, 1); | |
506 SET_FRAME_GARBAGED (f); | |
507 } | |
508 | |
509 int | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15784
diff
changeset
|
510 w32_console_read_socket (int sd, struct input_event *bufp, int numchars, |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15784
diff
changeset
|
511 int waitp, int expected) |
9907 | 512 { |
513 BOOL no_events = TRUE; | |
514 int nev, ret = 0, add; | |
515 | |
516 if (interrupt_input_blocked) | |
517 { | |
518 interrupt_input_pending = 1; | |
519 return -1; | |
520 } | |
521 | |
522 interrupt_input_pending = 0; | |
523 BLOCK_INPUT; | |
524 | |
525 for (;;) | |
526 { | |
15784
75547616a6fe
(win32_read_socket): Never block reading from input queue.
Richard M. Stallman <rms@gnu.org>
parents:
15460
diff
changeset
|
527 nev = fill_queue (0); |
9907 | 528 if (nev <= 0) |
529 { | |
530 /* If nev == -1, there was some kind of error | |
531 If nev == 0 then waitp must be zero and no events were available | |
532 so return. */ | |
533 UNBLOCK_INPUT; | |
534 return nev; | |
535 } | |
536 | |
537 while (nev > 0 && numchars > 0) | |
538 { | |
539 switch (queue_ptr->EventType) | |
540 { | |
541 case KEY_EVENT: | |
542 add = key_event (&queue_ptr->Event.KeyEvent, bufp); | |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
543 if (add == -1) /* 95.7.25 by himi */ |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
544 { |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
545 queue_ptr--; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
546 add = 1; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
547 } |
9907 | 548 bufp += add; |
549 ret += add; | |
550 numchars -= add; | |
551 break; | |
552 | |
553 case MOUSE_EVENT: | |
554 add = do_mouse_event (&queue_ptr->Event.MouseEvent, bufp); | |
555 bufp += add; | |
556 ret += add; | |
557 numchars -= add; | |
558 break; | |
559 | |
560 case WINDOW_BUFFER_SIZE_EVENT: | |
561 resize_event (&queue_ptr->Event.WindowBufferSizeEvent); | |
562 break; | |
563 | |
564 case MENU_EVENT: | |
565 case FOCUS_EVENT: | |
566 /* Internal event types, ignored. */ | |
567 break; | |
568 } | |
569 | |
570 queue_ptr++; | |
571 nev--; | |
572 } | |
573 | |
574 if (ret > 0 || expected == 0) | |
575 break; | |
576 } | |
577 | |
578 UNBLOCK_INPUT; | |
579 return ret; | |
580 } |