annotate src/msw-proc.c @ 225:12579d965149 r20-4b11

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