annotate src/msw-proc.c @ 245:51092a27c943 r20-5b21

Import from CVS: tag r20-5b21
author cvs
date Mon, 13 Aug 2007 10:17:54 +0200
parents 41f2f0e326e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1 /* mswindows specific event-handling.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
2 Copyright (C) 1997 Jonathan Harris.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
3
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
4 This file is part of XEmacs.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
5
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
9 later version.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
10
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
14 for more details.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
15
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
20
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
21 /* Synched up with: Not in FSF. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
22
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
23 /* Authorship:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
24
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
25 Jonathan Harris, November 1997 for 20.4.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
26 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
27
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
28 #include <config.h>
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
29 #include "lisp.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
30
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
31 #include "console-msw.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
32 #include "device.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
33 #include "frame.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
34 #include "events.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
35 #include "event-msw.h"
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
36 #include "redisplay.h"
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
37
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
38 #ifdef HAVE_SCROLLBARS
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
39 # include "scrollbar-msw.h"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
40 #endif
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
41
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
42 #ifdef HAVE_MENUBARS
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
43 # include "menubar-msw.h"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
44 #endif
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
45
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
46 #ifdef DEBUG_XEMACS
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
47 # include "opaque.h" /* For the debug functions at the end of this file */
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
48 # undef DEBUG_MESSAGES
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
49 # undef DEBUG_TIMEOUTS
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
50 #endif
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
51
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
52 #ifdef HAVE_MENUBARS
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
53 #define ADJR_MENUFLAG TRUE
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
54 #else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
55 #define ADJR_MENUFLAG FALSE
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
56 #endif
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
57
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
58 /* Timer ID used for button2 emulation */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
59 #define BUTTON_2_TIMER_ID 1
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
60
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
61 static Lisp_Object mswindows_find_frame (HWND hwnd);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
62 static Lisp_Object mswindows_find_console (HWND hwnd);
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
63 static Lisp_Object mswindows_key_to_emacs_keysym(int mswindows_key, int mods);
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
64 static int mswindows_modifier_state (BYTE* keymap, int has_AltGr);
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 239
diff changeset
65 #if 0 /* NOTUSED */
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
66 static int mswindows_enqueue_timeout (int milliseconds);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
67 static void mswindows_dequeue_timeout (int interval_id);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
68
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
69 /* Timeout queue */
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
70 struct mswindows_timeout
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
71 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
72 int ticks;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
73 int interval_id;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
74 struct mswindows_timeout *next;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
75 };
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
76 typedef struct mswindows_timeout mswindows_timeout;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
77 static mswindows_timeout timeout_pool[MSW_TIMEOUT_MAX];
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
78 static mswindows_timeout *timeout_head = NULL;
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 239
diff changeset
79
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
80 static int timeout_mswindows_id;
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 239
diff changeset
81 #endif
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
82
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
83 /*----------------------------------------------------------------------------*/
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
84 /* Enqueue helpers */
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
85 /*----------------------------------------------------------------------------*/
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
86
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
87 void
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
88 mswindows_enqueue_magic_event (HWND hwnd, UINT message)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
89 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
90 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
91 struct Lisp_Event* event = XEVENT (emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
92
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
93 event->channel = mswindows_find_frame (hwnd);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
94 event->timestamp = GetMessageTime();
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
95 event->event_type = magic_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
96 EVENT_MSWINDOWS_MAGIC_TYPE (event) = message;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
97
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
98 mswindows_enqueue_dispatch_event (emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
99 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
100
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
101 static void
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
102 mswindows_enqueue_mouse_button_event (HWND hwnd, UINT message, POINTS where, DWORD when)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
103 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
104
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
105 /* We always use last message time, because mouse button
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
106 events may get delayed, and XEmacs double click
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
107 recognition will fail */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
108
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
109 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
110 struct Lisp_Event* event = XEVENT(emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
111
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
112 event->channel = mswindows_find_frame(hwnd);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
113 event->timestamp = when;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
114 event->event.button.button =
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
115 (message==WM_LBUTTONDOWN || message==WM_LBUTTONUP) ? 1 :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
116 ((message==WM_RBUTTONDOWN || message==WM_RBUTTONUP) ? 3 : 2);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
117 event->event.button.x = where.x;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
118 event->event.button.y = where.y;
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
119 event->event.button.modifiers = mswindows_modifier_state (NULL, 0);
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
120
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
121 if (message==WM_LBUTTONDOWN || message==WM_MBUTTONDOWN ||
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
122 message==WM_RBUTTONDOWN)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
123 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
124 event->event_type = button_press_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
125 SetCapture (hwnd);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
126 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
127 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
128 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
129 event->event_type = button_release_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
130 ReleaseCapture ();
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
131 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
132
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
133 mswindows_enqueue_dispatch_event (emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
134 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
135
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
136 static void
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
137 mswindows_enqueue_keypress_event (HWND hwnd, Lisp_Object keysym, int mods)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
138 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
139 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
140 struct Lisp_Event* event = XEVENT(emacs_event);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
141
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
142 event->channel = mswindows_find_console(hwnd);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
143 event->timestamp = GetMessageTime();
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
144 event->event_type = key_press_event;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
145 event->event.key.keysym = keysym;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
146 event->event.key.modifiers = mods;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
147 mswindows_enqueue_dispatch_event (emacs_event);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
148 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
149
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
150 static void
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
151 mswindows_set_chord_timer (HWND hwnd)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
152 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
153 int interval;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
154
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
155 /* We get half system threshold as it seems to
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
156 long before drag-selection is shown */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
157 if (mswindows_button2_chord_time <= 0)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
158 interval = GetDoubleClickTime () / 2;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
159 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
160 interval = mswindows_button2_chord_time;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
161
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
162 SetTimer (hwnd, BUTTON_2_TIMER_ID, interval, 0);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
163 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
164
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
165 static int
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
166 mswindows_button2_near_enough (POINTS p1, POINTS p2)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
167 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
168 int dx, dy;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
169 if (mswindows_button2_max_skew_x <= 0)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
170 dx = GetSystemMetrics (SM_CXDOUBLECLK) / 2;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
171 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
172 dx = mswindows_button2_max_skew_x;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
173
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
174 if (mswindows_button2_max_skew_y <= 0)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
175 dy = GetSystemMetrics (SM_CYDOUBLECLK) / 2;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
176 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
177 dy = mswindows_button2_max_skew_y;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
178
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
179 return abs (p1.x - p2.x) < dx && abs (p1.y- p2.y)< dy;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
180 }
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
181
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
182 static int
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
183 mswindows_current_layout_has_AltGr ()
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
184 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
185 /* This simple caching mechanism saves 10% of CPU
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
186 time when a key typed at autorepeat rate of 30 cps! */
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
187 static HKL last_hkl = 0;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
188 static int last_hkl_has_AltGr;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
189
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
190 HKL current_hkl = GetKeyboardLayout (0);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
191 if (current_hkl != last_hkl)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
192 {
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
193 TCHAR c;
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
194 last_hkl_has_AltGr = 0;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
195 /* In this loop, we query whether a character requires
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
196 AltGr to be down to generate it. If at least such one
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
197 found, this means that the layout does regard AltGr */
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
198 for (c = ' '; c <= 0xFFU && c != 0 && !last_hkl_has_AltGr; ++c)
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
199 if (HIBYTE (VkKeyScan (c)) == 6)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
200 last_hkl_has_AltGr = 1;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
201 last_hkl = current_hkl;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
202 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
203 return last_hkl_has_AltGr;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
204 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
205
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
206 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
207 * The windows procedure for the window class XEMACS_CLASS
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
208 * Stuffs messages in the mswindows event queue
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
209 */
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
210 LRESULT WINAPI
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
211 mswindows_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
212 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
213 /* Note: Remember to initialise these before use */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
214 Lisp_Object emacs_event;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
215 struct Lisp_Event *event;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
216 Lisp_Object fobj;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
217 struct frame *frame;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
218 struct mswindows_frame* msframe;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
219
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
220 switch (message)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
221 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
222 case WM_ERASEBKGND:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
223 /* Erase background only during non-dynamic sizing */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
224 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
225 if (msframe->sizing && !mswindows_dynamic_frame_resize)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
226 goto defproc;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
227 return 1;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
228
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
229 case WM_CLOSE:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
230 fobj = mswindows_find_frame (hwnd);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
231 enqueue_misc_user_event (fobj, Qeval, list3 (Qdelete_frame, fobj, Qt));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
232 mswindows_enqueue_magic_event (hwnd, XM_BUMPQUEUE);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
233 break;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
234
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
235 case WM_KEYDOWN:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
236 case WM_SYSKEYDOWN:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
237 {
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
238 BYTE keymap[256];
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
239 int has_AltGr = mswindows_current_layout_has_AltGr ();
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
240 int mods;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
241 Lisp_Object keysym;
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
242
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
243 GetKeyboardState (keymap);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
244 mods = mswindows_modifier_state (keymap, has_AltGr);
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
245
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
246 /* Handle those keys that TranslateMessage won't generate a WM_CHAR for */
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
247 if (!NILP (keysym = mswindows_key_to_emacs_keysym(wParam, mods)))
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
248 mswindows_enqueue_keypress_event (hwnd, keysym, mods);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
249 else
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
250 {
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
251 int quit_ch = CONSOLE_QUIT_CHAR (XCONSOLE (mswindows_find_console (hwnd)));
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
252 BYTE keymap_orig[256];
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 239
diff changeset
253 MSG msg = { hwnd, message, wParam, lParam, GetMessageTime(), (GetMessagePos()) };
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
254 memcpy (keymap_orig, keymap, 256);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
255
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
256 /* Clear control and alt modifiers out of the keymap */
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
257 keymap [VK_RCONTROL] = 0;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
258 keymap [VK_LMENU] = 0;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
259 if (!has_AltGr || !(keymap [VK_LCONTROL] & 0x80) || !(keymap [VK_RMENU] & 0x80))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
260 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
261 keymap [VK_LCONTROL] = 0;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
262 keymap [VK_CONTROL] = 0;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
263 keymap [VK_RMENU] = 0;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
264 keymap [VK_MENU] = 0;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
265 }
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
266 SetKeyboardState (keymap);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
267
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
268 /* Have some WM_[SYS]CHARS in the queue */
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
269 TranslateMessage (&msg);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
270
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
271 while (PeekMessage (&msg, hwnd, WM_CHAR, WM_CHAR, PM_REMOVE)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
272 ||PeekMessage (&msg, hwnd, WM_SYSCHAR, WM_SYSCHAR, PM_REMOVE))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
273 {
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
274 int ch = msg.wParam;
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
275 /* CH is a character code for the key:
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
276 'C' for Shift+C and Ctrl+Shift+C
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
277 'c' for c and Ctrl+c */
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
278
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
279 /* #### If locale is not C, US or other latin-1,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
280 isalpha() maybe not what do we mean */
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
281
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
282 /* XEmacs doesn't seem to like Shift on non-alpha keys */
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
283 if (!isalpha(ch))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
284 mods &= ~MOD_SHIFT;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
285
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
286 /* Un-capitalise alpha control keys */
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
287 if ((mods & MOD_CONTROL) && isalpha(ch))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
288 ch |= ('A' ^ 'a');
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
289
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
290 /* If a quit char with no modifiers other than control and
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
291 shift, then mark it with a fake modifier, which is removed
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
292 upon dequeueing the event */
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
293 /* #### This might also not withstand localization, if
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
294 quit character is not a latin-1 symbol */
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
295 if (((quit_ch < ' ' && (mods & MOD_CONTROL) && quit_ch + 'a' - 1 == ch)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
296 || (quit_ch >= ' ' && !(mods & MOD_CONTROL) && quit_ch == ch))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
297 && ((mods & ~(MOD_CONTROL | MOD_SHIFT)) == 0))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
298 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
299 mods |= FAKE_MOD_QUIT;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
300 ++mswindows_quit_chars_count;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
301 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
302
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
303 mswindows_enqueue_keypress_event (hwnd, make_char(ch), mods);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
304 } /* while */
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
305 SetKeyboardState (keymap_orig);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
306 } /* else */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
307 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
308 goto defproc;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
309
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
310 case WM_MBUTTONDOWN:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
311 case WM_MBUTTONUP:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
312 /* Real middle mouse button has nothing to do with emulated one:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
313 if one wants to exercise fingers playing chords on the mouse,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
314 he is allowed to do that! */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
315 mswindows_enqueue_mouse_button_event (hwnd, message,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
316 MAKEPOINTS (lParam), GetMessageTime());
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
317 break;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
318
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
319 case WM_LBUTTONUP:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
320 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
321 msframe->last_click_time = GetMessageTime();
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
322
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
323 KillTimer (hwnd, BUTTON_2_TIMER_ID);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
324 msframe->button2_need_lbutton = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
325 if (msframe->ignore_next_lbutton_up)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
326 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
327 msframe->ignore_next_lbutton_up = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
328 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
329 else if (msframe->button2_is_down)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
330 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
331 msframe->button2_is_down = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
332 msframe->ignore_next_rbutton_up = 1;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
333 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONUP,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
334 MAKEPOINTS (lParam), GetMessageTime());
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
335 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
336 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
337 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
338 if (msframe->button2_need_rbutton)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
339 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
340 msframe->button2_need_rbutton = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
341 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
342 MAKEPOINTS (lParam), GetMessageTime());
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
343 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
344 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONUP,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
345 MAKEPOINTS (lParam), GetMessageTime());
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
346 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
347 break;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
348
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
349 case WM_RBUTTONUP:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
350 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
351 msframe->last_click_time = GetMessageTime();
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
352
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
353 KillTimer (hwnd, BUTTON_2_TIMER_ID);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
354 msframe->button2_need_rbutton = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
355 if (msframe->ignore_next_rbutton_up)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
356 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
357 msframe->ignore_next_rbutton_up = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
358 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
359 else if (msframe->button2_is_down)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
360 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
361 msframe->button2_is_down = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
362 msframe->ignore_next_lbutton_up = 1;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
363 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONUP,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
364 MAKEPOINTS (lParam), GetMessageTime());
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
365 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
366 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
367 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
368 if (msframe->button2_need_lbutton)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
369 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
370 msframe->button2_need_lbutton = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
371 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
372 MAKEPOINTS (lParam), GetMessageTime());
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
373 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
374 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONUP,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
375 MAKEPOINTS (lParam), GetMessageTime());
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
376 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
377 break;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
378
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
379 case WM_LBUTTONDOWN:
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
380 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
381
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
382 if (msframe->button2_need_lbutton)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
383 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
384 KillTimer (hwnd, BUTTON_2_TIMER_ID);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
385 msframe->button2_need_lbutton = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
386 msframe->button2_need_rbutton = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
387 if (mswindows_button2_near_enough (msframe->last_click_point, MAKEPOINTS (lParam)))
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
388 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
389 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONDOWN,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
390 MAKEPOINTS (lParam), GetMessageTime());
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
391 msframe->button2_is_down = 1;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
392 }
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
393 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
394 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
395 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
396 msframe->last_click_point, msframe->last_click_time);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
397 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
398 MAKEPOINTS (lParam), GetMessageTime());
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
399 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
400 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
401 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
402 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
403 mswindows_set_chord_timer (hwnd);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
404 msframe->button2_need_rbutton = 1;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
405 msframe->last_click_point = MAKEPOINTS (lParam);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
406 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
407 msframe->last_click_time = GetMessageTime();
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
408 break;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
409
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
410 case WM_RBUTTONDOWN:
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
411 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
412
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
413 if (msframe->button2_need_rbutton)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
414 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
415 KillTimer (hwnd, BUTTON_2_TIMER_ID);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
416 msframe->button2_need_lbutton = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
417 msframe->button2_need_rbutton = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
418 if (mswindows_button2_near_enough (msframe->last_click_point, MAKEPOINTS (lParam)))
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
419 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
420 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONDOWN,
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
421 MAKEPOINTS (lParam), GetMessageTime());
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
422 msframe->button2_is_down = 1;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
423 }
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
424 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
425 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
426 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
427 msframe->last_click_point, msframe->last_click_time);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
428 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
429 MAKEPOINTS (lParam), GetMessageTime());
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
430 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
431 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
432 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
433 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
434 mswindows_set_chord_timer (hwnd);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
435 msframe->button2_need_lbutton = 1;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
436 msframe->last_click_point = MAKEPOINTS (lParam);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
437 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
438 msframe->last_click_time = GetMessageTime();
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
439 break;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
440
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
441 case WM_TIMER:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
442 if (wParam == BUTTON_2_TIMER_ID)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
443 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
444 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
445 KillTimer (hwnd, BUTTON_2_TIMER_ID);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
446
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
447 if (msframe->button2_need_lbutton)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
448 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
449 msframe->button2_need_lbutton = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
450 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
451 msframe->last_click_point, msframe->last_click_time);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
452 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
453 else if (msframe->button2_need_rbutton)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
454 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
455 msframe->button2_need_rbutton = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
456 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
457 msframe->last_click_point, msframe->last_click_time);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
458 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
459 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
460 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
461 assert ("Spurious timer fired" == 0);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
462 break;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
463
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
464 case WM_MOUSEMOVE:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
465 /* Optimization: don't report mouse movement while size is changind */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
466 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
467 if (!msframe->sizing)
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
468 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
469 /* When waiting for the second mouse button to finish
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
470 button2 emulation, and have moved too far, just pretend
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
471 as if timer has expired. This impoves drag-select feedback */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
472 if ((msframe->button2_need_lbutton || msframe->button2_need_rbutton)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
473 && !mswindows_button2_near_enough (msframe->last_click_point,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
474 MAKEPOINTS (lParam)))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
475 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
476 KillTimer (hwnd, BUTTON_2_TIMER_ID);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
477 SendMessage (hwnd, WM_TIMER, BUTTON_2_TIMER_ID, 0);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
478 }
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
479
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
480 emacs_event = Fmake_event (Qnil, Qnil);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
481 event = XEVENT(emacs_event);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
482
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
483 event->channel = mswindows_find_frame(hwnd);
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
484 event->timestamp = GetMessageTime();
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
485 event->event_type = pointer_motion_event;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
486 event->event.motion.x = MAKEPOINTS(lParam).x;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
487 event->event.motion.y = MAKEPOINTS(lParam).y;
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
488 event->event.motion.modifiers = mswindows_modifier_state (NULL, 0);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
489
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
490 mswindows_enqueue_dispatch_event (emacs_event);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
491 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
492 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
493
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
494 case WM_PAINT:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
495 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
496 PAINTSTRUCT paintStruct;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
497
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
498 frame = XFRAME (mswindows_find_frame (hwnd));
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
499
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
500 BeginPaint (hwnd, &paintStruct);
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
501 mswindows_redraw_exposed_area (frame,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
502 paintStruct.rcPaint.left, paintStruct.rcPaint.top,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
503 paintStruct.rcPaint.right, paintStruct.rcPaint.bottom);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
504 EndPaint (hwnd, &paintStruct);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
505 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
506 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
507
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
508 case WM_SIZE:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
509 /* We only care about this message if our size has really changed */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
510 if (wParam==SIZE_RESTORED || wParam==SIZE_MAXIMIZED || wParam==SIZE_MINIMIZED)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
511 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
512 RECT rect;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
513 int columns, rows;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
514
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
515 fobj = mswindows_find_frame (hwnd);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
516 frame = XFRAME (fobj);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
517 msframe = FRAME_MSWINDOWS_DATA (frame);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
518
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
519 /* We cannot handle frame map and unmap hooks right in
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
520 this routine, because these may throw. We queue
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
521 magic events to run these hooks instead - kkm */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
522
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
523 if (wParam==SIZE_MINIMIZED)
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
524 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
525 /* Iconified */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
526 FRAME_VISIBLE_P (frame) = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
527 mswindows_enqueue_magic_event (hwnd, XM_UNMAPFRAME);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
528 Fframe_iconified_p (fobj);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
529 }
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
530 else
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
531 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
532 int was_visible = FRAME_VISIBLE_P (frame);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
533 if (!msframe->sizing && !was_visible)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
534 mswindows_enqueue_magic_event (hwnd, XM_MAPFRAME);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
535
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
536 GetClientRect(hwnd, &rect);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
537 FRAME_VISIBLE_P(frame) = 1;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
538 FRAME_PIXWIDTH(frame) = rect.right;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
539 FRAME_PIXHEIGHT(frame) = rect.bottom;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
540 pixel_to_char_size (frame, rect.right, rect.bottom, &columns, &rows);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
541 change_frame_size (frame, rows, columns, 1);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
542
239
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 233
diff changeset
543 if (msframe->sizing && mswindows_dynamic_frame_resize)
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
544 redisplay ();
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
545 }
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
546 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
547 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
548
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
549 /* Misc magic events which only require that the frame be identified */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
550 case WM_SETFOCUS:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
551 case WM_KILLFOCUS:
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
552 mswindows_enqueue_magic_event (hwnd, message);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
553 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
554
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
555 case WM_WINDOWPOSCHANGING:
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
556 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
557 WINDOWPOS *wp = (LPWINDOWPOS) lParam;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
558 WINDOWPLACEMENT wpl = { sizeof(WINDOWPLACEMENT) };
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
559 GetWindowPlacement(hwnd, &wpl);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
560
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
561 /* Only interested if size is changing and we're not being iconified */
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
562 if ((wpl.showCmd != SW_SHOWMINIMIZED) && !(wp->flags & SWP_NOSIZE))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
563 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
564 RECT ncsize = { 0, 0, 0, 0 };
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
565 int pixwidth, pixheight;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
566 AdjustWindowRectEx (&ncsize, GetWindowLong (hwnd, GWL_STYLE),
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
567 GetMenu(hwnd) != NULL,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
568 GetWindowLong (hwnd, GWL_EXSTYLE));
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
569
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
570 round_size_to_char (XFRAME (mswindows_find_frame (hwnd)),
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
571 wp->cx - (ncsize.right - ncsize.left),
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
572 wp->cy - (ncsize.bottom - ncsize.top),
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
573 &pixwidth, &pixheight);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
574
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
575 /* Convert client sizes to window sizes */
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
576 pixwidth += (ncsize.right - ncsize.left);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
577 pixheight += (ncsize.bottom - ncsize.top);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
578
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
579 if (wpl.showCmd != SW_SHOWMAXIMIZED)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
580 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
581 /* Adjust so that the bottom or right doesn't move if it's
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
582 * the top or left that's being changed */
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
583 RECT rect;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
584 GetWindowRect (hwnd, &rect);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
585
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
586 if (rect.left != wp->x)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
587 wp->x += wp->cx - pixwidth;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
588 if (rect.top != wp->y)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
589 wp->y += wp->cy - pixheight;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
590 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
591
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
592 wp->cx = pixwidth;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
593 wp->cy = pixheight;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
594 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
595 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
596 break;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
597
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
598 case WM_ENTERSIZEMOVE:
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
599 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
600 msframe->sizing = 1;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
601 return 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
602
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
603 case WM_EXITSIZEMOVE:
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
604 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
605 msframe->sizing = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
606 /* Queue noop event */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
607 mswindows_enqueue_magic_event (hwnd, XM_BUMPQUEUE);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
608 return 0;
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
609
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
610 #ifdef HAVE_SCROLLBARS
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
611 case WM_VSCROLL:
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
612 case WM_HSCROLL:
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
613 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
614 /* Direction of scroll is determined by scrollbar instance. */
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
615 int code = (int) LOWORD(wParam);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
616 int pos = (short int) HIWORD(wParam);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
617 HWND hwndScrollBar = (HWND) lParam;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
618 mswindows_handle_scrollbar_event (hwndScrollBar, code, pos);
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
619
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
620 if (UNBOUNDP(mswindows_pump_outstanding_events()))
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
621 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
622 /* Error during event pumping - cancel scroll */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
623 SendMessage (hwndScrollBar, WM_CANCELMODE, 0, 0);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
624 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
625
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
626 break;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
627 }
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
628 #endif
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
629
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
630 #ifdef HAVE_MENUBARS
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
631 case WM_INITMENU:
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
632 if (UNBOUNDP (mswindows_handle_wm_initmenu (
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
633 (HMENU) wParam,
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
634 XFRAME (mswindows_find_frame (hwnd)))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
635 SendMessage (hwnd, WM_CANCELMODE, 0, 0);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
636 break;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
637
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
638 case WM_INITMENUPOPUP:
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
639 if (!HIWORD(lParam))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
640 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
641 if (UNBOUNDP (mswindows_handle_wm_initmenupopup (
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
642 (HMENU) wParam,
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
643 XFRAME (mswindows_find_frame (hwnd)))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
644 SendMessage (hwnd, WM_CANCELMODE, 0, 0);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
645 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
646 break;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
647
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
648 case WM_EXITMENULOOP:
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
649 if (UNBOUNDP (mswindows_handle_wm_exitmenuloop (
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
650 XFRAME (mswindows_find_frame (hwnd)))))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
651 SendMessage (hwnd, WM_CANCELMODE, 0, 0);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
652 break;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
653
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
654 #endif /* HAVE_MENUBARS */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
655
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
656 case WM_COMMAND:
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
657 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
658 WORD id = LOWORD (wParam);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
659 frame = XFRAME (mswindows_find_frame (hwnd));
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
660
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
661 #ifdef HAVE_MENUBARS
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
662 if (!NILP (mswindows_handle_wm_command (frame, id)))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
663 break;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
664 #endif
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
665
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
666 #ifdef HAVE_TOOLBARS
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
667 O Toolbar Implementor, this place may have something for you!;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
668 #endif
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
669
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
670 /* Bite me - a spurious command. No abort(), for safety */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
671 /* #### Perhaps, this message should be changed */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
672 error ("Cannot decode command. Tell kkm he's a parallelogramm, if you know"
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
673 " what does that mean!");
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
674 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
675 break;
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
676
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
677 defproc:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
678 default:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
679 return DefWindowProc (hwnd, message, wParam, lParam);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
680 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
681 return (0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
682 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
683
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
684 /* Returns the state of the modifier keys in the format expected by the
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
685 * Lisp_Event key_data, button_data and motion_data modifiers member */
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
686 int mswindows_modifier_state (BYTE* keymap, int has_AltGr)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
687 {
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
688 int mods = 0;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
689
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
690 if (keymap == NULL)
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
691 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
692 keymap = (BYTE*) alloca(256);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
693 GetKeyboardState (keymap);
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
694 has_AltGr = mswindows_current_layout_has_AltGr ();
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
695 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
696
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
697 if (has_AltGr && (keymap [VK_LCONTROL] & 0x80) && (keymap [VK_RMENU] & 0x80))
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
698 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
699 mods |= (keymap [VK_LMENU] & 0x80) ? MOD_META : 0;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
700 mods |= (keymap [VK_RCONTROL] & 0x80) ? MOD_CONTROL : 0;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
701 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
702 else
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
703 {
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
704 mods |= (keymap [VK_MENU] & 0x80) ? MOD_META : 0;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
705 mods |= (keymap [VK_CONTROL] & 0x80) ? MOD_CONTROL : 0;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
706 }
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
707
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
708 mods |= (keymap [VK_SHIFT] & 0x80) ? MOD_SHIFT : 0;
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
709
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
710 return mods;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
711 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
712
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
713 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
714 * Translate a mswindows virtual key to a keysym.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
715 * Only returns non-Qnil for keys that don't generate WM_CHAR messages
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
716 * or whose ASCII codes (like space) xemacs doesn't like.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
717 * Virtual key values are defined in winresrc.h
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
718 * XXX I'm not sure that KEYSYM("name") is the best thing to use here.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
719 */
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
720 Lisp_Object mswindows_key_to_emacs_keysym(int mswindows_key, int mods)
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
721 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
722 switch (mswindows_key)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
723 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
724 /* First the predefined ones */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
725 case VK_BACK: return QKbackspace;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
726 case VK_TAB: return QKtab;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
727 case '\n': return QKlinefeed; /* No VK_LINEFEED in winresrc.h */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
728 case VK_RETURN: return QKreturn;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
729 case VK_ESCAPE: return QKescape;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
730 case VK_SPACE: return QKspace;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
731 case VK_DELETE: return QKdelete;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
732
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
733 /* The rest */
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
734 case VK_CLEAR: return KEYSYM ("clear"); /* Should do ^L ? */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
735 case VK_PRIOR: return KEYSYM ("prior");
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
736 case VK_NEXT: return KEYSYM ("next");
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
737 case VK_END: return KEYSYM ("end");
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
738 case VK_HOME: return KEYSYM ("home");
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
739 case VK_LEFT: return KEYSYM ("left");
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
740 case VK_UP: return KEYSYM ("up");
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
741 case VK_RIGHT: return KEYSYM ("right");
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
742 case VK_DOWN: return KEYSYM ("down");
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
743 case VK_SELECT: return KEYSYM ("select");
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
744 case VK_PRINT: return KEYSYM ("print");
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
745 case VK_EXECUTE: return KEYSYM ("execute");
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
746 case VK_SNAPSHOT: return KEYSYM ("print");
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
747 case VK_INSERT: return KEYSYM ("insert");
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
748 case VK_HELP: return KEYSYM ("help");
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
749 #if 0 /* XXX What are these supposed to do? */
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
750 case VK_LWIN return KEYSYM ("");
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
751 case VK_RWIN return KEYSYM ("");
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
752 #endif
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
753 case VK_APPS: return KEYSYM ("menu");
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
754 case VK_F1: return KEYSYM ("f1");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
755 case VK_F2: return KEYSYM ("f2");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
756 case VK_F3: return KEYSYM ("f3");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
757 case VK_F4: return KEYSYM ("f4");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
758 case VK_F5: return KEYSYM ("f5");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
759 case VK_F6: return KEYSYM ("f6");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
760 case VK_F7: return KEYSYM ("f7");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
761 case VK_F8: return KEYSYM ("f8");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
762 case VK_F9: return KEYSYM ("f9");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
763 case VK_F10: return KEYSYM ("f10");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
764 case VK_F11: return KEYSYM ("f11");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
765 case VK_F12: return KEYSYM ("f12");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
766 case VK_F13: return KEYSYM ("f13");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
767 case VK_F14: return KEYSYM ("f14");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
768 case VK_F15: return KEYSYM ("f15");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
769 case VK_F16: return KEYSYM ("f16");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
770 case VK_F17: return KEYSYM ("f17");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
771 case VK_F18: return KEYSYM ("f18");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
772 case VK_F19: return KEYSYM ("f19");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
773 case VK_F20: return KEYSYM ("f20");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
774 case VK_F21: return KEYSYM ("f21");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
775 case VK_F22: return KEYSYM ("f22");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
776 case VK_F23: return KEYSYM ("f23");
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents: 219
diff changeset
777 case VK_F24: return KEYSYM ("f24");
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
778 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
779 return Qnil;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
780 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
781
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
782 /*
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
783 * Find the console that matches the supplied mswindows window handle
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
784 */
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
785 Lisp_Object
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
786 mswindows_find_console (HWND hwnd)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
787 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
788 Lisp_Object concons;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
789
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
790 CONSOLE_LOOP (concons)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
791 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
792 Lisp_Object console = XCAR (concons);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
793 /* We only support one console so this must be it */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
794 return console;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
795 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
796
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
797 return Qnil;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
798 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
799
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
800 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
801 * Find the frame that matches the supplied mswindows window handle
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
802 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
803 static Lisp_Object
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
804 mswindows_find_frame (HWND hwnd)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
805 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 221
diff changeset
806 return (Lisp_Object) GetWindowLong (hwnd, XWL_FRAMEOBJ);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
807 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
808
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
809
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
810 #ifdef DEBUG_XEMACS
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
811 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
812 * Random helper functions for debugging.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
813 * Intended for use in the MSVC "Watch" window which doesn't like
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
814 * the aborts that the error_check_foo() functions can make.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
815 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
816 struct lrecord_header *DHEADER(Lisp_Object obj)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
817 {
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
818 return (LRECORDP (obj)) ? XRECORD_LHEADER (obj) : NULL;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
819 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
820
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
821 int *DOPAQUE_DATA (Lisp_Object obj)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
822 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
823 return (OPAQUEP (obj)) ? OPAQUE_DATA (XOPAQUE (obj)) : NULL;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
824 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
825
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
826 struct Lisp_Event *DEVENT(Lisp_Object obj)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
827 {
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
828 return (EVENTP (obj)) ? XEVENT (obj) : NULL;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
829 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
830
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
831 struct Lisp_Cons *DCONS(Lisp_Object obj)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
832 {
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
833 return (CONSP (obj)) ? XCONS (obj) : NULL;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
834 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
835
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
836 Lisp_Object DCAR(Lisp_Object obj)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
837 {
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
838 return (CONSP (obj)) ? XCAR (obj) : 0;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
839 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
840
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
841 Lisp_Object DCDR(Lisp_Object obj)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
842 {
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
843 return (CONSP (obj)) ? XCDR (obj) : 0;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
844 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
845
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
846 struct Lisp_Cons *DCONSCDR(Lisp_Object obj)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
847 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
848 return ((CONSP (obj)) && (CONSP (XCDR (obj)))) ? XCONS (XCDR (obj)) : 0;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
849 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
850
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
851 Lisp_Object DCARCDR(Lisp_Object obj)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
852 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
853 return ((CONSP (obj)) && (CONSP (XCDR (obj)))) ? XCAR (XCDR (obj)) : 0;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
854 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
855
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
856 char *DSTRING(Lisp_Object obj)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
857 {
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
858 return (STRINGP (obj)) ? XSTRING_DATA (obj) : NULL;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
859 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
860
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
861 struct Lisp_Vector *DVECTOR(Lisp_Object obj)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
862 {
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
863 return (VECTORP (obj)) ? XVECTOR (obj) : NULL;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
864 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
865
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
866 struct Lisp_Symbol *DSYMBOL(Lisp_Object obj)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
867 {
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
868 return (SYMBOLP (obj)) ? XSYMBOL (obj) : NULL;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
869 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
870
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
871 char *DSYMNAME(Lisp_Object obj)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
872 {
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
873 return (SYMBOLP (obj)) ? XSYMBOL (obj)->name->_data : NULL;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
874 }
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
875
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
876 #endif