Mercurial > emacs
annotate src/w32inevt.c @ 106818:a3da62473e24
Fix typos in comments and ChangeLogs.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Wed, 13 Jan 2010 16:38:28 +0100 |
parents | 1d1d5d9bd884 |
children | 0b67a7f89499 |
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. |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
2 Copyright (C) 1992, 1993, 1995, 2001, 2002, 2003, 2004, 2005, 2006, |
106815 | 3 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
9907 | 4 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
5 This file is part of GNU Emacs. |
9907 | 6 |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
7 GNU Emacs is free software: you can redistribute it and/or modify |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
8 it under the terms of the GNU General Public License as published by |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
10 (at your option) any later version. |
9907 | 11 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
12 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
|
13 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
|
14 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
|
15 GNU General Public License for more details. |
9907 | 16 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12544
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
9907 | 19 |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
20 /* |
9907 | 21 Drew Bliss 01-Oct-93 |
22 Adapted from ntkbd.c by Tim Fleehart | |
23 */ | |
24 | |
25 | |
42469 | 26 #ifdef HAVE_CONFIG_H |
27 #include <config.h> | |
28 #endif | |
9907 | 29 |
30 #include <stdlib.h> | |
31 #include <stdio.h> | |
32 #include <windows.h> | |
105669
68dd71358159
* alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101682
diff
changeset
|
33 #include <setjmp.h> |
9907 | 34 |
31113
1743924e00dd
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
29319
diff
changeset
|
35 #ifndef MOUSE_MOVED |
1743924e00dd
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
29319
diff
changeset
|
36 #define MOUSE_MOVED 1 |
1743924e00dd
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
29319
diff
changeset
|
37 #endif |
1743924e00dd
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
29319
diff
changeset
|
38 |
9907 | 39 #include "lisp.h" |
31113
1743924e00dd
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
29319
diff
changeset
|
40 #include "keyboard.h" |
9907 | 41 #include "frame.h" |
80615
ed3882ec9644
Backport of long term bug from trunk:
Jason Rumney <jasonr@gnu.org>
parents:
79759
diff
changeset
|
42 #include "dispextern.h" |
9907 | 43 #include "blockinput.h" |
44 #include "termhooks.h" | |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
45 #include "w32heap.h" |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
46 #include "w32term.h" |
9907 | 47 |
48 /* stdin, from ntterm */ | |
49 extern HANDLE keyboard_handle; | |
50 | |
51 /* Info for last mouse motion */ | |
52 static COORD movement_pos; | |
53 static DWORD movement_time; | |
54 | |
55 /* from keyboard.c */ | |
56 extern void reinvoke_input_signal (void); | |
57 | |
24937
42f29912dc46
(w32_console_read_socket): Use new variable w32_use_full_screen_buffer.
Andrew Innes <andrewi@gnu.org>
parents:
24756
diff
changeset
|
58 /* from w32console.c */ |
42f29912dc46
(w32_console_read_socket): Use new variable w32_use_full_screen_buffer.
Andrew Innes <andrewi@gnu.org>
parents:
24756
diff
changeset
|
59 extern int w32_use_full_screen_buffer; |
42f29912dc46
(w32_console_read_socket): Use new variable w32_use_full_screen_buffer.
Andrew Innes <andrewi@gnu.org>
parents:
24756
diff
changeset
|
60 |
15460
be07c4433554
(Vwin32_alt_is_meta): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
15144
diff
changeset
|
61 /* from w32fns.c */ |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15784
diff
changeset
|
62 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
|
63 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
|
64 |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
65 /* from w32term */ |
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
66 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
|
67 extern Lisp_Object Vw32_enable_caps_lock; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
68 extern Lisp_Object Vw32_enable_num_lock; |
21611
1a4fc4d9ca9a
(Vw32_recognize_altgr): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19710
diff
changeset
|
69 extern Lisp_Object Vw32_recognize_altgr; |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
70 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
|
71 extern Lisp_Object Vw32_pass_rwindow_to_system; |
23804
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
72 extern Lisp_Object Vw32_phantom_key_code; |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
73 extern Lisp_Object Vw32_lwindow_modifier; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
74 extern Lisp_Object Vw32_rwindow_modifier; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
75 extern Lisp_Object Vw32_apps_modifier; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
76 extern Lisp_Object Vw32_scroll_lock_modifier; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
77 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
|
78 |
9907 | 79 /* Event queue */ |
80 #define EVENT_QUEUE_SIZE 50 | |
81 static INPUT_RECORD event_queue[EVENT_QUEUE_SIZE]; | |
82 static INPUT_RECORD *queue_ptr = event_queue, *queue_end = event_queue; | |
83 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
84 static int |
9907 | 85 fill_queue (BOOL block) |
86 { | |
87 BOOL rc; | |
88 DWORD events_waiting; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
89 |
9907 | 90 if (queue_ptr < queue_end) |
91 return queue_end-queue_ptr; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
92 |
9907 | 93 if (!block) |
94 { | |
95 /* Check to see if there are some events to read before we try | |
96 because we can't block. */ | |
97 if (!GetNumberOfConsoleInputEvents (keyboard_handle, &events_waiting)) | |
98 return -1; | |
99 if (events_waiting == 0) | |
100 return 0; | |
101 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
102 |
9907 | 103 rc = ReadConsoleInput (keyboard_handle, event_queue, EVENT_QUEUE_SIZE, |
104 &events_waiting); | |
105 if (!rc) | |
106 return -1; | |
107 queue_ptr = event_queue; | |
108 queue_end = event_queue + events_waiting; | |
109 return (int) events_waiting; | |
110 } | |
111 | |
112 /* In a generic, multi-frame world this should take a console handle | |
113 and return the frame for it | |
114 | |
115 Right now, there's only one frame so return it. */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
116 static FRAME_PTR |
9907 | 117 get_frame (void) |
118 { | |
27399
22e4449438ff
(get_frame, w32_console_mouse_position, mouse_moved_to):
Jason Rumney <jasonr@gnu.org>
parents:
24937
diff
changeset
|
119 return SELECTED_FRAME (); |
9907 | 120 } |
121 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
122 /* Translate console modifiers to emacs modifiers. |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
123 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
|
124 int |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
125 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
|
126 { |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
127 int retval = 0; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
128 |
21611
1a4fc4d9ca9a
(Vw32_recognize_altgr): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19710
diff
changeset
|
129 /* 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
|
130 pressed, first remove those modifiers. */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
131 if (!NILP (Vw32_recognize_altgr) |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
132 && (mods & (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED)) |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
133 == (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
134 mods &= ~ (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED); |
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 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
|
137 retval = ((NILP (Vw32_alt_is_meta)) ? alt_modifier : meta_modifier); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
138 |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
139 if (mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
140 { |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
141 retval |= ctrl_modifier; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
142 if ((mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
143 == (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
144 retval |= meta_modifier; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
145 } |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
146 |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
147 if (mods & LEFT_WIN_PRESSED) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
148 retval |= w32_key_to_modifier (VK_LWIN); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
149 if (mods & RIGHT_WIN_PRESSED) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
150 retval |= w32_key_to_modifier (VK_RWIN); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
151 if (mods & APPS_PRESSED) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
152 retval |= w32_key_to_modifier (VK_APPS); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
153 if (mods & SCROLLLOCK_ON) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
154 retval |= w32_key_to_modifier (VK_SCROLL); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
155 |
96376
c3309dba6542
American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents:
94963
diff
changeset
|
156 /* Just in case someone wanted the original behavior, make it |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
157 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
|
158 if (NILP (Vw32_capslock_is_shiftlock) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
159 /* 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
|
160 && ( (key == VK_BACK) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
161 || (key == VK_TAB) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
162 || (key == VK_CLEAR) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
163 || (key == VK_RETURN) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
164 || (key == VK_ESCAPE) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
165 || ((key >= VK_SPACE) && (key <= VK_HELP)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
166 || ((key >= VK_NUMPAD0) && (key <= VK_F24)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
167 || ((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
|
168 )) |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
169 { |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
170 /* Only consider shift state. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
171 if ((mods & SHIFT_PRESSED) != 0) |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
172 retval |= shift_modifier; |
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
173 } |
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
174 else |
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
175 { |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
176 /* Ignore CapsLock state if not enabled. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
177 if (NILP (Vw32_enable_caps_lock)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
178 mods &= ~CAPSLOCK_ON; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
179 if ((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) != 0) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
180 retval |= shift_modifier; |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
181 } |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
182 |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
183 return retval; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
184 } |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
185 |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
186 #if 0 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
187 /* 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
|
188 static int |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
189 is_dead_key (int wparam) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
190 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
191 unsigned int code = MapVirtualKey (wparam, 2); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
192 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
193 /* Windows 95 returns 0x8000, NT returns 0x80000000. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
194 return (code & 0x80008000) ? 1 : 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
195 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
196 #endif |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
197 |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
198 /* 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
|
199 int |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15784
diff
changeset
|
200 w32_kbd_patch_key (KEY_EVENT_RECORD *event) |
9907 | 201 { |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
202 unsigned int key_code = event->wVirtualKeyCode; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
203 unsigned int mods = event->dwControlKeyState; |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
204 BYTE keystate[256]; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
205 static BYTE ansi_code[4]; |
15144
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
206 static int isdead = 0; |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
207 |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
208 if (isdead == 2) |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
209 { |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
210 event->uChar.AsciiChar = ansi_code[2]; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
211 isdead = 0; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
212 return 1; |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
213 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
214 if (event->uChar.AsciiChar != 0) |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
215 return 1; |
14463
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
216 |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
217 memset (keystate, 0, sizeof (keystate)); |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
218 keystate[key_code] = 0x80; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
219 if (mods & SHIFT_PRESSED) |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
220 keystate[VK_SHIFT] = 0x80; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
221 if (mods & CAPSLOCK_ON) |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
222 keystate[VK_CAPITAL] = 1; |
21611
1a4fc4d9ca9a
(Vw32_recognize_altgr): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19710
diff
changeset
|
223 /* 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
|
224 states accordingly before invoking ToAscii. */ |
1a4fc4d9ca9a
(Vw32_recognize_altgr): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19710
diff
changeset
|
225 if (!NILP (Vw32_recognize_altgr) |
1a4fc4d9ca9a
(Vw32_recognize_altgr): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19710
diff
changeset
|
226 && (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
|
227 { |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
228 keystate[VK_CONTROL] = 0x80; |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
229 keystate[VK_LCONTROL] = 0x80; |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
230 keystate[VK_MENU] = 0x80; |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
231 keystate[VK_RMENU] = 0x80; |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
232 } |
24e5bd545f4d
(win32_kbd_mods_to_emacs, win32_kbd_patch_key,
Geoff Voelker <voelker@cs.washington.edu>
parents:
14245
diff
changeset
|
233 |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
234 #if 0 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
235 /* 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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 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
|
241 otherwise ToAscii wouldn't crash). */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
242 if (is_dead_key (event->wVirtualKeyCode)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
243 return 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
244 #endif |
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 /* 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
|
247 locale's default codepage. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
248 if (os_subtype == OS_NT) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
249 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
250 WCHAR buf[128]; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
251 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
252 isdead = ToUnicode (event->wVirtualKeyCode, event->wVirtualScanCode, |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
253 keystate, buf, 128, 0); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
254 if (isdead > 0) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
255 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
256 char cp[20]; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
257 int cpId; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
258 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
259 GetLocaleInfo (GetThreadLocale (), |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
260 LOCALE_IDEFAULTANSICODEPAGE, cp, 20); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
261 cpId = atoi (cp); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
262 isdead = WideCharToMultiByte (cpId, 0, buf, isdead, |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
263 ansi_code, 4, NULL, NULL); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
264 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
265 else |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
266 isdead = 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
267 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
268 else |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
269 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
270 isdead = ToAscii (event->wVirtualKeyCode, event->wVirtualScanCode, |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
271 keystate, (LPWORD) ansi_code, 0); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
272 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
273 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
274 if (isdead == 0) |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
275 return 0; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
276 event->uChar.AsciiChar = ansi_code[0]; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
277 return isdead; |
9907 | 278 } |
15144
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
279 |
9907 | 280 |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
281 extern char *lispy_function_keys[]; |
9907 | 282 |
23804
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
283 static int faked_key = 0; |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
284 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
285 /* return code -1 means that event_queue_ptr won't be incremented. |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
286 In other word, this event makes two key codes. (by himi) */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
287 int |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
288 key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead) |
9907 | 289 { |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
290 static int mod_key_state = 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
291 int wParam; |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
292 |
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
293 *isdead = 0; |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
294 |
9907 | 295 /* Skip key-up events. */ |
15144
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
296 if (!event->bKeyDown) |
9907 | 297 { |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
298 switch (event->wVirtualKeyCode) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
299 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
300 case VK_LWIN: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
301 mod_key_state &= ~LEFT_WIN_PRESSED; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
302 break; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
303 case VK_RWIN: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
304 mod_key_state &= ~RIGHT_WIN_PRESSED; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
305 break; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
306 case VK_APPS: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
307 mod_key_state &= ~APPS_PRESSED; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
308 break; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
309 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
310 return 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
311 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
312 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
313 /* Ignore keystrokes we fake ourself; see below. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
314 if (faked_key == event->wVirtualKeyCode) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
315 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
316 faked_key = 0; |
9907 | 317 return 0; |
318 } | |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
319 |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
320 /* 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
|
321 switch (event->wVirtualKeyCode) |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
322 { |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
323 case VK_LWIN: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
324 if (NILP (Vw32_pass_lwindow_to_system)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
325 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
326 /* 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
|
327 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
|
328 Space which we will ignore. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
329 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
|
330 { |
23804
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
331 if (NUMBERP (Vw32_phantom_key_code)) |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
332 faked_key = XUINT (Vw32_phantom_key_code) & 255; |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
333 else |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
334 faked_key = VK_SPACE; |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
335 keybd_event (faked_key, (BYTE) MapVirtualKey (faked_key, 0), 0, 0); |
23679
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 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
338 mod_key_state |= LEFT_WIN_PRESSED; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
339 if (!NILP (Vw32_lwindow_modifier)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
340 return 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
341 break; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
342 case VK_RWIN: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
343 if (NILP (Vw32_pass_rwindow_to_system)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
344 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
345 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
|
346 { |
23804
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
347 if (NUMBERP (Vw32_phantom_key_code)) |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
348 faked_key = XUINT (Vw32_phantom_key_code) & 255; |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
349 else |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
350 faked_key = VK_SPACE; |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
351 keybd_event (faked_key, (BYTE) MapVirtualKey (faked_key, 0), 0, 0); |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
352 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
353 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
354 mod_key_state |= RIGHT_WIN_PRESSED; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
355 if (!NILP (Vw32_rwindow_modifier)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
356 return 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
357 break; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
358 case VK_APPS: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
359 mod_key_state |= APPS_PRESSED; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
360 if (!NILP (Vw32_apps_modifier)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
361 return 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
362 break; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
363 case VK_CAPITAL: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
364 /* 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
|
365 if (NILP (Vw32_enable_caps_lock)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
366 goto disable_lock_key; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
367 return 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
368 case VK_NUMLOCK: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
369 /* 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
|
370 if (NILP (Vw32_enable_num_lock)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
371 goto disable_lock_key; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
372 return 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
373 case VK_SCROLL: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
374 /* 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
|
375 if (NILP (Vw32_scroll_lock_modifier)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
376 goto disable_lock_key; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
377 return 0; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
378 disable_lock_key: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
379 /* 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
|
380 indicator light as well). */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
381 wParam = event->wVirtualKeyCode; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
382 if (GetAsyncKeyState (wParam) & 0x8000) |
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 /* 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
|
385 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
|
386 faked_key = wParam; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
387 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
|
388 KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
389 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
|
390 KEYEVENTF_EXTENDEDKEY | 0, 0); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
391 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
|
392 KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
393 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
394 break; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
395 case VK_MENU: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
396 case VK_CONTROL: |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
397 case VK_SHIFT: |
9907 | 398 return 0; |
23804
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
399 case VK_CANCEL: |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
400 /* Windows maps Ctrl-Pause (aka Ctrl-Break) into VK_CANCEL, |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
401 which is confusing for purposes of key binding; convert |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
402 VK_CANCEL events into VK_PAUSE events. */ |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
403 event->wVirtualKeyCode = VK_PAUSE; |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
404 break; |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
405 case VK_PAUSE: |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
406 /* Windows maps Ctrl-NumLock into VK_PAUSE, which is confusing |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
407 for purposes of key binding; convert these back into |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
408 VK_NUMLOCK events, at least when we want to see NumLock key |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
409 presses. (Note that there is never any possibility that |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
410 VK_PAUSE with Ctrl really is C-Pause as per above.) */ |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
411 if (NILP (Vw32_enable_num_lock) |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
412 && (event->dwControlKeyState |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
413 & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) != 0) |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
414 event->wVirtualKeyCode = VK_NUMLOCK; |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
415 break; |
9907 | 416 } |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
417 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
418 /* Recognize state of Windows and Apps keys. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
419 event->dwControlKeyState |= mod_key_state; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
420 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
421 /* Distinguish numeric keypad keys from extended keys. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
422 event->wVirtualKeyCode = |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
423 map_keypad_keys (event->wVirtualKeyCode, |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
424 (event->dwControlKeyState & ENHANCED_KEY)); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
425 |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
426 if (lispy_function_keys[event->wVirtualKeyCode] == 0) |
9907 | 427 { |
45804 | 428 emacs_ev->kind = ASCII_KEYSTROKE_EVENT; |
23679
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 (!NILP (Vw32_recognize_altgr) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
431 && (event->dwControlKeyState & LEFT_CTRL_PRESSED) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
432 && (event->dwControlKeyState & RIGHT_ALT_PRESSED)) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
433 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
434 /* 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
|
435 to process them correctly. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
436 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
437 /* 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
|
438 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
|
439 possible. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
440 else if (event->dwControlKeyState |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
441 & ( RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
442 | RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
443 | (!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
|
444 | (!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
|
445 | (!NILP (Vw32_apps_modifier) ? APPS_PRESSED : 0) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
446 | (!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
|
447 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
448 /* 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
|
449 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
|
450 meta keystrokes when the normal layout translates |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
451 alphabetic characters to non-ascii characters. */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
452 if ('A' <= event->wVirtualKeyCode && event->wVirtualKeyCode <= 'Z') |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
453 { |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
454 event->uChar.AsciiChar = event->wVirtualKeyCode; |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
455 if ((event->dwControlKeyState & SHIFT_PRESSED) == 0) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
456 event->uChar.AsciiChar += ('a' - 'A'); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
457 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
458 /* 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
|
459 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
|
460 modifier). */ |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
461 else if (event->uChar.AsciiChar == 0) |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
462 w32_kbd_patch_key (event); |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
463 } |
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
464 if (event->uChar.AsciiChar == 0) |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
465 return 0; |
55640
773eb057811d
(w32_console_mouse_position, do_mouse_event, key_event): Don't mix
Jason Rumney <jasonr@gnu.org>
parents:
54169
diff
changeset
|
466 emacs_ev->code = event->uChar.AsciiChar; |
9907 | 467 } |
468 else | |
469 { | |
45804 | 470 emacs_ev->kind = NON_ASCII_KEYSTROKE_EVENT; |
55640
773eb057811d
(w32_console_mouse_position, do_mouse_event, key_event): Don't mix
Jason Rumney <jasonr@gnu.org>
parents:
54169
diff
changeset
|
471 emacs_ev->code = event->wVirtualKeyCode; |
9907 | 472 } |
23679
3d02c8b4b525
Include w32term.h and w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21829
diff
changeset
|
473 |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
474 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
|
475 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
|
476 event->wVirtualKeyCode); |
9907 | 477 emacs_ev->timestamp = GetTickCount (); |
478 return 1; | |
479 } | |
480 | |
23804
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
481 int |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
482 w32_console_toggle_lock_key (int vk_code, Lisp_Object new_state) |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
483 { |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
484 int cur_state = (GetKeyState (vk_code) & 1); |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
485 |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
486 if (NILP (new_state) |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
487 || (NUMBERP (new_state) |
35284
712561c30aa5
(w32_console_toggle_lock_key): Add parentheses.
Jason Rumney <jasonr@gnu.org>
parents:
31113
diff
changeset
|
488 && ((XUINT (new_state)) & 1) != cur_state)) |
23804
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
489 { |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
490 faked_key = vk_code; |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
491 |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
492 keybd_event ((BYTE) vk_code, |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
493 (BYTE) MapVirtualKey (vk_code, 0), |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
494 KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
495 keybd_event ((BYTE) vk_code, |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
496 (BYTE) MapVirtualKey (vk_code, 0), |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
497 KEYEVENTF_EXTENDEDKEY | 0, 0); |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
498 keybd_event ((BYTE) vk_code, |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
499 (BYTE) MapVirtualKey (vk_code, 0), |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
500 KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
501 cur_state = !cur_state; |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
502 } |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
503 |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
504 return cur_state; |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
505 } |
aa5a4d0b1591
(key_event): Use Vw32_phantom_key_code. Undo the
Geoff Voelker <voelker@cs.washington.edu>
parents:
23679
diff
changeset
|
506 |
9907 | 507 /* Mouse position hook. */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
508 void |
21829
674d44aeeda1
(w32_console_mouse_position): Rename from
Geoff Voelker <voelker@cs.washington.edu>
parents:
21611
diff
changeset
|
509 w32_console_mouse_position (FRAME_PTR *f, |
674d44aeeda1
(w32_console_mouse_position): Rename from
Geoff Voelker <voelker@cs.washington.edu>
parents:
21611
diff
changeset
|
510 int insist, |
674d44aeeda1
(w32_console_mouse_position): Rename from
Geoff Voelker <voelker@cs.washington.edu>
parents:
21611
diff
changeset
|
511 Lisp_Object *bar_window, |
674d44aeeda1
(w32_console_mouse_position): Rename from
Geoff Voelker <voelker@cs.washington.edu>
parents:
21611
diff
changeset
|
512 enum scroll_bar_part *part, |
674d44aeeda1
(w32_console_mouse_position): Rename from
Geoff Voelker <voelker@cs.washington.edu>
parents:
21611
diff
changeset
|
513 Lisp_Object *x, |
674d44aeeda1
(w32_console_mouse_position): Rename from
Geoff Voelker <voelker@cs.washington.edu>
parents:
21611
diff
changeset
|
514 Lisp_Object *y, |
674d44aeeda1
(w32_console_mouse_position): Rename from
Geoff Voelker <voelker@cs.washington.edu>
parents:
21611
diff
changeset
|
515 unsigned long *time) |
9907 | 516 { |
517 BLOCK_INPUT; | |
15144
9dd18e9e0362
(win32_kdb_patch_key): Initialize isdead.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14463
diff
changeset
|
518 |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
519 insist = insist; |
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
520 |
9907 | 521 *f = get_frame (); |
522 *bar_window = Qnil; | |
523 *part = 0; | |
27399
22e4449438ff
(get_frame, w32_console_mouse_position, mouse_moved_to):
Jason Rumney <jasonr@gnu.org>
parents:
24937
diff
changeset
|
524 SELECTED_FRAME ()->mouse_moved = 0; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
525 |
55640
773eb057811d
(w32_console_mouse_position, do_mouse_event, key_event): Don't mix
Jason Rumney <jasonr@gnu.org>
parents:
54169
diff
changeset
|
526 XSETINT(*x, movement_pos.X); |
773eb057811d
(w32_console_mouse_position, do_mouse_event, key_event): Don't mix
Jason Rumney <jasonr@gnu.org>
parents:
54169
diff
changeset
|
527 XSETINT(*y, movement_pos.Y); |
9907 | 528 *time = movement_time; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
529 |
9907 | 530 UNBLOCK_INPUT; |
531 } | |
532 | |
533 /* Remember mouse motion and notify emacs. */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
534 static void |
9907 | 535 mouse_moved_to (int x, int y) |
536 { | |
537 /* If we're in the same place, ignore it */ | |
538 if (x != movement_pos.X || y != movement_pos.Y) | |
539 { | |
27399
22e4449438ff
(get_frame, w32_console_mouse_position, mouse_moved_to):
Jason Rumney <jasonr@gnu.org>
parents:
24937
diff
changeset
|
540 SELECTED_FRAME ()->mouse_moved = 1; |
9907 | 541 movement_pos.X = x; |
542 movement_pos.Y = y; | |
543 movement_time = GetTickCount (); | |
544 } | |
545 } | |
546 | |
547 /* Consoles return button bits in a strange order: | |
548 least significant - Leftmost button | |
549 next - Rightmost button | |
550 next - Leftmost+1 | |
551 next - Leftmost+2... | |
552 | |
553 Assume emacs likes three button mice, so | |
554 Left == 0 | |
555 Middle == 1 | |
556 Right == 2 | |
557 Others increase from there. */ | |
558 | |
29319
2069f3aa4939
(NUM_TRANSLATED_MOUSE_BUTTONS): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
27515
diff
changeset
|
559 #define NUM_TRANSLATED_MOUSE_BUTTONS 3 |
2069f3aa4939
(NUM_TRANSLATED_MOUSE_BUTTONS): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
27515
diff
changeset
|
560 static int emacs_button_translation[NUM_TRANSLATED_MOUSE_BUTTONS] = |
9907 | 561 { |
29319
2069f3aa4939
(NUM_TRANSLATED_MOUSE_BUTTONS): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
27515
diff
changeset
|
562 0, 2, 1 |
9907 | 563 }; |
564 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
565 static int |
9907 | 566 do_mouse_event (MOUSE_EVENT_RECORD *event, |
567 struct input_event *emacs_ev) | |
568 { | |
569 static DWORD button_state = 0; | |
570 DWORD but_change, mask; | |
571 int i; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
572 |
9907 | 573 if (event->dwEventFlags == MOUSE_MOVED) |
574 { | |
575 /* For movement events we just note that the mouse has moved | |
576 so that emacs will generate drag events. */ | |
577 mouse_moved_to (event->dwMousePosition.X, event->dwMousePosition.Y); | |
578 return 0; | |
579 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
580 |
9907 | 581 /* It looks like the console code sends us a mouse event with |
582 dwButtonState == 0 when a window is activated. Ignore this case. */ | |
583 if (event->dwButtonState == button_state) | |
584 return 0; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
585 |
45804 | 586 emacs_ev->kind = MOUSE_CLICK_EVENT; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
587 |
9907 | 588 /* Find out what button has changed state since the last button event. */ |
589 but_change = button_state ^ event->dwButtonState; | |
590 mask = 1; | |
29319
2069f3aa4939
(NUM_TRANSLATED_MOUSE_BUTTONS): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
27515
diff
changeset
|
591 for (i = 0; mask; i++, mask <<= 1) |
9907 | 592 if (but_change & mask) |
593 { | |
29319
2069f3aa4939
(NUM_TRANSLATED_MOUSE_BUTTONS): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
27515
diff
changeset
|
594 if (i < NUM_TRANSLATED_MOUSE_BUTTONS) |
55640
773eb057811d
(w32_console_mouse_position, do_mouse_event, key_event): Don't mix
Jason Rumney <jasonr@gnu.org>
parents:
54169
diff
changeset
|
595 emacs_ev->code = emacs_button_translation[i]; |
29319
2069f3aa4939
(NUM_TRANSLATED_MOUSE_BUTTONS): New constant.
Jason Rumney <jasonr@gnu.org>
parents:
27515
diff
changeset
|
596 else |
55640
773eb057811d
(w32_console_mouse_position, do_mouse_event, key_event): Don't mix
Jason Rumney <jasonr@gnu.org>
parents:
54169
diff
changeset
|
597 emacs_ev->code = i; |
9907 | 598 break; |
599 } | |
600 | |
601 button_state = event->dwButtonState; | |
602 emacs_ev->timestamp = GetTickCount (); | |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
603 emacs_ev->modifiers = w32_kbd_mods_to_emacs (event->dwControlKeyState, 0) | |
9907 | 604 ((event->dwButtonState & mask) ? down_modifier : up_modifier); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
605 |
10007
10fc4417831d
(SET_FRAME, key_event, do_mouse_event): Use accessor macros.
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
606 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
|
607 XSETFASTINT (emacs_ev->y, event->dwMousePosition.Y); |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
608 /* 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
|
609 #ifdef MULE |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
610 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
|
611 #else |
11386
62e2ab942896
(do_mouse_event): Use XSETFASTINT.
Karl Heuer <kwzh@gnu.org>
parents:
11123
diff
changeset
|
612 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
|
613 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
614 |
9907 | 615 return 1; |
616 } | |
617 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
618 static void |
9907 | 619 resize_event (WINDOW_BUFFER_SIZE_RECORD *event) |
620 { | |
621 FRAME_PTR f = get_frame (); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
622 |
80615
ed3882ec9644
Backport of long term bug from trunk:
Jason Rumney <jasonr@gnu.org>
parents:
79759
diff
changeset
|
623 change_frame_size (f, event->dwSize.Y, event->dwSize.X, 0, 1, 0); |
9907 | 624 SET_FRAME_GARBAGED (f); |
625 } | |
626 | |
24756
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
627 static void |
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
628 maybe_generate_resize_event () |
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
629 { |
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
630 CONSOLE_SCREEN_BUFFER_INFO info; |
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
631 FRAME_PTR f = get_frame (); |
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
632 |
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
633 GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &info); |
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
634 |
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
635 /* It is okay to call this unconditionally, since it will do nothing |
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
636 if the size hasn't actually changed. */ |
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
637 change_frame_size (f, |
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
638 1 + info.srWindow.Bottom - info.srWindow.Top, |
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
639 1 + info.srWindow.Right - info.srWindow.Left, |
80615
ed3882ec9644
Backport of long term bug from trunk:
Jason Rumney <jasonr@gnu.org>
parents:
79759
diff
changeset
|
640 0, 0, 0); |
24756
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
641 } |
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
642 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
643 int |
83575
cc3d57dc8761
(w32_console_read_socket): Make first arg a frame.
Jason Rumney <jasonr@gnu.org>
parents:
75227
diff
changeset
|
644 w32_console_read_socket (struct terminal *terminal, |
cc3d57dc8761
(w32_console_read_socket): Make first arg a frame.
Jason Rumney <jasonr@gnu.org>
parents:
75227
diff
changeset
|
645 int expected, |
cc3d57dc8761
(w32_console_read_socket): Make first arg a frame.
Jason Rumney <jasonr@gnu.org>
parents:
75227
diff
changeset
|
646 struct input_event *hold_quit) |
9907 | 647 { |
648 BOOL no_events = TRUE; | |
649 int nev, ret = 0, add; | |
19710
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
650 int isdead; |
4a6b8c86ad87
Declare externs from other files.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
651 |
9907 | 652 if (interrupt_input_blocked) |
653 { | |
654 interrupt_input_pending = 1; | |
655 return -1; | |
656 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
657 |
9907 | 658 interrupt_input_pending = 0; |
659 BLOCK_INPUT; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
660 |
9907 | 661 for (;;) |
662 { | |
15784
75547616a6fe
(win32_read_socket): Never block reading from input queue.
Richard M. Stallman <rms@gnu.org>
parents:
15460
diff
changeset
|
663 nev = fill_queue (0); |
9907 | 664 if (nev <= 0) |
665 { | |
666 /* If nev == -1, there was some kind of error | |
667 If nev == 0 then waitp must be zero and no events were available | |
668 so return. */ | |
669 UNBLOCK_INPUT; | |
670 return nev; | |
671 } | |
672 | |
54169
8b5313e6b324
(w32_console_read_socket): Remove bufp_r and
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
673 while (nev > 0) |
9907 | 674 { |
54169
8b5313e6b324
(w32_console_read_socket): Remove bufp_r and
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
675 struct input_event inev; |
8b5313e6b324
(w32_console_read_socket): Remove bufp_r and
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
676 |
8b5313e6b324
(w32_console_read_socket): Remove bufp_r and
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
677 EVENT_INIT (inev); |
8b5313e6b324
(w32_console_read_socket): Remove bufp_r and
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
678 inev.kind = NO_EVENT; |
8b5313e6b324
(w32_console_read_socket): Remove bufp_r and
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
679 inev.arg = Qnil; |
8b5313e6b324
(w32_console_read_socket): Remove bufp_r and
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
680 |
9907 | 681 switch (queue_ptr->EventType) |
682 { | |
683 case KEY_EVENT: | |
54169
8b5313e6b324
(w32_console_read_socket): Remove bufp_r and
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
684 add = key_event (&queue_ptr->Event.KeyEvent, &inev, &isdead); |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
685 if (add == -1) /* 95.7.25 by himi */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
686 { |
14245
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
687 queue_ptr--; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
688 add = 1; |
59d24d42958a
(WIN32_KEY_SHIFTED): Macro undefined.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
689 } |
54169
8b5313e6b324
(w32_console_read_socket): Remove bufp_r and
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
690 if (add) |
8b5313e6b324
(w32_console_read_socket): Remove bufp_r and
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
691 kbd_buffer_store_event_hold (&inev, hold_quit); |
9907 | 692 break; |
693 | |
694 case MOUSE_EVENT: | |
54169
8b5313e6b324
(w32_console_read_socket): Remove bufp_r and
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
695 add = do_mouse_event (&queue_ptr->Event.MouseEvent, &inev); |
8b5313e6b324
(w32_console_read_socket): Remove bufp_r and
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
696 if (add) |
8b5313e6b324
(w32_console_read_socket): Remove bufp_r and
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
697 kbd_buffer_store_event_hold (&inev, hold_quit); |
9907 | 698 break; |
699 | |
700 case WINDOW_BUFFER_SIZE_EVENT: | |
24937
42f29912dc46
(w32_console_read_socket): Use new variable w32_use_full_screen_buffer.
Andrew Innes <andrewi@gnu.org>
parents:
24756
diff
changeset
|
701 if (w32_use_full_screen_buffer) |
42f29912dc46
(w32_console_read_socket): Use new variable w32_use_full_screen_buffer.
Andrew Innes <andrewi@gnu.org>
parents:
24756
diff
changeset
|
702 resize_event (&queue_ptr->Event.WindowBufferSizeEvent); |
9907 | 703 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
704 |
9907 | 705 case MENU_EVENT: |
706 case FOCUS_EVENT: | |
707 /* Internal event types, ignored. */ | |
708 break; | |
709 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45804
diff
changeset
|
710 |
9907 | 711 queue_ptr++; |
712 nev--; | |
713 } | |
714 | |
715 if (ret > 0 || expected == 0) | |
716 break; | |
717 } | |
24756
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
718 |
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
719 /* We don't get told about changes in the window size (only the buffer |
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
720 size, which we no longer care about), so we have to check it |
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
721 periodically. */ |
24937
42f29912dc46
(w32_console_read_socket): Use new variable w32_use_full_screen_buffer.
Andrew Innes <andrewi@gnu.org>
parents:
24756
diff
changeset
|
722 if (!w32_use_full_screen_buffer) |
42f29912dc46
(w32_console_read_socket): Use new variable w32_use_full_screen_buffer.
Andrew Innes <andrewi@gnu.org>
parents:
24756
diff
changeset
|
723 maybe_generate_resize_event (); |
24756
4582b492a651
(maybe_generate_resize_event): Detect changes in the
Andrew Innes <andrewi@gnu.org>
parents:
23804
diff
changeset
|
724 |
9907 | 725 UNBLOCK_INPUT; |
726 return ret; | |
727 } | |
52401 | 728 |
729 /* arch-tag: 0bcb39b7-d085-4b85-9070-6750e8c03047 | |
730 (do not change this comment) */ |