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