annotate src/event-msw.c @ 233:52952cbfc5b5 r20-5b15

Import from CVS: tag r20-5b15
author cvs
date Mon, 13 Aug 2007 10:14:14 +0200
parents 557eaa0339bf
children 41f2f0e326e9
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
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
36 #include "device.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
37 #include "console-msw.h"
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
38 #include "emacsfns.h"
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
39 #include "events.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
40 #include "frame.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
41 #include "process.h"
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
42 #include "redisplay.h"
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
43 #include "sysproc.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
44 #include "syswait.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
45 #include "systime.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
46
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
47 #include "event-msw.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
48
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
49 static struct event_stream *mswindows_event_stream;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
50
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
51 /*
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
52 * Two separate queues, for efficiency, one (_u_) for user events, and
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
53 * 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
54 * 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
55 * one.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
56 */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
57 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
58 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
59
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
60 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
61 * List of mswindows waitable handles.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
62 * Apart from the dispatch queue semaphore, all of these handles may be waited
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
63 * on multiple times in emacs_mswindows_next_event before being processed and so
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
64 * must be manual-reset events.
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
65 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
66 static HANDLE mswindows_waitable[MAX_WAITABLE];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
67
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
68 /* random emacs info associated with each of the wait handles */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
69 static mswindows_waitable_info_type mswindows_waitable_info[MAX_WAITABLE];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
70
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
71 /* Count of quit chars currently in the queue */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
72 /* Incremented in WM_CHAR handler in msw-proc.c
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
73 Decremented in mswindows_dequeue_dispatch_event() */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
74 int mswindows_quit_chars_count = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
75
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
76 /* These are Lisp integers; see DEFVARS in this file for description. */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
77 int mswindows_dynamic_frame_resize;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
78 int mswindows_num_mouse_buttons;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
79 int mswindows_button2_max_skew_x;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
80 int mswindows_button2_max_skew_y;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
81 int mswindows_button2_chord_time;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
82
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
83 /* Number of wait handles */
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
84 static mswindows_waitable_count=0;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
85
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
86 /* This is the event signaled by the event pump.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
87 See mswindows_pump_outstanding_events for comments */
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
88 static Lisp_Object mswindows_error_caught_in_modal_loop;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
89 static int mswindows_in_modal_loop;
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
90
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
91 /* Count of wound timers */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
92 static int mswindows_pending_timers_count;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
93
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
94 static int
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
95 mswindows_user_event_p (struct Lisp_Event* sevt)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
96 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
97 return (sevt->event_type == key_press_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
98 || sevt->event_type == button_press_event
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
99 || sevt->event_type == button_release_event);
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
100 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
101
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
102 /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
103 * Add an emacs event to the proper dispatch queue
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
104 */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
105 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
106 mswindows_enqueue_dispatch_event (Lisp_Object event)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
107 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
108 int user_p = mswindows_user_event_p (XEVENT(event));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
109 enqueue_event (event,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
110 user_p ? &mswindows_u_dispatch_event_queue :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
111 &mswindows_s_dispatch_event_queue,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
112 user_p ? &mswindows_u_dispatch_event_queue_tail :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
113 &mswindows_s_dispatch_event_queue_tail);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
114
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
115 /* This one does not go to window procedure, hence does not
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
116 generate XM_BUMPQUEUE magic event! */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
117 PostMessage (NULL, XM_BUMPQUEUE, 0, 0);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
118 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
119
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
120 /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
121 * Remove and return the first emacs event on the dispatch queue.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
122 * Give a preference to user events over non-user ones.
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
123 */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
124 static Lisp_Object
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
125 mswindows_dequeue_dispatch_event ()
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
126 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
127 Lisp_Object event;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
128 struct Lisp_Event* sevt;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
129
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
130 assert (!NILP(mswindows_u_dispatch_event_queue) ||
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
131 !NILP(mswindows_s_dispatch_event_queue));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
132
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
133 event = dequeue_event (
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
134 NILP(mswindows_u_dispatch_event_queue) ?
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
135 &mswindows_s_dispatch_event_queue :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
136 &mswindows_u_dispatch_event_queue,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
137 NILP(mswindows_u_dispatch_event_queue) ?
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
138 &mswindows_s_dispatch_event_queue_tail :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
139 &mswindows_u_dispatch_event_queue_tail);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
140
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
141 sevt = XEVENT(event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
142 if (sevt->event_type == key_press_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
143 && (sevt->event.key.modifiers & FAKE_MOD_QUIT))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
144 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
145 sevt->event.key.modifiers &= ~FAKE_MOD_QUIT;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
146 --mswindows_quit_chars_count;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
147 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
148
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
149 return event;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
150 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
151
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
152 /*
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
153 * 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
154 * the supplied event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
155 * 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
156 * Keypress event matches if logical AND between modifiers bitmask of the
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
157 * 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
158 * For all other event types, this function asserts.
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
159 */
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
160
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
161 Lisp_Object
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
162 mswindows_cancel_dispatch_event (struct Lisp_Event* match)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
163 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
164 Lisp_Object event;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
165 Lisp_Object previous_event=Qnil;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
166 int user_p = mswindows_user_event_p (match);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
167 Lisp_Object* head = user_p ? &mswindows_u_dispatch_event_queue :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
168 &mswindows_s_dispatch_event_queue;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
169 Lisp_Object* tail = user_p ? &mswindows_u_dispatch_event_queue_tail :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
170 &mswindows_s_dispatch_event_queue_tail;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
171
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
172 assert (match->event_type == timeout_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
173 || match->event_type == key_press_event);
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
174
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
175 EVENT_CHAIN_LOOP (event, *head)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
176 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
177 int found = 1;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
178 if (XEVENT_TYPE (event) != match->event_type)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
179 found = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
180 if (found && match->event_type == timeout_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
181 && (XEVENT(event)->event.timeout.interval_id !=
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
182 match->event.timeout.interval_id))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
183 found = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
184 if (found && match->event_type == key_press_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
185 && ((XEVENT(event)->event.key.modifiers &
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
186 match->event.key.modifiers) == 0))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
187 found = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
188
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
189 if (found)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
190 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
191 if (NILP (previous_event))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
192 dequeue_event (head, tail);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
193 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
194 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
195 XSET_EVENT_NEXT (previous_event, XEVENT_NEXT (event));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
196 if (EQ (*tail, event))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
197 *tail = previous_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
198 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
199
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
200 return event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
201 }
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
202 previous_event = event;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
203 }
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
204 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
205
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
206 static Lisp_Object
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
207 mswindows_modal_loop_error_handler (Lisp_Object cons_sig_data,
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
208 Lisp_Object u_n_u_s_e_d)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
209 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
210 mswindows_error_caught_in_modal_loop = cons_sig_data;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
211 return Qunbound;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
212 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
213
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
214 Lisp_Object
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
215 mswindows_protect_modal_loop (Lisp_Object (*bfun) (Lisp_Object barg),
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
216 Lisp_Object barg)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
217 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
218 Lisp_Object tmp;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
219
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
220 ++mswindows_in_modal_loop;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
221 tmp = condition_case_1 (Qt,
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
222 bfun, barg,
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
223 mswindows_modal_loop_error_handler, Qnil);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
224 --mswindows_in_modal_loop;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
225
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
226 return tmp;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
227 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
228
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
229 void
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
230 mswindows_unmodalize_signal_maybe (void)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
231 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
232 if (!NILP (mswindows_error_caught_in_modal_loop))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
233 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
234 /* Got an error while messages were pumped while
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
235 in window procedure - have to resignal */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
236 Lisp_Object sym = XCAR (mswindows_error_caught_in_modal_loop);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
237 Lisp_Object data = XCDR (mswindows_error_caught_in_modal_loop);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
238 mswindows_error_caught_in_modal_loop = Qnil;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
239 Fsignal (sym, data);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
240 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
241 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
242
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
243 /*
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
244 * This is an unsafe part of event pump, guarded by
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
245 * condition_case. See mswindows_pump_outstanding_events
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
246 */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
247 static Lisp_Object
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
248 mswindows_unsafe_pump_events (Lisp_Object u_n_u_s_e_d)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
249 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
250 /* This function can call lisp */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
251 Lisp_Object event = Fmake_event (Qnil, Qnil);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
252 struct gcpro gcpro1;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
253 int do_redisplay = 0;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
254 GCPRO1 (event);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
255
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
256 while (detect_input_pending ())
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
257 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
258 Fnext_event (event, Qnil);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
259 Fdispatch_event (event);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
260 do_redisplay = 1;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
261 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
262
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
263 if (do_redisplay)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
264 redisplay ();
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
265
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
266 Fdeallocate_event (event);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
267 UNGCPRO;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
268
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
269 /* Qt becomes return value of mswindows_pump_outstanding_events
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
270 once we get here */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
271 return Qt;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
272 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
273
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
274 /*
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
275 * This function pumps emacs events, while available, by using
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
276 * next_message/dispatch_message loop. Errors are trapped around
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
277 * the loop so the function always returns.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
278 *
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
279 * Windows message queue is not looked into during the call,
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
280 * neither are waitable handles checked. The function pumps
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
281 * thus only dispatch events already queued, as well as those
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
282 * resulted in dispatching thereof. This is done by setting
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
283 * module local variable mswidows_in_modal_loop to nonzero.
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
284 *
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
285 * 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
286 * there was an error.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
287 *
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
288 * In case of error, a cons representing the error, in the
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
289 * form (SIGNAL . DATA), is stored in the module local variable
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
290 * mswindows_error_caught_in_modal_loop. This error is signaled
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
291 * again when DispatchMessage returns. Thus, Windows internal
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
292 * modal loops are protected against throws, which are proven
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
293 * to corrupt internal Windows structures.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
294 *
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
295 * In case of success, mswindows_error_caught_in_modal_loop is
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
296 * assigned Qnil.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
297 *
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
298 * 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
299 * nil already upon entry, the function just returns non-nil.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
300 * This situation means that a new event has been queued while
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
301 * cancleng mode. The event will be dequeued on the next regular
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
302 * call of next-event; the pump is off since error is caught.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
303 * The caller must *unconditionally* cancel modal loop if the
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
304 * value returned by this function is nil. Otherwise, everything
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
305 * will become frozen until the modal loop exits under normal
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
306 * condition (scrollbar drag is released, menu closed etc.)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
307 */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
308 Lisp_Object
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
309 mswindows_pump_outstanding_events (void)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
310 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
311 /* This function can call lisp */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
312
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
313 Lisp_Object result = Qt;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
314
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
315 if (NILP(mswindows_error_caught_in_modal_loop))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
316 result = mswindows_protect_modal_loop (mswindows_unsafe_pump_events, Qnil);
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
317 return result;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
318 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
319
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
320 /*
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
321 * Find a free waitable slot
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
322 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
323 static int
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
324 mswindows_find_free_waitable(void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
325 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
326 int i;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
327 for (i=0; i<mswindows_waitable_count; i++)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
328 if (mswindows_waitable_info[i].type == mswindows_waitable_type_none)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
329 return i;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
330 assert (mswindows_waitable_count < MAX_WAITABLE);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
331 return mswindows_waitable_count++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
332 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
333
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
334 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
335 * Create a new waitable using the type and data passed in by the info structure
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
336 * Returns a pointer to the info associated with the assigned waitable object
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
337 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
338 mswindows_waitable_info_type *
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
339 mswindows_add_waitable(mswindows_waitable_info_type *info)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
340 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
341 int waitable;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
342
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
343 switch (info->type)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
344 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
345 case mswindows_waitable_type_dispatch:
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
346 assert (0); /* kkm - should not get here */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
347 /* Can only have one waitable for the dispatch queue, and it's the first one */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
348 assert (mswindows_waitable_count++ == 0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
349 waitable=0;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
350 #if 0
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
351 InitializeCriticalSection(&mswindows_dispatch_crit);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
352 #endif
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
353 assert (mswindows_waitable[0] = CreateSemaphore (NULL, 0, 0x7fffffff, NULL));
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
354 return mswindows_waitable_info+0;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
355
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
356 default:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
357 assert(0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
358 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
359 mswindows_waitable_info[waitable].type = info->type;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
360 return mswindows_waitable_info+waitable;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
361 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
362
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
363 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
364 * Remove a waitable using the type and data passed in by the info structure.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
365 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
366 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
367 mswindows_remove_waitable(mswindows_waitable_info_type *info)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
368 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
369 int waitable;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
370
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
371 switch (info->type)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
372 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
373
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
374 default:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
375 assert(0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
376 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
377
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
378 CloseHandle(mswindows_waitable[waitable]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
379 mswindows_waitable[waitable] = 0;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
380 mswindows_waitable_info[waitable].type = mswindows_waitable_type_none;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
381 if (waitable == mswindows_waitable_count-1)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
382 --mswindows_waitable_count;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
383 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
384
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
385 /*
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
386 * Callback procedure for synchronous timer messages
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
387 */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
388 static void CALLBACK
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
389 mswindows_wm_timer_callback (HWND hwnd, UINT umsg, UINT id_timer, DWORD dwtime)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
390 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
391 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
392 struct Lisp_Event *event = XEVENT (emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
393
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
394 if (KillTimer (NULL, id_timer))
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
395 --mswindows_pending_timers_count;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
396
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
397 event->channel = Qnil;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
398 event->timestamp = dwtime;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
399 event->event_type = timeout_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
400 event->event.timeout.interval_id = id_timer;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
401
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
402 mswindows_enqueue_dispatch_event (emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
403 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
404
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
405 static void
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
406 mswindows_drain_windows_queue ()
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
407 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
408 MSG msg;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
409 while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
410 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
411 DispatchMessage (&msg);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
412 mswindows_unmodalize_signal_maybe ();
227
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 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
415
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 is a special flavour of the mswindows_need_event function,
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
418 * used while in event pump. Actually, there is only kind of events
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
419 * allowed while in event pump: a timer. An attempt to fetch any
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
420 * 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
421 * ('cause event pump mirrors windows modal loop, which is a sole
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
422 * owner of thread message queue).
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
423 *
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
424 * To detect this, we use a counter of active timers, and allow
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
425 * fetching WM_TIMER messages. Instead of trying to fetch a WM_TIMER
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
426 * which will never come when there are no pending timers, which leads
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
427 * to deadlock, we simply signal an error.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
428 *
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
429 * The implementation does not honor user_p by design.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
430 */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
431 static void
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
432 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
433 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
434 MSG msg;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
435
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
436 /* Check if already have one */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
437 if (!NILP (mswindows_u_dispatch_event_queue)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
438 || !NILP (mswindows_s_dispatch_event_queue))
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
439 return;
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 /* No event is ok */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
442 if (!badly_p)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
443 return;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
444
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
445 /* We do not check the _u_ queue, because timers go to _s_ */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
446 while (NILP (mswindows_s_dispatch_event_queue))
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
447 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
448 /* We'll deadlock if go waiting */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
449 if (mswindows_pending_timers_count == 0)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
450 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
451
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
452 /* Fetch and dispatch any pending timers */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
453 GetMessage (&msg, NULL, WM_TIMER, WM_TIMER);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
454 DispatchMessage (&msg);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
455 }
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
456 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
457
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
458 /*
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
459 * This drains the event queue and fills up two internal queues until
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
460 * an event of a type specified by USER_P is retrieved.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
461 *
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
462 * 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
463 * the first non-user event if there no user events. Otherwise, If
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
464 * not user_p, it does not give preference to user events.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
465 *
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
466 * 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
467 * available.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
468 *
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
469 * The code does not rely on MsgWaitForMultipleObjects preference for
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
470 * messages over waitable handles.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
471 *
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
472 * Used by emacs_mswindows_event_pending_p and emacs_mswindows_next_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
473 */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
474 static void
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
475 mswindows_need_event (int user_p, int badly_p)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
476 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
477 int active;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
478
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
479 if (mswindows_in_modal_loop)
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
480 {
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
481 mswindows_need_event_in_modal_loop (user_p, badly_p);
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
482 return;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
483 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
484
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
485 /* Have to drain Windows message queue first, otherwise, we may miss
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
486 quit char when called from quit_p */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
487 mswindows_drain_windows_queue ();
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
488
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
489 while (NILP (mswindows_u_dispatch_event_queue) &&
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
490 (user_p || NILP (mswindows_s_dispatch_event_queue)))
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 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
493 if (!NILP (mswindows_u_dispatch_event_queue)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
494 || !NILP (mswindows_s_dispatch_event_queue))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
495 badly_p = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
496
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
497 /* Now try getting a message */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
498 active = MsgWaitForMultipleObjects (mswindows_waitable_count,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
499 mswindows_waitable,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
500 FALSE, badly_p ? INFINITE : 0,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
501 QS_ALLINPUT);
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 /* This will assert if handle being waited for becomes abandoned.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
504 Not the case currently tho */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
505 assert ((!badly_p && active == WAIT_TIMEOUT) ||
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
506 (active >= WAIT_OBJECT_0 &&
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
507 active <= WAIT_OBJECT_0 + mswindows_waitable_count));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
508
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
509 if (active == WAIT_TIMEOUT)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
510 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
511 /* No luck trying - just return what we've already got */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
512 return;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
513 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
514 else if (active == WAIT_OBJECT_0 + mswindows_waitable_count)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
515 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
516 /* Got your message, thanks */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
517 mswindows_drain_windows_queue ();
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
518 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
519 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
520 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
521 /* 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
522 int waitable = active - WAIT_OBJECT_0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
523 mswindows_waitable_info_type *info = mswindows_waitable_info + waitable;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
524
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
525 switch (info->type)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
526 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
527 /* XXX FIXME: Should enque subprocess event here so that it is not lost */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
528 default:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
529 assert(0);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
530 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
531 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
532 } /* while */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
533
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
534 return;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
535 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
536
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
537
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
538 /************************************************************************/
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
539 /* methods */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
540 /************************************************************************/
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
541
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
542 static int
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
543 emacs_mswindows_add_timeout (EMACS_TIME thyme)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
544 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
545 int milliseconds;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
546 EMACS_TIME current_time;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
547 EMACS_GET_TIME (current_time);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
548 EMACS_SUB_TIME (thyme, thyme, current_time);
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
549 milliseconds = EMACS_SECS (thyme) * 1000 +
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
550 (EMACS_USECS (thyme) + 500) / 1000;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
551 if (milliseconds < 1)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
552 milliseconds = 1;
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
553 ++mswindows_pending_timers_count;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
554 return SetTimer (NULL, 0, milliseconds, mswindows_wm_timer_callback);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
555 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
556
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
557 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
558 emacs_mswindows_remove_timeout (int id)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
559 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
560 struct Lisp_Event match_against;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
561 Lisp_Object emacs_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
562
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
563 if (KillTimer (NULL, id))
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
564 --mswindows_pending_timers_count;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
565
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
566 /* If there is a dispatch event generated by this
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
567 timeout in the queue, we have to remove it too. */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
568 match_against.event_type = timeout_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
569 match_against.event.timeout.interval_id = id;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
570 emacs_event = mswindows_cancel_dispatch_event (&match_against);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
571 if (!NILP (emacs_event))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
572 Fdeallocate_event(emacs_event);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
573 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
574
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
575 /* 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
576 * or subprocess events pending (that is, whether
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
577 * emacs_mswindows_next_event() would return immediately without blocking).
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
578 *
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
579 * 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
580 * events available (that is, whether there are keyboard or mouse-click
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
581 * events ready to be read). This also implies that
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
582 * emacs_mswindows_next_event() would not block.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
583 */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
584 static int
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
585 emacs_mswindows_event_pending_p (int user_p)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
586 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
587 mswindows_need_event (user_p, 0);
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
588
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
589 return (!NILP (mswindows_u_dispatch_event_queue)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
590 || (!user_p && !NILP (mswindows_s_dispatch_event_queue)));
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
591 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
592
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
593 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
594 * Return the next event
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
595 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
596 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
597 emacs_mswindows_next_event (struct Lisp_Event *emacs_event)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
598 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
599 Lisp_Object event, event2;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
600
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
601 /* Give strong preference to user events */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
602 mswindows_need_event (1, 1);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
603
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
604 /* XXX Copied from event-Xt.c */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
605 event = mswindows_dequeue_dispatch_event (!NILP(mswindows_u_dispatch_event_queue));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
606 XSETEVENT (event2, emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
607 Fcopy_event (event, event2);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
608 Fdeallocate_event (event);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
609 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
610
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
611 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
612 * Handle a magic event off the dispatch queue.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
613 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
614 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
615 emacs_mswindows_handle_magic_event (struct Lisp_Event *emacs_event)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
616 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
617 #if 0
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
618 stderr_out("magic %x, (%d,%d), (%d,%d)\n",
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
619 EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event),
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
620 rect->left, rect->top, rect->right, rect->bottom);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
621 #endif
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
622 switch (EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
623 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
624 case WM_SETFOCUS:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
625 case WM_KILLFOCUS:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
626 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
627 Lisp_Object frame = EVENT_CHANNEL (emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
628 struct frame *f = XFRAME (frame);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
629 int in_p = (EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event) == WM_SETFOCUS);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
630 Lisp_Object conser;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
631
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
632 /* struct gcpro gcpro1; */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
633
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
634 /* Clear sticky modifiers here (if we had any) */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
635
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
636 conser = Fcons (frame, Fcons (FRAME_DEVICE (f), in_p ? Qt : Qnil));
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
637 /* GCPRO1 (conser); XXX Not necessary? */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
638 emacs_handle_focus_change_preliminary (conser);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
639 /* 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
640 I Don't know why */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
641 emacs_handle_focus_change_final (conser);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
642 /* UNGCPRO; */
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
643
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
644 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
645 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
646
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
647 case XM_BUMPQUEUE:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
648 /* 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
649 break;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
650
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
651 case XM_MAPFRAME:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
652 case XM_UNMAPFRAME:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
653 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
654 Lisp_Object frame = EVENT_CHANNEL (emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
655 va_run_hook_with_args (EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
656 == XM_MAPFRAME ?
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
657 Qmap_frame_hook : Qunmap_frame_hook,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
658 1, frame);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
659 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
660 break;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
661
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
662 /* XXX What about Enter & Leave */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
663 #if 0
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
664 va_run_hook_with_args (in_p ? Qmouse_enter_frame_hook :
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
665 Qmouse_leave_frame_hook, 1, frame);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
666 #endif
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
667
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
668 default:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
669 assert(0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
670 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
671 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
672
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
673 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
674 emacs_mswindows_select_process (struct Lisp_Process *process)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
675 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
676 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
677
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
678 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
679 emacs_mswindows_unselect_process (struct Lisp_Process *process)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
680 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
681 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
682
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
683 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
684 emacs_mswindows_select_console (struct console *con)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
685 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
686 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
687
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
688 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
689 emacs_mswindows_unselect_console (struct console *con)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
690 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
691 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
692
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
693 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
694 emacs_mswindows_quit_p (void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
695 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
696 mswindows_need_event (1, 0);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
697
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
698 if (mswindows_quit_chars_count > 0)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
699 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
700 /* Yes there's a hidden one... Throw it away */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
701 struct Lisp_Event match_against;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
702 Lisp_Object emacs_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
703
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
704 match_against.event_type = key_press_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
705 match_against.event.key.modifiers = FAKE_MOD_QUIT;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
706
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
707 emacs_event = mswindows_cancel_dispatch_event (&match_against);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
708 assert (!NILP (emacs_event));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
709
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
710 Vquit_flag = (XEVENT(emacs_event)->event.key.modifiers & MOD_SHIFT
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
711 ? Qcritical : Qt);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
712
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
713 Fdeallocate_event(emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
714 --mswindows_quit_chars_count;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
715 }
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
716 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
717
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
718 /* 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
719 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
720 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
721 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
722 debug_process_finalization (struct Lisp_Process *p)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
723 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
724 #if 0 /* #### */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
725 int i;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
726 int infd, outfd;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
727 get_process_file_descriptors (p, &infd, &outfd);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
728 /* if it still has fds, then it hasn't been killed yet. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
729 assert (infd < 0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
730 assert (outfd < 0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
731 /* 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
732 for (i = 0; i < MAXDESC; i++)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
733 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
734 Lisp_Object process = filedesc_fds_with_input [i];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
735 assert (!PROCESSP (process) || XPROCESS (process) != p);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
736 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
737 #endif
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
738 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
739
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
740 /************************************************************************/
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
741 /* initialization */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
742 /************************************************************************/
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
743
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
744 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
745 vars_of_event_mswindows (void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
746 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
747 mswindows_u_dispatch_event_queue = Qnil;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
748 staticpro (&mswindows_u_dispatch_event_queue);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
749 mswindows_u_dispatch_event_queue_tail = Qnil;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
750
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
751 mswindows_s_dispatch_event_queue = Qnil;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
752 staticpro (&mswindows_s_dispatch_event_queue);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
753 mswindows_s_dispatch_event_queue_tail = Qnil;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
754
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
755 mswindows_error_caught_in_modal_loop = Qnil;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
756 staticpro (&mswindows_error_caught_in_modal_loop);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
757 mswindows_in_modal_loop = 0;
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
758 mswindows_pending_timers_count = 0;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
759
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
760 mswindows_event_stream = xnew (struct event_stream);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
761
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
762 mswindows_event_stream->event_pending_p = emacs_mswindows_event_pending_p;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
763 mswindows_event_stream->next_event_cb = emacs_mswindows_next_event;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
764 mswindows_event_stream->handle_magic_event_cb = emacs_mswindows_handle_magic_event;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
765 mswindows_event_stream->add_timeout_cb = emacs_mswindows_add_timeout;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
766 mswindows_event_stream->remove_timeout_cb = emacs_mswindows_remove_timeout;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
767 mswindows_event_stream->select_console_cb = emacs_mswindows_select_console;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
768 mswindows_event_stream->unselect_console_cb = emacs_mswindows_unselect_console;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
769 mswindows_event_stream->select_process_cb = emacs_mswindows_select_process;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
770 mswindows_event_stream->unselect_process_cb = emacs_mswindows_unselect_process;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
771 mswindows_event_stream->quit_p_cb = emacs_mswindows_quit_p;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
772
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
773 DEFVAR_BOOL ("mswindows-dynamic-frame-resize", &mswindows_dynamic_frame_resize /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
774 *Controls redrawing frame contents during mouse-drag or keyboard resize
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
775 operation. When non-nil, the frame is redrawn while being resized. When
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
776 nil, frame is not redrawn, and exposed areas are filled with default
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
777 MDI application background color. Note that this option only has effect
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
778 if "Show window contents while dragging" is on in system Display/Plus!
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
779 settings.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
780 Default is t on fast machines, nil on slow.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
781 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
782
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
783 /* The description copied verbatim from nt-emacs. (C) Geoff Voelker */
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
784 DEFVAR_INT ("mswindows-mouse-button-tolerance", &mswindows_button2_chord_time /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
785 *Analogue of double click interval for faking middle mouse events.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
786 The value is the minimum time in milliseconds that must elapse between
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
787 left/right button down events before they are considered distinct events.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
788 If both mouse buttons are depressed within this interval, a middle mouse
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
789 button down event is generated instead.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
790 If negative or zero, currently set system default is used instead.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
791 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
792
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
793 /* The description copied verbatim from nt-emacs. (C) Geoff Voelker */
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
794 DEFVAR_INT ("mswindows-num-mouse-buttons", &mswindows_num_mouse_buttons /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
795 Number of physical mouse buttons.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
796 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
797
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
798 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
799 *Maximum horizontal distance in pixels between points in which left and
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
800 right button clicks occured for them to be translated into single
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
801 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
802 by the variable mswindows-mouse-button-tolerance.
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
803 If negative or zero, currently set system default is used instead.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
804 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
805
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
806 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
807 *Maximum vertical distance in pixels between points in which left and
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
808 right button clicks occured for them to be translated into single
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
809 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
810 by the variable mswindows-mouse-button-tolerance.
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
811 If negative or zero, currently set system default is used instead.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
812 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
813
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
814 mswindows_button2_max_skew_x = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
815 mswindows_button2_max_skew_y = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
816 mswindows_button2_chord_time = 0;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
817 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
818
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
819 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
820 syms_of_event_mswindows (void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
821 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
822 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
823
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
824 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
825 init_event_mswindows_late (void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
826 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
827 event_stream = mswindows_event_stream;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
828
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
829 mswindows_dynamic_frame_resize = !GetSystemMetrics (SM_SLOWMACHINE);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
830 mswindows_num_mouse_buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
831 }