annotate src/event-msw.c @ 249:83b3d10dcba9 r20-5b23

Import from CVS: tag r20-5b23
author cvs
date Mon, 13 Aug 2007 10:19:09 +0200
parents 51092a27c943
children 677f6a0ee643
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 /* The mswindows event_stream interface.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
2 Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
3 Copyright (C) 1995 Sun Microsystems, Inc.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
4 Copyright (C) 1996 Ben Wing.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
5 Copyright (C) 1997 Jonathan Harris.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
6
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
7 This file is part of XEmacs.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
8
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
9 XEmacs is free software; you can redistribute it and/or modify it
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
11 Free Software Foundation; either version 2, or (at your option) any
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
12 later version.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
13
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
17 for more details.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
18
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
20 along with XEmacs; see the file COPYING. If not, write to
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
22 Boston, MA 02111-1307, USA. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
23
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
24 /* Synched up with: Not in FSF. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
25
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
26 /* Authorship:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
27
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
28 Ultimately based on FSF.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
29 Rewritten by Ben Wing.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
30 Rewritten for mswindows by Jonathan Harris, November 1997 for 20.4.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
31 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
32
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
33 #include <config.h>
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
34 #include "lisp.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
35
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
36 #include "console-msw.h"
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
37
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
38 #ifdef HAVE_SCROLLBARS
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
39 # include "scrollbar-msw.h"
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
40 #endif
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
41
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
42 #ifdef HAVE_MENUBARS
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
43 # include "menubar-msw.h"
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
44 #endif
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
45
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
46 #include "device.h"
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
47 #include "emacsfns.h"
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
48 #include "events.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
49 #include "frame.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
50 #include "process.h"
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
51 #include "redisplay.h"
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
52 #include "sysproc.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
53 #include "syswait.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
54 #include "systime.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
55
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
56 #include "events-mod.h"
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
57
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
58 #ifdef HAVE_MENUBARS
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
59 #define ADJR_MENUFLAG TRUE
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
60 #else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
61 #define ADJR_MENUFLAG FALSE
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
62 #endif
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
63
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
64 /* Fake key modifier which is attached to a quit char event.
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
65 Removed upon dequeueing an event */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
66 #define FAKE_MOD_QUIT 0x80
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
67
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
68 /* Timer ID used for button2 emulation */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
69 #define BUTTON_2_TIMER_ID 1
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
70
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
71 /* Drag and drop event data types (subset of types in offix-types.h) */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
72 #define DndFile 2
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
73 #define DndFiles 3
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
74 #define DndText 4
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
75
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
76
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
77 static Lisp_Object mswindows_find_frame (HWND hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
78 static Lisp_Object mswindows_find_console (HWND hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
79 static Lisp_Object mswindows_key_to_emacs_keysym(int mswindows_key, int mods);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
80 static int mswindows_modifier_state (BYTE* keymap, int has_AltGr);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
81 static void mswindows_set_chord_timer (HWND hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
82 static int mswindows_button2_near_enough (POINTS p1, POINTS p2);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
83 static int mswindows_current_layout_has_AltGr (void);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
84
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
85
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
86 static struct event_stream *mswindows_event_stream;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
87
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
88 /*
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
89 * Two separate queues, for efficiency, one (_u_) for user events, and
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
90 * another (_s_) for non-user ones. We always return events out of the
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
91 * first one until it is empty and only then proceed with the second
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
92 * one.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
93 */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
94 static Lisp_Object mswindows_u_dispatch_event_queue, mswindows_u_dispatch_event_queue_tail;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
95 static Lisp_Object mswindows_s_dispatch_event_queue, mswindows_s_dispatch_event_queue_tail;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
96
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
97 /* The number of things we can wait on */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
98 #define MAX_WAITABLE (MAXIMUM_WAIT_OBJECTS - 1)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
99
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
100 /* List of mswindows waitable handles. */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
101 static HANDLE mswindows_waitable[MAX_WAITABLE];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
102
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
103 /* Count of quit chars currently in the queue */
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
104 /* Incremented in WM_[SYS]KEYDOWN handler in the mswindows_wnd_proc()
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
105 Decremented in mswindows_dequeue_dispatch_event() */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
106 int mswindows_quit_chars_count = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
107
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
108 /* These are Lisp integers; see DEFVARS in this file for description. */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
109 int mswindows_dynamic_frame_resize;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
110 int mswindows_num_mouse_buttons;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
111 int mswindows_button2_max_skew_x;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
112 int mswindows_button2_max_skew_y;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
113 int mswindows_button2_chord_time;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
114
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
115 /* Number of wait handles */
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 239
diff changeset
116 static int mswindows_waitable_count=0;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
117
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
118 /* This is the event signaled by the event pump.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
119 See mswindows_pump_outstanding_events for comments */
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
120 static Lisp_Object mswindows_error_caught_in_modal_loop;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
121 static int mswindows_in_modal_loop;
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
122
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
123 /* Count of wound timers */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
124 static int mswindows_pending_timers_count;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
125
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
126 static int
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
127 mswindows_user_event_p (struct Lisp_Event* sevt)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
128 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
129 return (sevt->event_type == key_press_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
130 || sevt->event_type == button_press_event
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
131 || sevt->event_type == button_release_event
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
132 || sevt->event_type == dnd_drop_event);
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
133 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
134
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
135 /************************************************************************/
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
136 /* Dispatch queue management */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
137 /************************************************************************/
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
138
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
139 /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
140 * Add an emacs event to the proper dispatch queue
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
141 */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
142 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
143 mswindows_enqueue_dispatch_event (Lisp_Object event)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
144 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
145 int user_p = mswindows_user_event_p (XEVENT(event));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
146 enqueue_event (event,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
147 user_p ? &mswindows_u_dispatch_event_queue :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
148 &mswindows_s_dispatch_event_queue,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
149 user_p ? &mswindows_u_dispatch_event_queue_tail :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
150 &mswindows_s_dispatch_event_queue_tail);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
151
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
152 /* This one does not go to window procedure, hence does not
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
153 generate XM_BUMPQUEUE magic event! */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
154 PostMessage (NULL, XM_BUMPQUEUE, 0, 0);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
155 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
156
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
157 void
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
158 mswindows_enqueue_magic_event (HWND hwnd, UINT message)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
159 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
160 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
161 struct Lisp_Event* event = XEVENT (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
162
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
163 event->channel = mswindows_find_frame (hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
164 event->timestamp = GetMessageTime();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
165 event->event_type = magic_event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
166 EVENT_MSWINDOWS_MAGIC_TYPE (event) = message;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
167
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
168 mswindows_enqueue_dispatch_event (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
169 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
170
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
171 static void
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
172 mswindows_enqueue_mouse_button_event (HWND hwnd, UINT message, POINTS where, DWORD when)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
173 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
174
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
175 /* We always use last message time, because mouse button
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
176 events may get delayed, and XEmacs double click
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
177 recognition will fail */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
178
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
179 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
180 struct Lisp_Event* event = XEVENT(emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
181
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
182 event->channel = mswindows_find_frame(hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
183 event->timestamp = when;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
184 event->event.button.button =
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
185 (message==WM_LBUTTONDOWN || message==WM_LBUTTONUP) ? 1 :
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
186 ((message==WM_RBUTTONDOWN || message==WM_RBUTTONUP) ? 3 : 2);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
187 event->event.button.x = where.x;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
188 event->event.button.y = where.y;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
189 event->event.button.modifiers = mswindows_modifier_state (NULL, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
190
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
191 if (message==WM_LBUTTONDOWN || message==WM_MBUTTONDOWN ||
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
192 message==WM_RBUTTONDOWN)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
193 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
194 event->event_type = button_press_event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
195 SetCapture (hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
196 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
197 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
198 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
199 event->event_type = button_release_event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
200 ReleaseCapture ();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
201 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
202
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
203 mswindows_enqueue_dispatch_event (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
204 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
205
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
206 static void
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
207 mswindows_enqueue_keypress_event (HWND hwnd, Lisp_Object keysym, int mods)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
208 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
209 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
210 struct Lisp_Event* event = XEVENT(emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
211
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
212 event->channel = mswindows_find_console(hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
213 event->timestamp = GetMessageTime();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
214 event->event_type = key_press_event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
215 event->event.key.keysym = keysym;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
216 event->event.key.modifiers = mods;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
217 mswindows_enqueue_dispatch_event (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
218 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
219
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
220 /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
221 * Remove and return the first emacs event on the dispatch queue.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
222 * Give a preference to user events over non-user ones.
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
223 */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
224 static Lisp_Object
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
225 mswindows_dequeue_dispatch_event ()
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
226 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
227 Lisp_Object event;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
228 struct Lisp_Event* sevt;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
229
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
230 assert (!NILP(mswindows_u_dispatch_event_queue) ||
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
231 !NILP(mswindows_s_dispatch_event_queue));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
232
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
233 event = dequeue_event (
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
234 NILP(mswindows_u_dispatch_event_queue) ?
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
235 &mswindows_s_dispatch_event_queue :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
236 &mswindows_u_dispatch_event_queue,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
237 NILP(mswindows_u_dispatch_event_queue) ?
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
238 &mswindows_s_dispatch_event_queue_tail :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
239 &mswindows_u_dispatch_event_queue_tail);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
240
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
241 sevt = XEVENT(event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
242 if (sevt->event_type == key_press_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
243 && (sevt->event.key.modifiers & FAKE_MOD_QUIT))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
244 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
245 sevt->event.key.modifiers &= ~FAKE_MOD_QUIT;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
246 --mswindows_quit_chars_count;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
247 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
248
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
249 return event;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
250 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
251
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
252 /*
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
253 * Remove and return the first emacs event on the dispatch queue that matches
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
254 * the supplied event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
255 * Timeout event matches if interval_id equals to that of the given event.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
256 * Keypress event matches if logical AND between modifiers bitmask of the
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
257 * event in the queue and that of the given event is non-zero
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
258 * For all other event types, this function asserts.
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
259 */
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
260
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
261 Lisp_Object
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
262 mswindows_cancel_dispatch_event (struct Lisp_Event* match)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
263 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
264 Lisp_Object event;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
265 Lisp_Object previous_event=Qnil;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
266 int user_p = mswindows_user_event_p (match);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
267 Lisp_Object* head = user_p ? &mswindows_u_dispatch_event_queue :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
268 &mswindows_s_dispatch_event_queue;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
269 Lisp_Object* tail = user_p ? &mswindows_u_dispatch_event_queue_tail :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
270 &mswindows_s_dispatch_event_queue_tail;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
271
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
272 assert (match->event_type == timeout_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
273 || match->event_type == key_press_event);
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
274
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
275 EVENT_CHAIN_LOOP (event, *head)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
276 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
277 int found = 1;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
278 if (XEVENT_TYPE (event) != match->event_type)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
279 found = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
280 if (found && match->event_type == timeout_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
281 && (XEVENT(event)->event.timeout.interval_id !=
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
282 match->event.timeout.interval_id))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
283 found = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
284 if (found && match->event_type == key_press_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
285 && ((XEVENT(event)->event.key.modifiers &
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
286 match->event.key.modifiers) == 0))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
287 found = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
288
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
289 if (found)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
290 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
291 if (NILP (previous_event))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
292 dequeue_event (head, tail);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
293 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
294 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
295 XSET_EVENT_NEXT (previous_event, XEVENT_NEXT (event));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
296 if (EQ (*tail, event))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
297 *tail = previous_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
298 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
299
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
300 return event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
301 }
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
302 previous_event = event;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
303 }
239
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 233
diff changeset
304 return Qnil;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
305 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
306
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
307
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
308 /************************************************************************/
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
309 /* Event pump */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
310 /************************************************************************/
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
311
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
312 static Lisp_Object
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
313 mswindows_modal_loop_error_handler (Lisp_Object cons_sig_data,
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
314 Lisp_Object u_n_u_s_e_d)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
315 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
316 mswindows_error_caught_in_modal_loop = cons_sig_data;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
317 return Qunbound;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
318 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
319
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
320 Lisp_Object
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
321 mswindows_protect_modal_loop (Lisp_Object (*bfun) (Lisp_Object barg),
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
322 Lisp_Object barg)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
323 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
324 Lisp_Object tmp;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
325
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
326 ++mswindows_in_modal_loop;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
327 tmp = condition_case_1 (Qt,
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
328 bfun, barg,
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
329 mswindows_modal_loop_error_handler, Qnil);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
330 --mswindows_in_modal_loop;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
331
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
332 return tmp;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
333 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
334
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
335 void
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
336 mswindows_unmodalize_signal_maybe (void)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
337 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
338 if (!NILP (mswindows_error_caught_in_modal_loop))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
339 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
340 /* Got an error while messages were pumped while
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
341 in window procedure - have to resignal */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
342 Lisp_Object sym = XCAR (mswindows_error_caught_in_modal_loop);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
343 Lisp_Object data = XCDR (mswindows_error_caught_in_modal_loop);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
344 mswindows_error_caught_in_modal_loop = Qnil;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
345 Fsignal (sym, data);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
346 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
347 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
348
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
349 /*
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
350 * This is an unsafe part of event pump, guarded by
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
351 * condition_case. See mswindows_pump_outstanding_events
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
352 */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
353 static Lisp_Object
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
354 mswindows_unsafe_pump_events (Lisp_Object u_n_u_s_e_d)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
355 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
356 /* This function can call lisp */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
357 Lisp_Object event = Fmake_event (Qnil, Qnil);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
358 struct gcpro gcpro1;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
359 int do_redisplay = 0;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
360 GCPRO1 (event);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
361
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
362 while (detect_input_pending ())
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
363 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
364 Fnext_event (event, Qnil);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
365 Fdispatch_event (event);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
366 do_redisplay = 1;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
367 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
368
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
369 if (do_redisplay)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
370 redisplay ();
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
371
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
372 Fdeallocate_event (event);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
373 UNGCPRO;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
374
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
375 /* Qt becomes return value of mswindows_pump_outstanding_events
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
376 once we get here */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
377 return Qt;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
378 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
379
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
380 /*
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
381 * This function pumps emacs events, while available, by using
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
382 * next_message/dispatch_message loop. Errors are trapped around
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
383 * the loop so the function always returns.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
384 *
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
385 * Windows message queue is not looked into during the call,
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
386 * neither are waitable handles checked. The function pumps
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
387 * thus only dispatch events already queued, as well as those
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
388 * resulted in dispatching thereof. This is done by setting
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
389 * module local variable mswidows_in_modal_loop to nonzero.
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
390 *
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
391 * Return value is Qt if no errors was trapped, or Qunbound if
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
392 * there was an error.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
393 *
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
394 * In case of error, a cons representing the error, in the
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
395 * form (SIGNAL . DATA), is stored in the module local variable
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
396 * mswindows_error_caught_in_modal_loop. This error is signaled
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
397 * again when DispatchMessage returns. Thus, Windows internal
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
398 * modal loops are protected against throws, which are proven
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
399 * to corrupt internal Windows structures.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
400 *
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
401 * In case of success, mswindows_error_caught_in_modal_loop is
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
402 * assigned Qnil.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
403 *
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
404 * If the value of mswindows_error_caught_in_modal_loop is not
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
405 * nil already upon entry, the function just returns non-nil.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
406 * This situation means that a new event has been queued while
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
407 * cancleng mode. The event will be dequeued on the next regular
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
408 * call of next-event; the pump is off since error is caught.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
409 * The caller must *unconditionally* cancel modal loop if the
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
410 * value returned by this function is nil. Otherwise, everything
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
411 * will become frozen until the modal loop exits under normal
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
412 * condition (scrollbar drag is released, menu closed etc.)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
413 */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
414 Lisp_Object
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
415 mswindows_pump_outstanding_events (void)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
416 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
417 /* This function can call lisp */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
418
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
419 Lisp_Object result = Qt;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
420 struct gcpro gcpro1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
421 GCPRO1 (result);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
422
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
423 if (NILP(mswindows_error_caught_in_modal_loop))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
424 result = mswindows_protect_modal_loop (mswindows_unsafe_pump_events, Qnil);
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
425 UNGCPRO;
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
426 return result;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
427 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
428
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
429
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
430
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
431 static void
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
432 mswindows_drain_windows_queue ()
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
433 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
434 MSG msg;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
435 while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
436 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
437 DispatchMessage (&msg);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
438 mswindows_unmodalize_signal_maybe ();
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
439 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
440 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
441
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
442 /*
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
443 * This is a special flavour of the mswindows_need_event function,
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
444 * used while in event pump. Actually, there is only kind of events
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
445 * allowed while in event pump: a timer. An attempt to fetch any
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
446 * other event leads to a dealock, as there's no source of user input
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
447 * ('cause event pump mirrors windows modal loop, which is a sole
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
448 * owner of thread message queue).
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
449 *
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
450 * To detect this, we use a counter of active timers, and allow
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
451 * fetching WM_TIMER messages. Instead of trying to fetch a WM_TIMER
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
452 * which will never come when there are no pending timers, which leads
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
453 * to deadlock, we simply signal an error.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
454 *
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
455 * The implementation does not honor user_p by design.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
456 */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
457 static void
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
458 mswindows_need_event_in_modal_loop (int user_p, int badly_p)
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
459 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
460 MSG msg;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
461
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
462 /* Check if already have one */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
463 if (!NILP (mswindows_u_dispatch_event_queue)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
464 || !NILP (mswindows_s_dispatch_event_queue))
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
465 return;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
466
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
467 /* No event is ok */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
468 if (!badly_p)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
469 return;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
470
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
471 /* We do not check the _u_ queue, because timers go to _s_ */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
472 while (NILP (mswindows_s_dispatch_event_queue))
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
473 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
474 /* We'll deadlock if go waiting */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
475 if (mswindows_pending_timers_count == 0)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
476 error ("Deadlock due to an attempt to call next-event in a wrong context");
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
477
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
478 /* Fetch and dispatch any pending timers */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
479 GetMessage (&msg, NULL, WM_TIMER, WM_TIMER);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
480 DispatchMessage (&msg);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
481 }
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
482 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
483
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
484 /*
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
485 * This drains the event queue and fills up two internal queues until
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
486 * an event of a type specified by USER_P is retrieved.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
487 *
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
488 * If user_p, then the function drains until the first user event, or
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
489 * the first non-user event if there no user events. Otherwise, If
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
490 * not user_p, it does not give preference to user events.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
491 *
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
492 * If badly_p, then the function does not return until an event is
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
493 * available.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
494 *
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
495 * The code does not rely on MsgWaitForMultipleObjects preference for
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
496 * messages over waitable handles.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
497 *
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
498 * Used by emacs_mswindows_event_pending_p and emacs_mswindows_next_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
499 */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
500 static void
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
501 mswindows_need_event (int user_p, int badly_p)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
502 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
503 int active;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
504
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
505 if (mswindows_in_modal_loop)
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
506 {
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
507 mswindows_need_event_in_modal_loop (user_p, badly_p);
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
508 return;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
509 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
510
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
511 /* Have to drain Windows message queue first, otherwise, we may miss
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
512 quit char when called from quit_p */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
513 mswindows_drain_windows_queue ();
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
514
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
515 while (NILP (mswindows_u_dispatch_event_queue) &&
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
516 (user_p || NILP (mswindows_s_dispatch_event_queue)))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
517 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
518 /* If we already have an event, we've got someting to return - no wait! */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
519 if (!NILP (mswindows_u_dispatch_event_queue)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
520 || !NILP (mswindows_s_dispatch_event_queue))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
521 badly_p = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
522
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
523 /* Now try getting a message */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
524 active = MsgWaitForMultipleObjects (mswindows_waitable_count,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
525 mswindows_waitable,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
526 FALSE, badly_p ? INFINITE : 0,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
527 QS_ALLINPUT);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
528
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
529 /* This will assert if handle being waited for becomes abandoned.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
530 Not the case currently tho */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
531 assert ((!badly_p && active == WAIT_TIMEOUT) ||
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
532 (active >= WAIT_OBJECT_0 &&
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
533 active <= WAIT_OBJECT_0 + mswindows_waitable_count));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
534
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
535 if (active == WAIT_TIMEOUT)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
536 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
537 /* No luck trying - just return what we've already got */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
538 return;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
539 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
540 else if (active == WAIT_OBJECT_0 + mswindows_waitable_count)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
541 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
542 /* Got your message, thanks */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
543 mswindows_drain_windows_queue ();
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
544 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
545 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
546 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
547 /* XXX FIXME: We should do some kind of round-robin scheme to ensure fairness */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
548 int waitable = active - WAIT_OBJECT_0;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
549 assert(0); /* #### */
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
550 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
551 } /* while */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
552
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
553 return;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
554 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
555
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
556 /************************************************************************/
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
557 /* Event generators */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
558 /************************************************************************/
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
559
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
560 /*
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
561 * Callback procedure for synchronous timer messages
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
562 */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
563 static void CALLBACK
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
564 mswindows_wm_timer_callback (HWND hwnd, UINT umsg, UINT id_timer, DWORD dwtime)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
565 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
566 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
567 struct Lisp_Event *event = XEVENT (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
568
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
569 if (KillTimer (NULL, id_timer))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
570 --mswindows_pending_timers_count;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
571
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
572 event->channel = Qnil;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
573 event->timestamp = dwtime;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
574 event->event_type = timeout_event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
575 event->event.timeout.interval_id = id_timer;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
576
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
577 mswindows_enqueue_dispatch_event (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
578 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
579
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
580 /*
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
581 * Callback procedure for dde messages
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
582 */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
583 HDDEDATA CALLBACK
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
584 mswindows_dde_callback (UINT uType, UINT uFmt, HCONV hconv,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
585 HSZ hszTopic, HSZ hszItem, HDDEDATA hdata,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
586 DWORD dwData1, DWORD dwData2)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
587 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
588 switch (uType)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
589 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
590 case XTYP_CONNECT:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
591 if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
592 return (HDDEDATA)TRUE;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
593 return (HDDEDATA)FALSE;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
594
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
595 case XTYP_WILDCONNECT:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
596 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
597 /* We only support one {service,topic} pair */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
598 HSZPAIR pairs[2] = {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
599 { mswindows_dde_service, mswindows_dde_topic_system }, { 0, 0 } };
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
600
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
601 if (!(hszItem || DdeCmpStringHandles (hszItem, mswindows_dde_service)) &&
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
602 !(hszTopic || DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
603 return (DdeCreateDataHandle (mswindows_dde_mlid, (LPBYTE)pairs,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
604 sizeof (pairs), 0L, 0, uFmt, 0));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
605 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
606 return (HDDEDATA)NULL;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
607
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
608 case XTYP_EXECUTE:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
609 if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
610 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
611 DWORD len = DdeGetData (hdata, NULL, 0, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
612 char *cmd = alloca (len+1);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
613 char *end;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
614 Lisp_Object l_dndlist;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
615 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
616 struct Lisp_Event *event = XEVENT (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
617
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
618 DdeGetData (hdata, cmd, len, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
619 cmd[len] = '\0';
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
620 DdeFreeDataHandle (hdata);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
621
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
622 /* Check syntax & that it's an [Open("foo")] command */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
623 /* #### Ought to be generalised and accept some other commands */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
624 if (*cmd == '[')
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
625 cmd++;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
626 if (strnicmp (cmd, MSWINDOWS_DDE_ITEM_OPEN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
627 strlen (MSWINDOWS_DDE_ITEM_OPEN)))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
628 return DDE_FNOTPROCESSED;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
629 cmd += strlen (MSWINDOWS_DDE_ITEM_OPEN);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
630 while (*cmd==' ')
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
631 cmd++;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
632 if (*cmd!='(' || *(cmd+1)!='\"')
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
633 return DDE_FNOTPROCESSED;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
634 end = (cmd+=2);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
635 while (*end && *end!='\"')
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
636 end++;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
637 if (!*end)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
638 return DDE_FNOTPROCESSED;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
639 *end = '\0';
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
640 if (*(++end)!=')')
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
641 return DDE_FNOTPROCESSED;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
642 if (*(++end)==']')
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
643 end++;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
644 if (*end)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
645 return DDE_FNOTPROCESSED;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
646
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
647 l_dndlist = make_ext_string (cmd, strlen(cmd), FORMAT_FILENAME);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
648
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
649 event->channel = Qnil;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
650 event->timestamp = GetTickCount();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
651 event->event_type = dnd_drop_event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
652 event->event.dnd_drop.button = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
653 event->event.dnd_drop.modifiers = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
654 event->event.dnd_drop.x = -1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
655 event->event.dnd_drop.y = -1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
656 event->event.dnd_drop.data = Fcons (make_int (DndFile),
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
657 Fcons (l_dndlist, Qnil));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
658 mswindows_enqueue_dispatch_event (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
659
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
660 return (HDDEDATA) DDE_FACK;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
661 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
662 DdeFreeDataHandle (hdata);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
663 return (HDDEDATA) DDE_FNOTPROCESSED;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
664
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
665 default:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
666 return (HDDEDATA) NULL;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
667 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
668
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
669 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
670
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
671 /*
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
672 * The windows procedure for the window class XEMACS_CLASS
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
673 */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
674 LRESULT WINAPI
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
675 mswindows_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
676 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
677 /* Note: Remember to initialise emacs_event and event before use.
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
678 This code calls code that can GC. You must GCPRO before calling such code. */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
679 Lisp_Object emacs_event = Qnil;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
680 Lisp_Object fobj = Qnil;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
681
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
682 struct Lisp_Event *event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
683 struct frame *frame;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
684 struct mswindows_frame* msframe;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
685
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
686 switch (message)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
687 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
688 case WM_ERASEBKGND:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
689 /* Erase background only during non-dynamic sizing */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
690 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
691 if (msframe->sizing && !mswindows_dynamic_frame_resize)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
692 goto defproc;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
693 return 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
694
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
695 case WM_CLOSE:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
696 fobj = mswindows_find_frame (hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
697 enqueue_misc_user_event (fobj, Qeval, list3 (Qdelete_frame, fobj, Qt));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
698 mswindows_enqueue_magic_event (hwnd, XM_BUMPQUEUE);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
699 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
700
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
701 case WM_KEYDOWN:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
702 case WM_SYSKEYDOWN:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
703 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
704 BYTE keymap[256];
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
705 int has_AltGr = mswindows_current_layout_has_AltGr ();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
706 int mods;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
707 Lisp_Object keysym;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
708
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
709 GetKeyboardState (keymap);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
710 mods = mswindows_modifier_state (keymap, has_AltGr);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
711
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
712 /* Handle those keys that TranslateMessage won't generate a WM_CHAR for */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
713 if (!NILP (keysym = mswindows_key_to_emacs_keysym(wParam, mods)))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
714 mswindows_enqueue_keypress_event (hwnd, keysym, mods);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
715 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
716 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
717 int quit_ch = CONSOLE_QUIT_CHAR (XCONSOLE (mswindows_find_console (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
718 BYTE keymap_orig[256];
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
719 MSG msg = { hwnd, message, wParam, lParam, GetMessageTime(), (GetMessagePos()) };
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
720 memcpy (keymap_orig, keymap, 256);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
721
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
722 /* Clear control and alt modifiers out of the keymap */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
723 keymap [VK_RCONTROL] = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
724 keymap [VK_LMENU] = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
725 if (!has_AltGr || !(keymap [VK_LCONTROL] & 0x80) || !(keymap [VK_RMENU] & 0x80))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
726 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
727 keymap [VK_LCONTROL] = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
728 keymap [VK_CONTROL] = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
729 keymap [VK_RMENU] = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
730 keymap [VK_MENU] = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
731 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
732 SetKeyboardState (keymap);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
733
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
734 /* Have some WM_[SYS]CHARS in the queue */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
735 TranslateMessage (&msg);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
736
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
737 while (PeekMessage (&msg, hwnd, WM_CHAR, WM_CHAR, PM_REMOVE)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
738 ||PeekMessage (&msg, hwnd, WM_SYSCHAR, WM_SYSCHAR, PM_REMOVE))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
739 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
740 int ch = msg.wParam;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
741 /* CH is a character code for the key:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
742 'C' for Shift+C and Ctrl+Shift+C
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
743 'c' for c and Ctrl+c */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
744
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
745 /* #### If locale is not C, US or other latin-1,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
746 isalpha() maybe not what do we mean */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
747
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
748 /* XEmacs doesn't seem to like Shift on non-alpha keys */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
749 if (!isalpha(ch))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
750 mods &= ~MOD_SHIFT;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
751
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
752 /* Un-capitalise alpha control keys */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
753 if ((mods & MOD_CONTROL) && isalpha(ch))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
754 ch |= ('A' ^ 'a');
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
755
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
756 /* If a quit char with no modifiers other than control and
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
757 shift, then mark it with a fake modifier, which is removed
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
758 upon dequeueing the event */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
759 /* #### This might also not withstand localization, if
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
760 quit character is not a latin-1 symbol */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
761 if (((quit_ch < ' ' && (mods & MOD_CONTROL) && quit_ch + 'a' - 1 == ch)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
762 || (quit_ch >= ' ' && !(mods & MOD_CONTROL) && quit_ch == ch))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
763 && ((mods & ~(MOD_CONTROL | MOD_SHIFT)) == 0))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
764 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
765 mods |= FAKE_MOD_QUIT;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
766 ++mswindows_quit_chars_count;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
767 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
768
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
769 mswindows_enqueue_keypress_event (hwnd, make_char(ch), mods);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
770 } /* while */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
771 SetKeyboardState (keymap_orig);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
772 } /* else */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
773 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
774 goto defproc;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
775
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
776 case WM_MBUTTONDOWN:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
777 case WM_MBUTTONUP:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
778 /* Real middle mouse button has nothing to do with emulated one:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
779 if one wants to exercise fingers playing chords on the mouse,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
780 he is allowed to do that! */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
781 mswindows_enqueue_mouse_button_event (hwnd, message,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
782 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
783 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
784
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
785 case WM_LBUTTONUP:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
786 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
787 msframe->last_click_time = GetMessageTime();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
788
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
789 KillTimer (hwnd, BUTTON_2_TIMER_ID);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
790 msframe->button2_need_lbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
791 if (msframe->ignore_next_lbutton_up)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
792 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
793 msframe->ignore_next_lbutton_up = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
794 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
795 else if (msframe->button2_is_down)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
796 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
797 msframe->button2_is_down = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
798 msframe->ignore_next_rbutton_up = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
799 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONUP,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
800 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
801 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
802 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
803 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
804 if (msframe->button2_need_rbutton)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
805 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
806 msframe->button2_need_rbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
807 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
808 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
809 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
810 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONUP,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
811 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
812 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
813 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
814
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
815 case WM_RBUTTONUP:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
816 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
817 msframe->last_click_time = GetMessageTime();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
818
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
819 KillTimer (hwnd, BUTTON_2_TIMER_ID);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
820 msframe->button2_need_rbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
821 if (msframe->ignore_next_rbutton_up)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
822 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
823 msframe->ignore_next_rbutton_up = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
824 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
825 else if (msframe->button2_is_down)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
826 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
827 msframe->button2_is_down = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
828 msframe->ignore_next_lbutton_up = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
829 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONUP,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
830 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
831 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
832 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
833 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
834 if (msframe->button2_need_lbutton)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
835 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
836 msframe->button2_need_lbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
837 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
838 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
839 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
840 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONUP,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
841 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
842 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
843 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
844
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
845 case WM_LBUTTONDOWN:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
846 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
847
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
848 if (msframe->button2_need_lbutton)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
849 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
850 KillTimer (hwnd, BUTTON_2_TIMER_ID);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
851 msframe->button2_need_lbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
852 msframe->button2_need_rbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
853 if (mswindows_button2_near_enough (msframe->last_click_point, MAKEPOINTS (lParam)))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
854 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
855 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
856 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
857 msframe->button2_is_down = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
858 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
859 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
860 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
861 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
862 msframe->last_click_point, msframe->last_click_time);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
863 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
864 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
865 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
866 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
867 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
868 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
869 mswindows_set_chord_timer (hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
870 msframe->button2_need_rbutton = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
871 msframe->last_click_point = MAKEPOINTS (lParam);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
872 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
873 msframe->last_click_time = GetMessageTime();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
874 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
875
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
876 case WM_RBUTTONDOWN:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
877 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
878
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
879 if (msframe->button2_need_rbutton)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
880 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
881 KillTimer (hwnd, BUTTON_2_TIMER_ID);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
882 msframe->button2_need_lbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
883 msframe->button2_need_rbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
884 if (mswindows_button2_near_enough (msframe->last_click_point, MAKEPOINTS (lParam)))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
885 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
886 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
887 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
888 msframe->button2_is_down = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
889 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
890 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
891 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
892 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
893 msframe->last_click_point, msframe->last_click_time);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
894 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
895 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
896 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
897 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
898 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
899 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
900 mswindows_set_chord_timer (hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
901 msframe->button2_need_lbutton = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
902 msframe->last_click_point = MAKEPOINTS (lParam);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
903 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
904 msframe->last_click_time = GetMessageTime();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
905 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
906
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
907 case WM_TIMER:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
908 if (wParam == BUTTON_2_TIMER_ID)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
909 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
910 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
911 KillTimer (hwnd, BUTTON_2_TIMER_ID);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
912
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
913 if (msframe->button2_need_lbutton)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
914 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
915 msframe->button2_need_lbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
916 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
917 msframe->last_click_point, msframe->last_click_time);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
918 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
919 else if (msframe->button2_need_rbutton)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
920 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
921 msframe->button2_need_rbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
922 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
923 msframe->last_click_point, msframe->last_click_time);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
924 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
925 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
926 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
927 assert ("Spurious timer fired" == 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
928 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
929
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
930 case WM_MOUSEMOVE:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
931 /* Optimization: don't report mouse movement while size is changind */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
932 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
933 if (!msframe->sizing)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
934 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
935 /* When waiting for the second mouse button to finish
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
936 button2 emulation, and have moved too far, just pretend
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
937 as if timer has expired. This impoves drag-select feedback */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
938 if ((msframe->button2_need_lbutton || msframe->button2_need_rbutton)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
939 && !mswindows_button2_near_enough (msframe->last_click_point,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
940 MAKEPOINTS (lParam)))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
941 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
942 KillTimer (hwnd, BUTTON_2_TIMER_ID);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
943 SendMessage (hwnd, WM_TIMER, BUTTON_2_TIMER_ID, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
944 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
945
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
946 emacs_event = Fmake_event (Qnil, Qnil);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
947 event = XEVENT(emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
948
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
949 event->channel = mswindows_find_frame(hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
950 event->timestamp = GetMessageTime();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
951 event->event_type = pointer_motion_event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
952 event->event.motion.x = MAKEPOINTS(lParam).x;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
953 event->event.motion.y = MAKEPOINTS(lParam).y;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
954 event->event.motion.modifiers = mswindows_modifier_state (NULL, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
955
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
956 mswindows_enqueue_dispatch_event (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
957 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
958 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
959
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
960 case WM_PAINT:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
961 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
962 PAINTSTRUCT paintStruct;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
963
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
964 frame = XFRAME (mswindows_find_frame (hwnd));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
965
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
966 BeginPaint (hwnd, &paintStruct);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
967 mswindows_redraw_exposed_area (frame,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
968 paintStruct.rcPaint.left, paintStruct.rcPaint.top,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
969 paintStruct.rcPaint.right, paintStruct.rcPaint.bottom);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
970 EndPaint (hwnd, &paintStruct);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
971 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
972 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
973
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
974 case WM_SIZE:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
975 /* We only care about this message if our size has really changed */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
976 if (wParam==SIZE_RESTORED || wParam==SIZE_MAXIMIZED || wParam==SIZE_MINIMIZED)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
977 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
978 RECT rect;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
979 int columns, rows;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
980
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
981 fobj = mswindows_find_frame (hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
982 frame = XFRAME (fobj);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
983 msframe = FRAME_MSWINDOWS_DATA (frame);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
984
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
985 /* We cannot handle frame map and unmap hooks right in
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
986 this routine, because these may throw. We queue
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
987 magic events to run these hooks instead - kkm */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
988
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
989 if (wParam==SIZE_MINIMIZED)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
990 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
991 /* Iconified */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
992 FRAME_VISIBLE_P (frame) = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
993 mswindows_enqueue_magic_event (hwnd, XM_UNMAPFRAME);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
994 Fframe_iconified_p (fobj);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
995 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
996 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
997 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
998 int was_visible = FRAME_VISIBLE_P (frame);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
999 if (!msframe->sizing && !was_visible)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1000 mswindows_enqueue_magic_event (hwnd, XM_MAPFRAME);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1001
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1002 GetClientRect(hwnd, &rect);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1003 FRAME_VISIBLE_P(frame) = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1004 FRAME_PIXWIDTH(frame) = rect.right;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1005 FRAME_PIXHEIGHT(frame) = rect.bottom;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1006 pixel_to_char_size (frame, rect.right, rect.bottom, &columns, &rows);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1007 change_frame_size (frame, rows, columns, 1);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1008
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1009 if (msframe->sizing && mswindows_dynamic_frame_resize)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1010 redisplay ();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1011 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1012 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1013 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1014
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1015 /* Misc magic events which only require that the frame be identified */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1016 case WM_SETFOCUS:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1017 case WM_KILLFOCUS:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1018 mswindows_enqueue_magic_event (hwnd, message);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1019 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1020
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1021 case WM_WINDOWPOSCHANGING:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1022 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1023 WINDOWPOS *wp = (LPWINDOWPOS) lParam;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1024 WINDOWPLACEMENT wpl = { sizeof(WINDOWPLACEMENT) };
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1025 GetWindowPlacement(hwnd, &wpl);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1026
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1027 /* Only interested if size is changing and we're not being iconified */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1028 if ((wpl.showCmd != SW_SHOWMINIMIZED) && !(wp->flags & SWP_NOSIZE))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1029 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1030 RECT ncsize = { 0, 0, 0, 0 };
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1031 int pixwidth, pixheight;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1032 AdjustWindowRectEx (&ncsize, GetWindowLong (hwnd, GWL_STYLE),
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1033 GetMenu(hwnd) != NULL,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1034 GetWindowLong (hwnd, GWL_EXSTYLE));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1035
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1036 round_size_to_char (XFRAME (mswindows_find_frame (hwnd)),
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1037 wp->cx - (ncsize.right - ncsize.left),
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1038 wp->cy - (ncsize.bottom - ncsize.top),
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1039 &pixwidth, &pixheight);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1040
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1041 /* Convert client sizes to window sizes */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1042 pixwidth += (ncsize.right - ncsize.left);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1043 pixheight += (ncsize.bottom - ncsize.top);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1044
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1045 if (wpl.showCmd != SW_SHOWMAXIMIZED)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1046 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1047 /* Adjust so that the bottom or right doesn't move if it's
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1048 * the top or left that's being changed */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1049 RECT rect;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1050 GetWindowRect (hwnd, &rect);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1051
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1052 if (rect.left != wp->x)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1053 wp->x += wp->cx - pixwidth;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1054 if (rect.top != wp->y)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1055 wp->y += wp->cy - pixheight;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1056 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1057
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1058 wp->cx = pixwidth;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1059 wp->cy = pixheight;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1060 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1061 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1062 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1063
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1064 case WM_ENTERSIZEMOVE:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1065 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1066 msframe->sizing = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1067 return 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1068
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1069 case WM_EXITSIZEMOVE:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1070 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1071 msframe->sizing = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1072 /* Queue noop event */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1073 mswindows_enqueue_magic_event (hwnd, XM_BUMPQUEUE);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1074 return 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1075
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1076 #ifdef HAVE_SCROLLBARS
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1077 case WM_VSCROLL:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1078 case WM_HSCROLL:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1079 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1080 /* Direction of scroll is determined by scrollbar instance. */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1081 int code = (int) LOWORD(wParam);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1082 int pos = (short int) HIWORD(wParam);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1083 HWND hwndScrollBar = (HWND) lParam;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1084 struct gcpro gcpro1, gcpro2;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1085
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1086 mswindows_handle_scrollbar_event (hwndScrollBar, code, pos);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1087 GCPRO2 (emacs_event, fobj);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1088 if (UNBOUNDP(mswindows_pump_outstanding_events())) /* Can GC */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1089 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1090 /* Error during event pumping - cancel scroll */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1091 SendMessage (hwndScrollBar, WM_CANCELMODE, 0, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1092 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1093 UNGCPRO;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1094 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1095 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1096 #endif
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1097
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1098 #ifdef HAVE_MENUBARS
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1099 case WM_INITMENU:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1100 if (UNBOUNDP (mswindows_handle_wm_initmenu (
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1101 (HMENU) wParam,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1102 XFRAME (mswindows_find_frame (hwnd)))))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1103 SendMessage (hwnd, WM_CANCELMODE, 0, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1104 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1105
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1106 case WM_INITMENUPOPUP:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1107 if (!HIWORD(lParam))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1108 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1109 if (UNBOUNDP (mswindows_handle_wm_initmenupopup (
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1110 (HMENU) wParam,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1111 XFRAME (mswindows_find_frame (hwnd)))))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1112 SendMessage (hwnd, WM_CANCELMODE, 0, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1113 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1114 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1115
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1116 case WM_EXITMENULOOP:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1117 if (UNBOUNDP (mswindows_handle_wm_exitmenuloop (
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1118 XFRAME (mswindows_find_frame (hwnd)))))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1119 SendMessage (hwnd, WM_CANCELMODE, 0, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1120 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1121
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1122 #endif /* HAVE_MENUBARS */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1123
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1124 case WM_COMMAND:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1125 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1126 WORD id = LOWORD (wParam);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1127 frame = XFRAME (mswindows_find_frame (hwnd));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1128
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1129 #ifdef HAVE_MENUBARS
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1130 if (!NILP (mswindows_handle_wm_command (frame, id)))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1131 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1132 #endif
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1133
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1134 #ifdef HAVE_TOOLBARS
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1135 O Toolbar Implementor, this place may have something for you!;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1136 #endif
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1137
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1138 /* Bite me - a spurious command. No abort(), for safety */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1139 /* #### Perhaps, this message should be changed */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1140 error ("Cannot decode command. Tell kkm he's a parallelogramm, if you know"
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1141 " what does that mean!");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1142 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1143 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1144
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1145 case WM_DROPFILES: /* implementation ripped-off from event-Xt.c */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1146 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1147 UINT filecount, i, len;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1148 POINT point;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1149 char filename[MAX_PATH];
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1150 Lisp_Object l_type, l_dndlist = Qnil, l_item;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1151
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1152 emacs_event = Fmake_event (Qnil, Qnil);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1153 event = XEVENT(emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1154
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1155 if (!DragQueryPoint ((HANDLE) wParam, &point))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1156 point.x = point.y = -1; /* outside client area */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1157
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1158 filecount = DragQueryFile ((HANDLE) wParam, -1, NULL, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1159 if (filecount == 1)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1160 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1161 l_type = make_int (DndFile);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1162 len = DragQueryFile ((HANDLE) wParam, 0, filename, MAX_PATH);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1163 l_dndlist = make_ext_string (filename, len, FORMAT_FILENAME);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1164 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1165 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1166 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1167 l_type = make_int (DndFiles);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1168 for (i=0; i<filecount; i++)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1169 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1170 len = DragQueryFile ((HANDLE) wParam, i, filename, MAX_PATH);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1171 l_item = make_ext_string (filename, len, FORMAT_FILENAME);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1172 l_dndlist = Fcons (l_item, l_dndlist); /* reverse order */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1173 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1174 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1175 DragFinish ((HANDLE) wParam);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1176
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1177 event->channel = mswindows_find_frame(hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1178 event->timestamp = GetMessageTime();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1179 event->event_type = dnd_drop_event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1180 event->event.dnd_drop.button = 1; /* #### Should try harder */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1181 event->event.dnd_drop.modifiers = mswindows_modifier_state (NULL, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1182 event->event.dnd_drop.x = point.x;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1183 event->event.dnd_drop.y = point.y;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1184 event->event.dnd_drop.data = Fcons (l_type, Fcons (l_dndlist, Qnil));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1185
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1186 mswindows_enqueue_dispatch_event (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1187 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1188 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1189
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1190 defproc:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1191 default:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1192 return DefWindowProc (hwnd, message, wParam, lParam);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1193 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1194 return (0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1195 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1196
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1197
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1198 /************************************************************************/
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1199 /* keyboard, mouse & other helpers for the windows procedure */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1200 /************************************************************************/
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1201 static void
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1202 mswindows_set_chord_timer (HWND hwnd)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1203 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1204 int interval;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1205
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1206 /* We get half system threshold as it seems to
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1207 long before drag-selection is shown */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1208 if (mswindows_button2_chord_time <= 0)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1209 interval = GetDoubleClickTime () / 2;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1210 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1211 interval = mswindows_button2_chord_time;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1212
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1213 SetTimer (hwnd, BUTTON_2_TIMER_ID, interval, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1214 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1215
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1216 static int
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1217 mswindows_button2_near_enough (POINTS p1, POINTS p2)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1218 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1219 int dx, dy;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1220 if (mswindows_button2_max_skew_x <= 0)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1221 dx = GetSystemMetrics (SM_CXDOUBLECLK) / 2;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1222 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1223 dx = mswindows_button2_max_skew_x;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1224
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1225 if (mswindows_button2_max_skew_y <= 0)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1226 dy = GetSystemMetrics (SM_CYDOUBLECLK) / 2;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1227 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1228 dy = mswindows_button2_max_skew_y;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1229
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1230 return abs (p1.x - p2.x) < dx && abs (p1.y- p2.y)< dy;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1231 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1232
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1233 static int
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1234 mswindows_current_layout_has_AltGr (void)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1235 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1236 /* This simple caching mechanism saves 10% of CPU
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1237 time when a key typed at autorepeat rate of 30 cps! */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1238 static HKL last_hkl = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1239 static int last_hkl_has_AltGr;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1240
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1241 HKL current_hkl = GetKeyboardLayout (0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1242 if (current_hkl != last_hkl)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1243 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1244 TCHAR c;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1245 last_hkl_has_AltGr = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1246 /* In this loop, we query whether a character requires
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1247 AltGr to be down to generate it. If at least such one
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1248 found, this means that the layout does regard AltGr */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1249 for (c = ' '; c <= 0xFFU && c != 0 && !last_hkl_has_AltGr; ++c)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1250 if (HIBYTE (VkKeyScan (c)) == 6)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1251 last_hkl_has_AltGr = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1252 last_hkl = current_hkl;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1253 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1254 return last_hkl_has_AltGr;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1255 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1256
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1257
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1258 /* Returns the state of the modifier keys in the format expected by the
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1259 * Lisp_Event key_data, button_data and motion_data modifiers member */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1260 int mswindows_modifier_state (BYTE* keymap, int has_AltGr)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1261 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1262 int mods = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1263
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1264 if (keymap == NULL)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1265 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1266 keymap = (BYTE*) alloca(256);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1267 GetKeyboardState (keymap);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1268 has_AltGr = mswindows_current_layout_has_AltGr ();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1269 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1270
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1271 if (has_AltGr && (keymap [VK_LCONTROL] & 0x80) && (keymap [VK_RMENU] & 0x80))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1272 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1273 mods |= (keymap [VK_LMENU] & 0x80) ? MOD_META : 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1274 mods |= (keymap [VK_RCONTROL] & 0x80) ? MOD_CONTROL : 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1275 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1276 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1277 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1278 mods |= (keymap [VK_MENU] & 0x80) ? MOD_META : 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1279 mods |= (keymap [VK_CONTROL] & 0x80) ? MOD_CONTROL : 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1280 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1281
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1282 mods |= (keymap [VK_SHIFT] & 0x80) ? MOD_SHIFT : 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1283
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1284 return mods;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1285 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1286
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1287 /*
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1288 * Translate a mswindows virtual key to a keysym.
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1289 * Only returns non-Qnil for keys that don't generate WM_CHAR messages
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1290 * or whose ASCII codes (like space) xemacs doesn't like.
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1291 * Virtual key values are defined in winresrc.h
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1292 * XXX I'm not sure that KEYSYM("name") is the best thing to use here.
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1293 */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1294 Lisp_Object mswindows_key_to_emacs_keysym(int mswindows_key, int mods)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1295 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1296 switch (mswindows_key)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1297 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1298 /* First the predefined ones */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1299 case VK_BACK: return QKbackspace;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1300 case VK_TAB: return QKtab;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1301 case '\n': return QKlinefeed; /* No VK_LINEFEED in winresrc.h */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1302 case VK_RETURN: return QKreturn;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1303 case VK_ESCAPE: return QKescape;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1304 case VK_SPACE: return QKspace;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1305 case VK_DELETE: return QKdelete;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1306
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1307 /* The rest */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1308 case VK_CLEAR: return KEYSYM ("clear"); /* Should do ^L ? */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1309 case VK_PRIOR: return KEYSYM ("prior");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1310 case VK_NEXT: return KEYSYM ("next");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1311 case VK_END: return KEYSYM ("end");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1312 case VK_HOME: return KEYSYM ("home");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1313 case VK_LEFT: return KEYSYM ("left");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1314 case VK_UP: return KEYSYM ("up");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1315 case VK_RIGHT: return KEYSYM ("right");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1316 case VK_DOWN: return KEYSYM ("down");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1317 case VK_SELECT: return KEYSYM ("select");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1318 case VK_PRINT: return KEYSYM ("print");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1319 case VK_EXECUTE: return KEYSYM ("execute");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1320 case VK_SNAPSHOT: return KEYSYM ("print");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1321 case VK_INSERT: return KEYSYM ("insert");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1322 case VK_HELP: return KEYSYM ("help");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1323 #if 0 /* XXX What are these supposed to do? */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1324 case VK_LWIN return KEYSYM ("");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1325 case VK_RWIN return KEYSYM ("");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1326 #endif
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1327 case VK_APPS: return KEYSYM ("menu");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1328 case VK_F1: return KEYSYM ("f1");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1329 case VK_F2: return KEYSYM ("f2");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1330 case VK_F3: return KEYSYM ("f3");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1331 case VK_F4: return KEYSYM ("f4");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1332 case VK_F5: return KEYSYM ("f5");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1333 case VK_F6: return KEYSYM ("f6");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1334 case VK_F7: return KEYSYM ("f7");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1335 case VK_F8: return KEYSYM ("f8");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1336 case VK_F9: return KEYSYM ("f9");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1337 case VK_F10: return KEYSYM ("f10");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1338 case VK_F11: return KEYSYM ("f11");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1339 case VK_F12: return KEYSYM ("f12");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1340 case VK_F13: return KEYSYM ("f13");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1341 case VK_F14: return KEYSYM ("f14");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1342 case VK_F15: return KEYSYM ("f15");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1343 case VK_F16: return KEYSYM ("f16");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1344 case VK_F17: return KEYSYM ("f17");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1345 case VK_F18: return KEYSYM ("f18");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1346 case VK_F19: return KEYSYM ("f19");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1347 case VK_F20: return KEYSYM ("f20");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1348 case VK_F21: return KEYSYM ("f21");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1349 case VK_F22: return KEYSYM ("f22");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1350 case VK_F23: return KEYSYM ("f23");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1351 case VK_F24: return KEYSYM ("f24");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1352 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1353 return Qnil;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1354 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1355
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1356 /*
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1357 * Find the console that matches the supplied mswindows window handle
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1358 */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1359 Lisp_Object
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1360 mswindows_find_console (HWND hwnd)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1361 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1362 Lisp_Object concons;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1363
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1364 CONSOLE_LOOP (concons)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1365 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1366 Lisp_Object console = XCAR (concons);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1367 /* We only support one console so this must be it */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1368 return console;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1369 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1370
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1371 return Qnil;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1372 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1373
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1374 /*
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1375 * Find the frame that matches the supplied mswindows window handle
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1376 */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1377 static Lisp_Object
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1378 mswindows_find_frame (HWND hwnd)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1379 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1380 return (Lisp_Object) GetWindowLong (hwnd, XWL_FRAMEOBJ);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1381 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1382
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1383
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1384
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1385 /************************************************************************/
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1386 /* methods */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1387 /************************************************************************/
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1388
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1389 static int
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1390 emacs_mswindows_add_timeout (EMACS_TIME thyme)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1391 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1392 int milliseconds;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1393 EMACS_TIME current_time;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1394 EMACS_GET_TIME (current_time);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1395 EMACS_SUB_TIME (thyme, thyme, current_time);
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1396 milliseconds = EMACS_SECS (thyme) * 1000 +
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1397 (EMACS_USECS (thyme) + 500) / 1000;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1398 if (milliseconds < 1)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1399 milliseconds = 1;
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
1400 ++mswindows_pending_timers_count;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1401 return SetTimer (NULL, 0, milliseconds,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1402 (TIMERPROC) mswindows_wm_timer_callback);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1403 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1404
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1405 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1406 emacs_mswindows_remove_timeout (int id)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1407 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1408 struct Lisp_Event match_against;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1409 Lisp_Object emacs_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1410
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
1411 if (KillTimer (NULL, id))
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
1412 --mswindows_pending_timers_count;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1413
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1414 /* If there is a dispatch event generated by this
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1415 timeout in the queue, we have to remove it too. */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1416 match_against.event_type = timeout_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1417 match_against.event.timeout.interval_id = id;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1418 emacs_event = mswindows_cancel_dispatch_event (&match_against);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1419 if (!NILP (emacs_event))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1420 Fdeallocate_event(emacs_event);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1421 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1422
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1423 /* If `user_p' is false, then return whether there are any win32, timeout,
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1424 * or subprocess events pending (that is, whether
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1425 * emacs_mswindows_next_event() would return immediately without blocking).
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1426 *
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1427 * if `user_p' is true, then return whether there are any *user generated*
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1428 * events available (that is, whether there are keyboard or mouse-click
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1429 * events ready to be read). This also implies that
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1430 * emacs_mswindows_next_event() would not block.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1431 */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1432 static int
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1433 emacs_mswindows_event_pending_p (int user_p)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1434 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1435 mswindows_need_event (user_p, 0);
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1436
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1437 return (!NILP (mswindows_u_dispatch_event_queue)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1438 || (!user_p && !NILP (mswindows_s_dispatch_event_queue)));
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1439 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1440
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1441 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1442 * Return the next event
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1443 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1444 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1445 emacs_mswindows_next_event (struct Lisp_Event *emacs_event)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1446 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1447 Lisp_Object event, event2;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1448
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1449 /* Give strong preference to user events */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1450 mswindows_need_event (1, 1);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1451
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1452 /* XXX Copied from event-Xt.c */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1453 event = mswindows_dequeue_dispatch_event (!NILP(mswindows_u_dispatch_event_queue));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1454 XSETEVENT (event2, emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1455 Fcopy_event (event, event2);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1456 Fdeallocate_event (event);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1457 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1458
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1459 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1460 * Handle a magic event off the dispatch queue.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1461 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1462 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1463 emacs_mswindows_handle_magic_event (struct Lisp_Event *emacs_event)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1464 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1465 switch (EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1466 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1467 case WM_SETFOCUS:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1468 case WM_KILLFOCUS:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1469 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1470 Lisp_Object frame = EVENT_CHANNEL (emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1471 struct frame *f = XFRAME (frame);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1472 int in_p = (EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event) == WM_SETFOCUS);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1473 Lisp_Object conser;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1474
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1475 /* struct gcpro gcpro1; */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1476
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1477 /* Clear sticky modifiers here (if we had any) */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1478
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1479 conser = Fcons (frame, Fcons (FRAME_DEVICE (f), in_p ? Qt : Qnil));
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1480 /* GCPRO1 (conser); XXX Not necessary? */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1481 emacs_handle_focus_change_preliminary (conser);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1482 /* Under X the stuff up to here is done in the X event handler.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1483 I Don't know why */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1484 emacs_handle_focus_change_final (conser);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1485 /* UNGCPRO; */
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1486
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1487 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1488 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1489
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1490 case XM_BUMPQUEUE:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1491 /* This is a nice event, when we're in need to queue *something* */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1492 break;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1493
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1494 case XM_MAPFRAME:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1495 case XM_UNMAPFRAME:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1496 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1497 Lisp_Object frame = EVENT_CHANNEL (emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1498 va_run_hook_with_args (EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1499 == XM_MAPFRAME ?
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1500 Qmap_frame_hook : Qunmap_frame_hook,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1501 1, frame);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1502 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1503 break;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1504
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1505 /* #### What about Enter & Leave */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1506 #if 0
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1507 va_run_hook_with_args (in_p ? Qmouse_enter_frame_hook :
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1508 Qmouse_leave_frame_hook, 1, frame);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1509 #endif
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1510
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1511 default:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1512 assert(0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1513 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1514 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1515
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1516 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1517 emacs_mswindows_select_process (struct Lisp_Process *process)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1518 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1519 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1520
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1521 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1522 emacs_mswindows_unselect_process (struct Lisp_Process *process)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1523 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1524 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1525
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1526 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1527 emacs_mswindows_select_console (struct console *con)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1528 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1529 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1530
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1531 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1532 emacs_mswindows_unselect_console (struct console *con)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1533 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1534 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1535
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1536 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1537 emacs_mswindows_quit_p (void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1538 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1539 mswindows_need_event (1, 0);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1540
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1541 if (mswindows_quit_chars_count > 0)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1542 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1543 /* Yes there's a hidden one... Throw it away */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1544 struct Lisp_Event match_against;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1545 Lisp_Object emacs_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1546
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1547 match_against.event_type = key_press_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1548 match_against.event.key.modifiers = FAKE_MOD_QUIT;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1549
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1550 emacs_event = mswindows_cancel_dispatch_event (&match_against);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1551 assert (!NILP (emacs_event));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1552
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1553 Vquit_flag = (XEVENT(emacs_event)->event.key.modifiers & MOD_SHIFT
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1554 ? Qcritical : Qt);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1555
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1556 Fdeallocate_event(emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1557 --mswindows_quit_chars_count;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1558 }
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1559 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1560
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1561 /* This is called from GC when a process object is about to be freed.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1562 If we've still got pointers to it in this file, we're gonna lose hard.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1563 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1564 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1565 debug_process_finalization (struct Lisp_Process *p)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1566 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1567 #if 0 /* #### */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1568 int i;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1569 int infd, outfd;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1570 get_process_file_descriptors (p, &infd, &outfd);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1571 /* if it still has fds, then it hasn't been killed yet. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1572 assert (infd < 0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1573 assert (outfd < 0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1574 /* Better not still be in the "with input" table; we know it's got no fds. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1575 for (i = 0; i < MAXDESC; i++)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1576 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1577 Lisp_Object process = filedesc_fds_with_input [i];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1578 assert (!PROCESSP (process) || XPROCESS (process) != p);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1579 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1580 #endif
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1581 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1582
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1583 /************************************************************************/
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1584 /* initialization */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1585 /************************************************************************/
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1586
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1587 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1588 vars_of_event_mswindows (void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1589 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1590 mswindows_u_dispatch_event_queue = Qnil;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1591 staticpro (&mswindows_u_dispatch_event_queue);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1592 mswindows_u_dispatch_event_queue_tail = Qnil;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1593
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1594 mswindows_s_dispatch_event_queue = Qnil;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1595 staticpro (&mswindows_s_dispatch_event_queue);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1596 mswindows_s_dispatch_event_queue_tail = Qnil;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1597
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
1598 mswindows_error_caught_in_modal_loop = Qnil;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
1599 staticpro (&mswindows_error_caught_in_modal_loop);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
1600 mswindows_in_modal_loop = 0;
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
1601 mswindows_pending_timers_count = 0;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
1602
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1603 mswindows_event_stream = xnew (struct event_stream);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1604
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1605 mswindows_event_stream->event_pending_p = emacs_mswindows_event_pending_p;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1606 mswindows_event_stream->next_event_cb = emacs_mswindows_next_event;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1607 mswindows_event_stream->handle_magic_event_cb = emacs_mswindows_handle_magic_event;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1608 mswindows_event_stream->add_timeout_cb = emacs_mswindows_add_timeout;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1609 mswindows_event_stream->remove_timeout_cb = emacs_mswindows_remove_timeout;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1610 mswindows_event_stream->select_console_cb = emacs_mswindows_select_console;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1611 mswindows_event_stream->unselect_console_cb = emacs_mswindows_unselect_console;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1612 mswindows_event_stream->select_process_cb = emacs_mswindows_select_process;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1613 mswindows_event_stream->unselect_process_cb = emacs_mswindows_unselect_process;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1614 mswindows_event_stream->quit_p_cb = emacs_mswindows_quit_p;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1615
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1616 DEFVAR_BOOL ("mswindows-dynamic-frame-resize", &mswindows_dynamic_frame_resize /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1617 *Controls redrawing frame contents during mouse-drag or keyboard resize
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1618 operation. When non-nil, the frame is redrawn while being resized. When
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1619 nil, frame is not redrawn, and exposed areas are filled with default
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1620 MDI application background color. Note that this option only has effect
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1621 if "Show window contents while dragging" is on in system Display/Plus!
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1622 settings.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1623 Default is t on fast machines, nil on slow.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1624 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1625
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1626 /* The description copied verbatim from nt-emacs. (C) Geoff Voelker */
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1627 DEFVAR_INT ("mswindows-mouse-button-tolerance", &mswindows_button2_chord_time /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1628 *Analogue of double click interval for faking middle mouse events.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1629 The value is the minimum time in milliseconds that must elapse between
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1630 left/right button down events before they are considered distinct events.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1631 If both mouse buttons are depressed within this interval, a middle mouse
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1632 button down event is generated instead.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1633 If negative or zero, currently set system default is used instead.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1634 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1635
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1636 /* The description copied verbatim from nt-emacs. (C) Geoff Voelker */
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1637 DEFVAR_INT ("mswindows-num-mouse-buttons", &mswindows_num_mouse_buttons /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1638 Number of physical mouse buttons.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1639 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1640
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1641 DEFVAR_INT ("mswindows-mouse-button-max-skew-x", &mswindows_button2_max_skew_x /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1642 *Maximum horizontal distance in pixels between points in which left and
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1643 right button clicks occured for them to be translated into single
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1644 middle button event. Clicks must occur in time not longer than defined
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1645 by the variable mswindows-mouse-button-tolerance.
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1646 If negative or zero, currently set system default is used instead.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1647 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1648
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1649 DEFVAR_INT ("mswindows-mouse-button-max-skew-y", &mswindows_button2_max_skew_y /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1650 *Maximum vertical distance in pixels between points in which left and
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1651 right button clicks occured for them to be translated into single
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1652 middle button event. Clicks must occur in time not longer than defined
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1653 by the variable mswindows-mouse-button-tolerance.
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1654 If negative or zero, currently set system default is used instead.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1655 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1656
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1657 mswindows_button2_max_skew_x = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1658 mswindows_button2_max_skew_y = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1659 mswindows_button2_chord_time = 0;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1660 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1661
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1662 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1663 syms_of_event_mswindows (void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1664 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1665 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1666
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1667 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1668 init_event_mswindows_late (void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1669 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1670 event_stream = mswindows_event_stream;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1671
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1672 mswindows_dynamic_frame_resize = !GetSystemMetrics (SM_SLOWMACHINE);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1673 mswindows_num_mouse_buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1674 }