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