annotate src/event-msw.c @ 223:2c611d1463a6 r20-4b10

Import from CVS: tag r20-4b10
author cvs
date Mon, 13 Aug 2007 10:10:54 +0200
parents 262b8bb4a523
children 12579d965149
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"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
38 #include "events.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
39 #include "frame.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
40 #include "process.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
41
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
42 #include "sysproc.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
43 #include "syswait.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
44 #include "systime.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
45
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
46 #include "event-msw.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
47
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
48 static struct event_stream *mswindows_event_stream;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
49
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 * Two separate queues, for efficiency, one (_u_) for user events, and
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
52 * 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
53 * 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
54 * one.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
55 */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
56 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
57 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
58
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
59 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
60 * List of mswindows waitable handles.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
61 * 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
62 * 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
63 * must be manual-reset events.
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
64 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
65 static HANDLE mswindows_waitable[MAX_WAITABLE];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
66
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
67 /* random emacs info associated with each of the wait handles */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
68 static mswindows_waitable_info_type mswindows_waitable_info[MAX_WAITABLE];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
69
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
70 /* Count of quit chars currently in the queue */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
71 /* Incremented in WM_CHAR handler in msw-proc.c
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
72 Decremented in mswindows_dequeue_dispatch_event() */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
73 int mswindows_quit_chars_count = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
74
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
75 /* These are Lisp integers; see DEFVARS in this file for description. */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
76 int mswindows_dynamic_frame_resize;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
77 int mswindows_num_mouse_buttons;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
78 int mswindows_button2_max_skew_x;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
79 int mswindows_button2_max_skew_y;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
80 int mswindows_button2_chord_time;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
81
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
82 /* Number of wait handles */
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
83 static mswindows_waitable_count=0;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
84
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
85 static int
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
86 mswindows_user_event_p (struct Lisp_Event* sevt)
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 return (sevt->event_type == key_press_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
89 || sevt->event_type == button_press_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
90 || sevt->event_type == button_release_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
91 || sevt->event_type == pointer_motion_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
92 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
93
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
94 /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
95 * Add an emacs event to the proper dispatch queue
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
96 */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
97 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
98 mswindows_enqueue_dispatch_event (Lisp_Object event)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
99 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
100 int user_p = mswindows_user_event_p (XEVENT(event));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
101 enqueue_event (event,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
102 user_p ? &mswindows_u_dispatch_event_queue :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
103 &mswindows_s_dispatch_event_queue,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
104 user_p ? &mswindows_u_dispatch_event_queue_tail :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
105 &mswindows_s_dispatch_event_queue_tail);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
106
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
107 /* This one does not go to window procedure, hence does not
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
108 generate XM_BUMPQUEUE magic event! */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
109 PostMessage (NULL, XM_BUMPQUEUE, 0, 0);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
110 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
111
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
112 /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
113 * Remove and return the first emacs event on the dispatch queue.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
114 * Give a preference to user events over non-user ones.
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
115 */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
116 static Lisp_Object
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
117 mswindows_dequeue_dispatch_event ()
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 Lisp_Object event;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
120 struct Lisp_Event* sevt;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
121
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
122 assert (!NILP(mswindows_u_dispatch_event_queue) ||
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
123 !NILP(mswindows_s_dispatch_event_queue));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
124
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
125 event = dequeue_event (
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
126 NILP(mswindows_u_dispatch_event_queue) ?
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
127 &mswindows_s_dispatch_event_queue :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
128 &mswindows_u_dispatch_event_queue,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
129 NILP(mswindows_u_dispatch_event_queue) ?
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
130 &mswindows_s_dispatch_event_queue_tail :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
131 &mswindows_u_dispatch_event_queue_tail);
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 sevt = XEVENT(event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
134 if (sevt->event_type == key_press_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
135 && (sevt->event.key.modifiers & FAKE_MOD_QUIT))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
136 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
137 sevt->event.key.modifiers &= ~FAKE_MOD_QUIT;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
138 --mswindows_quit_chars_count;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
139 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
140
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
141 return event;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
142 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
143
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
144 /*
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
145 * 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
146 * the supplied event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
147 * 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
148 * Keypress event matches if logical AND between modifiers bitmask of the
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
149 * 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
150 * For all other event types, this function asserts.
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
151 */
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
152
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
153 Lisp_Object
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
154 mswindows_cancel_dispatch_event (struct Lisp_Event* match)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
155 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
156 Lisp_Object event;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
157 Lisp_Object previous_event=Qnil;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
158 int user_p = mswindows_user_event_p (match);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
159 Lisp_Object* head = user_p ? &mswindows_u_dispatch_event_queue :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
160 &mswindows_s_dispatch_event_queue;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
161 Lisp_Object* tail = user_p ? &mswindows_u_dispatch_event_queue_tail :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
162 &mswindows_s_dispatch_event_queue_tail;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
163
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
164 assert (match->event_type == timeout_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
165 || match->event_type == key_press_event);
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
166
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
167 EVENT_CHAIN_LOOP (event, *head)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
168 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
169 int found = 1;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
170 if (XEVENT_TYPE (event) != match->event_type)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
171 found = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
172 if (found && match->event_type == timeout_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
173 && (XEVENT(event)->event.timeout.interval_id !=
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
174 match->event.timeout.interval_id))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
175 found = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
176 if (found && match->event_type == key_press_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
177 && ((XEVENT(event)->event.key.modifiers &
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
178 match->event.key.modifiers) == 0))
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
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
181 if (found)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
182 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
183 if (NILP (previous_event))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
184 dequeue_event (head, tail);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
185 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
186 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
187 XSET_EVENT_NEXT (previous_event, XEVENT_NEXT (event));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
188 if (EQ (*tail, event))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
189 *tail = previous_event;
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
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
192 return event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
193 }
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
194 previous_event = event;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
195 }
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
196 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
197
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
198 /*
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
199 * Find a free waitable slot
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
200 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
201 static int
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
202 mswindows_find_free_waitable(void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
203 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
204 int i;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
205 for (i=0; i<mswindows_waitable_count; i++)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
206 if (mswindows_waitable_info[i].type == mswindows_waitable_type_none)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
207 return i;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
208 assert (mswindows_waitable_count < MAX_WAITABLE);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
209 return mswindows_waitable_count++;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
210 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
211
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
212 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
213 * 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
214 * Returns a pointer to the info associated with the assigned waitable object
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
215 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
216 mswindows_waitable_info_type *
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
217 mswindows_add_waitable(mswindows_waitable_info_type *info)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
218 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
219 int waitable;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
220
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
221 switch (info->type)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
222 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
223 case mswindows_waitable_type_dispatch:
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
224 assert (0); /* kkm - should not get here */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
225 /* 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
226 assert (mswindows_waitable_count++ == 0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
227 waitable=0;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
228 // InitializeCriticalSection(&mswindows_dispatch_crit);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
229 assert (mswindows_waitable[0] = CreateSemaphore (NULL, 0, 0x7fffffff, NULL));
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
230 return mswindows_waitable_info+0;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
231
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
232 default:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
233 assert(0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
234 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
235 mswindows_waitable_info[waitable].type = info->type;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
236 return mswindows_waitable_info+waitable;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
237 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
238
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
239 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
240 * 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
241 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
242 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
243 mswindows_remove_waitable(mswindows_waitable_info_type *info)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
244 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
245 int waitable;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
246
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
247 switch (info->type)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
248 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
249
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
250 default:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
251 assert(0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
252 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
253
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
254 CloseHandle(mswindows_waitable[waitable]);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
255 mswindows_waitable[waitable] = 0;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
256 mswindows_waitable_info[waitable].type = mswindows_waitable_type_none;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
257 if (waitable == mswindows_waitable_count-1)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
258 --mswindows_waitable_count;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
259 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
260
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
261 /*
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
262 * Callback procedure for synchronous timer messages
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
263 */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
264 static void CALLBACK
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
265 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
266 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
267 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
268 struct Lisp_Event *event = XEVENT (emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
269
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
270 KillTimer (NULL, id_timer);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
271
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
272 event->channel = Qnil;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
273 event->timestamp = dwtime;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
274 event->event_type = timeout_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
275 event->event.timeout.interval_id = id_timer;
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 mswindows_enqueue_dispatch_event (emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
278 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
279
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
280 static void
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
281 mswindows_drain_windows_queue ()
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
282 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
283 MSG msg;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
284 while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
285 DispatchMessage (&msg);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
286 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
287
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 * This drains the event queue and fills up two internal queues until
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
290 * an event of a type specified by USER_P is retrieved.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
291 *
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
292 * 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
293 * the first non-user event if there no user events. Otherwise, If
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
294 * not user_p, it does not give preference to user events.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
295 *
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
296 * 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
297 * available.
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 * The code does not rely on MsgWaitForMultipleObjects preference for
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
300 * messages over waitable handles.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
301 *
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
302 * Used by emacs_mswindows_event_pending_p and emacs_mswindows_next_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
303 */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
304 static void
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
305 mswindows_need_event (int user_p, int badly_p)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
306 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
307 int active;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
308
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
309 /* Have to drain Windows message queue first, otherwise, we may miss
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
310 quit char when called from quit_p */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
311 mswindows_drain_windows_queue ();
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
312
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
313 while (NILP (mswindows_u_dispatch_event_queue) &&
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
314 (user_p || NILP (mswindows_s_dispatch_event_queue)))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
315 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
316 /* 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
317 if (!NILP (mswindows_u_dispatch_event_queue)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
318 || !NILP (mswindows_s_dispatch_event_queue))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
319 badly_p = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
320
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
321 /* Now try getting a message */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
322 active = MsgWaitForMultipleObjects (mswindows_waitable_count,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
323 mswindows_waitable,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
324 FALSE, badly_p ? INFINITE : 0,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
325 QS_ALLINPUT);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
326
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
327 /* This will assert if handle being waited for becomes abandoned.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
328 Not the case currently tho */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
329 assert ((!badly_p && active == WAIT_TIMEOUT) ||
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
330 (active >= WAIT_OBJECT_0 &&
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
331 active <= WAIT_OBJECT_0 + mswindows_waitable_count));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
332
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
333 if (active == WAIT_TIMEOUT)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
334 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
335 /* No luck trying - just return what we've already got */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
336 return;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
337 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
338 else if (active == WAIT_OBJECT_0 + mswindows_waitable_count)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
339 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
340 /* Got your message, thanks */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
341 mswindows_drain_windows_queue ();
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
342 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
343 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
344 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
345 /* 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
346 int waitable = active - WAIT_OBJECT_0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
347 mswindows_waitable_info_type *info = mswindows_waitable_info + waitable;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
348
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
349 switch (info->type)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
350 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
351 /* 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
352 default:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
353 assert(0);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
354 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
355 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
356 } /* while */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
357
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
358 return;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
359 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
360
213
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 /* methods */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
364 /************************************************************************/
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
365
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
366 static int
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
367 emacs_mswindows_add_timeout (EMACS_TIME thyme)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
368 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
369 int milliseconds;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
370 EMACS_TIME current_time;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
371 EMACS_GET_TIME (current_time);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
372 EMACS_SUB_TIME (thyme, thyme, current_time);
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
373 milliseconds = EMACS_SECS (thyme) * 1000 +
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
374 (EMACS_USECS (thyme) + 500) / 1000;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
375 if (milliseconds < 1)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
376 milliseconds = 1;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
377 return SetTimer (NULL, 0, milliseconds, mswindows_wm_timer_callback);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
378 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
379
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
380 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
381 emacs_mswindows_remove_timeout (int id)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
382 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
383 struct Lisp_Event match_against;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
384 Lisp_Object emacs_event;
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 KillTimer (NULL, id);
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 /* If there is a dispatch event generated by this
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
389 timeout in the queue, we have to remove it too. */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
390 match_against.event_type = timeout_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
391 match_against.event.timeout.interval_id = id;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
392 emacs_event = mswindows_cancel_dispatch_event (&match_against);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
393 if (!NILP (emacs_event))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
394 Fdeallocate_event(emacs_event);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
395 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
396
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
397 /* 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
398 * or subprocess events pending (that is, whether
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
399 * emacs_mswindows_next_event() would return immediately without blocking).
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
400 *
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
401 * 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
402 * events available (that is, whether there are keyboard or mouse-click
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
403 * events ready to be read). This also implies that
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
404 * emacs_mswindows_next_event() would not block.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
405 */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
406 static int
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
407 emacs_mswindows_event_pending_p (int user_p)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
408 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
409 mswindows_need_event (user_p, 0);
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
410
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
411 return (!NILP (mswindows_u_dispatch_event_queue)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
412 || (!user_p && !NILP (mswindows_s_dispatch_event_queue)));
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
413 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
414
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
415 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
416 * Return the next event
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
417 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
418 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
419 emacs_mswindows_next_event (struct Lisp_Event *emacs_event)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
420 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
421 Lisp_Object event, event2;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
422
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
423 /* Give strong preference to user events */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
424 mswindows_need_event (1, 1);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
425
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
426 /* XXX Copied from event-Xt.c */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
427 event = mswindows_dequeue_dispatch_event (!NILP(mswindows_u_dispatch_event_queue));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
428 XSETEVENT (event2, emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
429 Fcopy_event (event, event2);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
430 Fdeallocate_event (event);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
431 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
432
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
433 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
434 * Handle a magic event off the dispatch queue.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
435 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
436 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
437 emacs_mswindows_handle_magic_event (struct Lisp_Event *emacs_event)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
438 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
439 #if 0
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
440 stderr_out("magic %x, (%d,%d), (%d,%d)\n",
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
441 EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event),
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
442 rect->left, rect->top, rect->right, rect->bottom);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
443 #endif
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
444 switch (EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
445 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
446 case WM_SETFOCUS:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
447 case WM_KILLFOCUS:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
448 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
449 Lisp_Object frame = EVENT_CHANNEL (emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
450 struct frame *f = XFRAME (frame);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
451 int in_p = (EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event) == WM_SETFOCUS);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
452 Lisp_Object conser;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
453
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
454 /* struct gcpro gcpro1; */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
455
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
456 /* Clear sticky modifiers here (if we had any) */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
457
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
458 conser = Fcons (frame, Fcons (FRAME_DEVICE (f), in_p ? Qt : Qnil));
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
459 /* GCPRO1 (conser); XXX Not necessary? */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
460 emacs_handle_focus_change_preliminary (conser);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
461 /* 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
462 I Don't know why */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
463 emacs_handle_focus_change_final (conser);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
464 /* UNGCPRO; */
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
465
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
466 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
467 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
468
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
469 case XM_BUMPQUEUE:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
470 /* 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
471 break;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
472
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
473 case XM_MAPFRAME:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
474 case XM_UNMAPFRAME:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
475 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
476 Lisp_Object frame = EVENT_CHANNEL (emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
477 va_run_hook_with_args (EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
478 == XM_MAPFRAME ?
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
479 Qmap_frame_hook : Qunmap_frame_hook,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
480 1, frame);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
481 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
482 break;
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 /* XXX What about Enter & Leave */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
485 #if 0
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
486 va_run_hook_with_args (in_p ? Qmouse_enter_frame_hook :
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
487 Qmouse_leave_frame_hook, 1, frame);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
488 #endif
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
489
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
490 default:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
491 assert(0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
492 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
493 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
494
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
495 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
496 emacs_mswindows_select_process (struct Lisp_Process *process)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
497 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
498 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
499
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
500 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
501 emacs_mswindows_unselect_process (struct Lisp_Process *process)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
502 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
503 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
504
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
505 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
506 emacs_mswindows_select_console (struct console *con)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
507 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
508 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
509
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
510 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
511 emacs_mswindows_unselect_console (struct console *con)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
512 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
513 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
514
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
515 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
516 emacs_mswindows_quit_p (void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
517 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
518 mswindows_need_event (1, 0);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
519
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
520 if (mswindows_quit_chars_count > 0)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
521 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
522 /* Yes there's a hidden one... Throw it away */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
523 struct Lisp_Event match_against;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
524 Lisp_Object emacs_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
525
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
526 match_against.event_type = key_press_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
527 match_against.event.key.modifiers = FAKE_MOD_QUIT;
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 emacs_event = mswindows_cancel_dispatch_event (&match_against);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
530 assert (!NILP (emacs_event));
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 Vquit_flag = (XEVENT(emacs_event)->event.key.modifiers & MOD_SHIFT
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
533 ? Qcritical : Qt);
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 Fdeallocate_event(emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
536 --mswindows_quit_chars_count;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
537 }
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
538 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
539
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
540 /* 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
541 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
542 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
543 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
544 debug_process_finalization (struct Lisp_Process *p)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
545 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
546 #if 0 /* #### */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
547 int i;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
548 int infd, outfd;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
549 get_process_file_descriptors (p, &infd, &outfd);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
550 /* if it still has fds, then it hasn't been killed yet. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
551 assert (infd < 0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
552 assert (outfd < 0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
553 /* 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
554 for (i = 0; i < MAXDESC; i++)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
555 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
556 Lisp_Object process = filedesc_fds_with_input [i];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
557 assert (!PROCESSP (process) || XPROCESS (process) != p);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
558 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
559 #endif
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
560 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
561
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
562 /************************************************************************/
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
563 /* initialization */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
564 /************************************************************************/
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
565
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
566 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
567 vars_of_event_mswindows (void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
568 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
569 mswindows_u_dispatch_event_queue = Qnil;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
570 staticpro (&mswindows_u_dispatch_event_queue);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
571 mswindows_u_dispatch_event_queue_tail = Qnil;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
572
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
573 mswindows_s_dispatch_event_queue = Qnil;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
574 staticpro (&mswindows_s_dispatch_event_queue);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
575 mswindows_s_dispatch_event_queue_tail = Qnil;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
576
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
577 mswindows_event_stream = xnew (struct event_stream);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
578
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
579 mswindows_event_stream->event_pending_p = emacs_mswindows_event_pending_p;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
580 mswindows_event_stream->next_event_cb = emacs_mswindows_next_event;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
581 mswindows_event_stream->handle_magic_event_cb = emacs_mswindows_handle_magic_event;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
582 mswindows_event_stream->add_timeout_cb = emacs_mswindows_add_timeout;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
583 mswindows_event_stream->remove_timeout_cb = emacs_mswindows_remove_timeout;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
584 mswindows_event_stream->select_console_cb = emacs_mswindows_select_console;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
585 mswindows_event_stream->unselect_console_cb = emacs_mswindows_unselect_console;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
586 mswindows_event_stream->select_process_cb = emacs_mswindows_select_process;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
587 mswindows_event_stream->unselect_process_cb = emacs_mswindows_unselect_process;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
588 mswindows_event_stream->quit_p_cb = emacs_mswindows_quit_p;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
589
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
590 DEFVAR_BOOL ("w32-dynamic-frame-resize", &mswindows_dynamic_frame_resize /*
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
591 *Controls redrawing frame contents during mouse-drag or keyboard resize
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
592 operation. When non-nil, the frame is redrawn while being resized. When
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
593 nil, frame is not redrawn, and exposed areas are filled with default
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
594 MDI application background color. Note that this option only has effect
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
595 if "Show window contents while dragging" is on in system Display/Plus!
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
596 settings.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
597 Default is t on fast machines, nil on slow.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
598 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
599
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
600 /* The description copied verbatim from nt-emacs. (C) Geoff Voelker */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
601 DEFVAR_INT ("w32-mouse-button-tolerance", &mswindows_button2_chord_time /*
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
602 *Analogue of double click interval for faking middle mouse events.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
603 The value is the minimum time in milliseconds that must elapse between
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
604 left/right button down events before they are considered distinct events.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
605 If both mouse buttons are depressed within this interval, a middle mouse
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
606 button down event is generated instead.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
607 If negative or zero, currently set system default is used instead.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
608 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
609
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
610 /* The description copied verbatim from nt-emacs. (C) Geoff Voelker */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
611 DEFVAR_INT ("w32-num-mouse-buttons", &mswindows_num_mouse_buttons /*
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
612 Number of physical mouse buttons.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
613 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
614
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
615 DEFVAR_INT ("w32-mouse-button-max-skew-x", &mswindows_button2_max_skew_x /*
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
616 *Maximum horizontal distance in pixels between points in which left and
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
617 right button clicks occured for them to be translated into single
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
618 middle button event. Clicks must occur in time not longer than defined
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
619 by the variable w32-mouse-button-tolerance.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
620 If negative or zero, currently set system default is used instead.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
621 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
622
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
623 DEFVAR_INT ("w32-mouse-button-max-skew-y", &mswindows_button2_max_skew_y /*
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
624 *Maximum vertical distance in pixels between points in which left and
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
625 right button clicks occured for them to be translated into single
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
626 middle button event. Clicks must occur in time not longer than defined
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
627 by the variable w32-mouse-button-tolerance.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
628 If negative or zero, currently set system default is used instead.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
629 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
630
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
631 mswindows_button2_max_skew_x = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
632 mswindows_button2_max_skew_y = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
633 mswindows_button2_chord_time = 0;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
634 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
635
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
636 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
637 syms_of_event_mswindows (void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
638 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
639 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
640
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
641 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
642 init_event_mswindows_late (void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
643 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
644 event_stream = mswindows_event_stream;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
645
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
646 mswindows_dynamic_frame_resize = !GetSystemMetrics (SM_SLOWMACHINE);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
647 mswindows_num_mouse_buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
648 }