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.
|
272
|
30 Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0.
|
213
|
31 */
|
|
32
|
|
33 #include <config.h>
|
|
34 #include "lisp.h"
|
|
35
|
249
|
36 #include "console-msw.h"
|
|
37
|
|
38 #ifdef HAVE_SCROLLBARS
|
|
39 # include "scrollbar-msw.h"
|
|
40 #endif
|
|
41
|
|
42 #ifdef HAVE_MENUBARS
|
|
43 # include "menubar-msw.h"
|
|
44 #endif
|
|
45
|
213
|
46 #include "device.h"
|
|
47 #include "events.h"
|
|
48 #include "frame.h"
|
274
|
49 #include "lstream.h"
|
213
|
50 #include "process.h"
|
227
|
51 #include "redisplay.h"
|
213
|
52 #include "sysproc.h"
|
|
53 #include "syswait.h"
|
|
54 #include "systime.h"
|
278
|
55 #include "sysdep.h"
|
213
|
56
|
249
|
57 #include "events-mod.h"
|
278
|
58 #ifdef HAVE_MSG_SELECT
|
|
59 #include "sysfile.h"
|
|
60 #endif
|
276
|
61 #include <io.h>
|
274
|
62 #include <errno.h>
|
|
63
|
249
|
64 #ifdef HAVE_MENUBARS
|
|
65 #define ADJR_MENUFLAG TRUE
|
|
66 #else
|
|
67 #define ADJR_MENUFLAG FALSE
|
|
68 #endif
|
|
69
|
|
70 /* Fake key modifier which is attached to a quit char event.
|
|
71 Removed upon dequeueing an event */
|
|
72 #define FAKE_MOD_QUIT 0x80
|
|
73
|
|
74 /* Timer ID used for button2 emulation */
|
|
75 #define BUTTON_2_TIMER_ID 1
|
|
76
|
|
77 /* Drag and drop event data types (subset of types in offix-types.h) */
|
|
78 #define DndFile 2
|
|
79 #define DndFiles 3
|
|
80 #define DndText 4
|
|
81
|
278
|
82 extern Lisp_Object
|
|
83 mswindows_get_toolbar_button_text (struct frame* f, int command_id);
|
|
84 extern Lisp_Object
|
|
85 mswindows_handle_toolbar_wm_command (struct frame* f, HWND ctrl, WORD id);
|
249
|
86
|
|
87 static Lisp_Object mswindows_find_frame (HWND hwnd);
|
|
88 static Lisp_Object mswindows_find_console (HWND hwnd);
|
|
89 static Lisp_Object mswindows_key_to_emacs_keysym(int mswindows_key, int mods);
|
|
90 static int mswindows_modifier_state (BYTE* keymap, int has_AltGr);
|
|
91 static void mswindows_set_chord_timer (HWND hwnd);
|
|
92 static int mswindows_button2_near_enough (POINTS p1, POINTS p2);
|
|
93 static int mswindows_current_layout_has_AltGr (void);
|
|
94
|
213
|
95 static struct event_stream *mswindows_event_stream;
|
223
|
96
|
278
|
97 #ifdef HAVE_MSG_SELECT
|
|
98 extern SELECT_TYPE input_wait_mask, non_fake_input_wait_mask;
|
|
99 extern SELECT_TYPE process_only_mask, tty_only_mask;
|
|
100 extern int signal_event_pipe_initialized;
|
|
101 int windows_fd;
|
|
102 #endif
|
|
103
|
223
|
104 /*
|
|
105 * Two separate queues, for efficiency, one (_u_) for user events, and
|
|
106 * another (_s_) for non-user ones. We always return events out of the
|
|
107 * first one until it is empty and only then proceed with the second
|
|
108 * one.
|
|
109 */
|
|
110 static Lisp_Object mswindows_u_dispatch_event_queue, mswindows_u_dispatch_event_queue_tail;
|
|
111 static Lisp_Object mswindows_s_dispatch_event_queue, mswindows_s_dispatch_event_queue_tail;
|
213
|
112
|
249
|
113 /* The number of things we can wait on */
|
|
114 #define MAX_WAITABLE (MAXIMUM_WAIT_OBJECTS - 1)
|
|
115
|
|
116 /* List of mswindows waitable handles. */
|
274
|
117 static HANDLE mswindows_waitable_handles[MAX_WAITABLE];
|
|
118
|
|
119 /* Number of wait handles */
|
|
120 static int mswindows_waitable_count=0;
|
213
|
121
|
223
|
122 /* Count of quit chars currently in the queue */
|
249
|
123 /* Incremented in WM_[SYS]KEYDOWN handler in the mswindows_wnd_proc()
|
223
|
124 Decremented in mswindows_dequeue_dispatch_event() */
|
|
125 int mswindows_quit_chars_count = 0;
|
|
126
|
|
127 /* These are Lisp integers; see DEFVARS in this file for description. */
|
|
128 int mswindows_dynamic_frame_resize;
|
|
129 int mswindows_num_mouse_buttons;
|
272
|
130 int mswindows_mouse_button_max_skew_x;
|
|
131 int mswindows_mouse_button_max_skew_y;
|
|
132 int mswindows_mouse_button_tolerance;
|
223
|
133
|
227
|
134 /* This is the event signaled by the event pump.
|
|
135 See mswindows_pump_outstanding_events for comments */
|
231
|
136 static Lisp_Object mswindows_error_caught_in_modal_loop;
|
|
137 static int mswindows_in_modal_loop;
|
227
|
138
|
|
139 /* Count of wound timers */
|
|
140 static int mswindows_pending_timers_count;
|
274
|
141
|
|
142 /************************************************************************/
|
|
143 /* Pipe instream - reads process output */
|
|
144 /************************************************************************/
|
|
145
|
|
146 #define PIPE_READ_DELAY 20
|
|
147
|
|
148 #define HANDLE_TO_USID(h) ((USID)(h))
|
|
149
|
|
150 #define NTPIPE_SLURP_STREAM_DATA(stream) \
|
|
151 LSTREAM_TYPE_DATA (stream, ntpipe_slurp)
|
|
152
|
276
|
153 /* This structure is allocated by the main thread, and is deallocated
|
|
154 in the thread upon exit. There are situations when a thread
|
|
155 remains blocked for a long time, much longer than the lstream
|
|
156 exists. For exmaple, "start notepad" command is issued from the
|
|
157 shell, then the shell is closed by C-c C-d. Although the shell
|
|
158 process exits, its output pipe will not get closed until the
|
|
159 notepad process exits also, because it inherits the pipe form the
|
|
160 shell. In this case, we abandon the thread, and let it live until
|
|
161 all such processes exit. While struct ntpipe_slurp_stream is
|
|
162 deallocated in this case, ntpipe_slurp_stream_shared_data are not. */
|
|
163
|
|
164 struct ntpipe_slurp_stream_shared_data
|
274
|
165 {
|
|
166 HANDLE hev_thread; /* Our thread blocks on this, signaled by caller */
|
|
167 /* This is a manual-reset object. */
|
|
168 HANDLE hev_caller; /* Caller blocks on this, and we signal it */
|
|
169 /* This is a manual-reset object. */
|
|
170 HANDLE hev_unsleep; /* Pipe read delay is canceled if this is set */
|
|
171 /* This is a manual-reset object. */
|
|
172 HANDLE hpipe; /* Pipe read end handle. */
|
276
|
173 LONG die_p; /* Thread must exit ASAP if non-zero */
|
274
|
174 BOOL eof_p : 1; /* Set when thread saw EOF */
|
|
175 BOOL error_p : 1; /* Read error other than EOF/broken pipe */
|
276
|
176 BOOL inuse_p : 1; /* this structure is in use */
|
|
177 LONG lock_count; /* Client count of this struct, 0=safe to free */
|
|
178 BYTE onebyte; /* One byte buffer read by thread */
|
|
179 };
|
|
180
|
|
181 #define MAX_SLURP_STREAMS 32
|
|
182 struct ntpipe_slurp_stream_shared_data
|
278
|
183 shared_data_block[MAX_SLURP_STREAMS]={{0}};
|
276
|
184
|
|
185 struct ntpipe_slurp_stream
|
|
186 {
|
|
187 LPARAM user_data; /* Any user data stored in the stream object */
|
|
188 struct ntpipe_slurp_stream_shared_data* thread_data;
|
274
|
189 };
|
|
190
|
|
191 DEFINE_LSTREAM_IMPLEMENTATION ("ntpipe-input", lstream_ntpipe_slurp,
|
|
192 sizeof (struct ntpipe_slurp_stream));
|
|
193
|
276
|
194 /* This function is thread-safe, and is called from either thread
|
|
195 context. It serializes freeing shared dtata structure */
|
|
196 static void
|
|
197 slurper_free_shared_data_maybe (struct ntpipe_slurp_stream_shared_data* s)
|
|
198 {
|
|
199 if (InterlockedDecrement (&s->lock_count) == 0)
|
|
200 {
|
|
201 /* Destroy events */
|
|
202 CloseHandle (s->hev_thread);
|
|
203 CloseHandle (s->hev_caller);
|
|
204 CloseHandle (s->hev_unsleep);
|
|
205 s->inuse_p = 0;
|
|
206 }
|
|
207 }
|
|
208
|
|
209 static struct ntpipe_slurp_stream_shared_data*
|
|
210 slurper_allocate_shared_data()
|
|
211 {
|
|
212 int i=0;
|
|
213 for (i=0; i<MAX_SLURP_STREAMS; i++)
|
|
214 {
|
|
215 if (!shared_data_block[i].inuse_p)
|
|
216 {
|
|
217 shared_data_block[i].inuse_p=1;
|
|
218 return &shared_data_block[i];
|
|
219 }
|
|
220 }
|
|
221 return (struct ntpipe_slurp_stream_shared_data*)0;
|
|
222 }
|
|
223
|
274
|
224 static DWORD WINAPI
|
|
225 slurp_thread (LPVOID vparam)
|
|
226 {
|
276
|
227 struct ntpipe_slurp_stream_shared_data *s =
|
|
228 (struct ntpipe_slurp_stream_shared_data*)vparam;
|
274
|
229
|
|
230 for (;;)
|
|
231 {
|
|
232 /* Read one byte from the pipe */
|
|
233 DWORD actually_read;
|
|
234 if (!ReadFile (s->hpipe, &s->onebyte, 1, &actually_read, NULL))
|
|
235 {
|
|
236 DWORD err = GetLastError ();
|
|
237 if (err == ERROR_BROKEN_PIPE || err == ERROR_NO_DATA)
|
|
238 s->eof_p = TRUE;
|
|
239 else
|
|
240 s->error_p = TRUE;
|
|
241 }
|
|
242 else if (actually_read == 0)
|
|
243 s->eof_p = TRUE;
|
|
244
|
|
245 /* We must terminate on an error or eof */
|
|
246 if (s->eof_p || s->error_p)
|
|
247 InterlockedIncrement (&s->die_p);
|
|
248
|
|
249 /* Before we notify caller, we unsignal our event. */
|
|
250 ResetEvent (s->hev_thread);
|
|
251
|
|
252 /* Now we got something to notify caller, either a byte or an
|
|
253 error/eof indication. Before we do, allow internal pipe
|
|
254 buffer to accumulate little bit more data.
|
|
255 Reader function pulses this event before waiting for
|
276
|
256 a character, to avoid pipe delay, and to get the byte
|
274
|
257 immediately. */
|
|
258 if (!s->die_p)
|
|
259 WaitForSingleObject (s->hev_unsleep, PIPE_READ_DELAY);
|
|
260
|
|
261 /* Either make event loop generate a process event, or
|
|
262 inblock reader */
|
|
263 SetEvent (s->hev_caller);
|
|
264
|
|
265 /* Cleanup and exit if we're shot off */
|
|
266 if (s->die_p)
|
|
267 break;
|
|
268
|
|
269 /* Block until the client finishes with retireving the rest of
|
|
270 pipe data */
|
|
271 WaitForSingleObject (s->hev_thread, INFINITE);
|
|
272 }
|
|
273
|
276
|
274 slurper_free_shared_data_maybe (s);
|
|
275
|
274
|
276 return 0;
|
|
277 }
|
|
278
|
|
279 static Lisp_Object
|
|
280 make_ntpipe_input_stream (HANDLE hpipe, LPARAM param)
|
|
281 {
|
|
282 Lisp_Object obj;
|
|
283 Lstream *lstr = Lstream_new (lstream_ntpipe_slurp, "r");
|
|
284 struct ntpipe_slurp_stream* s = NTPIPE_SLURP_STREAM_DATA (lstr);
|
|
285 DWORD thread_id_unused;
|
276
|
286 HANDLE hthread;
|
274
|
287
|
|
288 /* We deal only with pipes, for we're using PeekNamedPipe api */
|
|
289 assert (GetFileType (hpipe) == FILE_TYPE_PIPE);
|
|
290
|
276
|
291 s->thread_data = slurper_allocate_shared_data();
|
274
|
292
|
276
|
293 /* Create reader thread. This could fail, so do not create events
|
|
294 until thread is created */
|
|
295 hthread = CreateThread (NULL, 0, slurp_thread, (LPVOID)s->thread_data,
|
|
296 CREATE_SUSPENDED, &thread_id_unused);
|
|
297 if (hthread == NULL)
|
274
|
298 {
|
|
299 Lstream_delete (lstr);
|
276
|
300 s->thread_data->inuse_p=0;
|
274
|
301 return Qnil;
|
|
302 }
|
|
303
|
276
|
304 /* Shared data are initially owned by both main and slurper
|
|
305 threads. */
|
|
306 s->thread_data->lock_count = 2;
|
|
307 s->thread_data->die_p = 0;
|
|
308 s->thread_data->eof_p = FALSE;
|
|
309 s->thread_data->error_p = FALSE;
|
|
310 s->thread_data->hpipe = hpipe;
|
|
311 s->user_data = param;
|
|
312
|
274
|
313 /* hev_thread is a manual-reset event, initially signaled */
|
276
|
314 s->thread_data->hev_thread = CreateEvent (NULL, TRUE, TRUE, NULL);
|
274
|
315 /* hev_caller is a manual-reset event, initially nonsignaled */
|
276
|
316 s->thread_data->hev_caller = CreateEvent (NULL, TRUE, FALSE, NULL);
|
274
|
317 /* hev_unsleep is a manual-reset event, initially nonsignaled */
|
276
|
318 s->thread_data->hev_unsleep = CreateEvent (NULL, TRUE, FALSE, NULL);
|
274
|
319
|
|
320 /* Now let it go */
|
276
|
321 ResumeThread (hthread);
|
|
322 CloseHandle (hthread);
|
274
|
323
|
|
324 lstr->flags |= LSTREAM_FL_CLOSE_AT_DISKSAVE;
|
|
325 XSETLSTREAM (obj, lstr);
|
|
326 return obj;
|
|
327 }
|
|
328
|
|
329 static LPARAM
|
|
330 get_ntpipe_input_stream_param (Lstream *stream)
|
|
331 {
|
|
332 struct ntpipe_slurp_stream* s = NTPIPE_SLURP_STREAM_DATA(stream);
|
|
333 return s->user_data;
|
|
334 }
|
|
335
|
|
336 static HANDLE
|
|
337 get_ntpipe_input_stream_waitable (Lstream *stream)
|
|
338 {
|
|
339 struct ntpipe_slurp_stream* s = NTPIPE_SLURP_STREAM_DATA(stream);
|
276
|
340 return s->thread_data->hev_caller;
|
274
|
341 }
|
|
342
|
|
343 static int
|
|
344 ntpipe_slurp_reader (Lstream *stream, unsigned char *data, size_t size)
|
|
345 {
|
|
346 /* This function must be called from the main thread only */
|
276
|
347 struct ntpipe_slurp_stream_shared_data* s =
|
|
348 NTPIPE_SLURP_STREAM_DATA(stream)->thread_data;
|
274
|
349
|
|
350 if (!s->die_p)
|
|
351 {
|
|
352 DWORD wait_result;
|
276
|
353 /* Disallow pipe read delay for the thread: we need a character
|
|
354 ASAP */
|
274
|
355 SetEvent (s->hev_unsleep);
|
|
356
|
276
|
357 /* Check if we have a character ready. Give it a short delay,
|
|
358 for the thread to awake from pipe delay, just ion case*/
|
274
|
359 wait_result = WaitForSingleObject (s->hev_caller, 2);
|
|
360
|
|
361 /* Revert to the normal sleep behavior. */
|
|
362 ResetEvent (s->hev_unsleep);
|
|
363
|
|
364 /* If there's no byte buffered yet, give up */
|
|
365 if (wait_result == WAIT_TIMEOUT)
|
|
366 {
|
|
367 errno = EAGAIN;
|
|
368 return -1;
|
|
369 }
|
|
370 }
|
|
371
|
|
372 /* Reset caller unlock event now, as we've handled the pending
|
|
373 process output event */
|
|
374 ResetEvent (s->hev_caller);
|
|
375
|
|
376 /* It is now safe to do anything with contents of S, except for
|
|
377 changing s->die_p, which still should be interlocked */
|
|
378
|
|
379 if (s->eof_p)
|
|
380 return 0;
|
|
381 if (s->error_p || s->die_p)
|
|
382 return -1;
|
|
383
|
276
|
384 /* Ok, there were no error neither eof - we've got a byte from the
|
|
385 pipe */
|
274
|
386 *(data++) = s->onebyte;
|
|
387 --size;
|
|
388
|
276
|
389 {
|
|
390 DWORD bytes_read = 0;
|
|
391 if (size > 0)
|
|
392 {
|
|
393 DWORD bytes_available;
|
274
|
394
|
276
|
395 /* If the api call fails, return at least one byte already
|
|
396 read. ReadFile in thread will return error */
|
|
397 if (PeekNamedPipe (s->hpipe, NULL, 0, NULL, &bytes_available, NULL))
|
|
398 {
|
274
|
399
|
276
|
400 /* Fetch available bytes. The same consideration applies,
|
|
401 so do not check for errors. ReadFile in the thread will
|
|
402 fail if the next call fails. */
|
|
403 if (bytes_available)
|
|
404 ReadFile (s->hpipe, data, min (bytes_available, size),
|
|
405 &bytes_read, NULL);
|
|
406 }
|
|
407
|
|
408 /* Now we can unblock thread, so it attempts to read more */
|
|
409 SetEvent (s->hev_thread);
|
|
410 return bytes_read + 1;
|
|
411 }
|
|
412 }
|
278
|
413 return 0;
|
274
|
414 }
|
|
415
|
|
416 static int
|
|
417 ntpipe_slurp_closer (Lstream *stream)
|
|
418 {
|
|
419 /* This function must be called from the main thread only */
|
276
|
420 struct ntpipe_slurp_stream_shared_data* s =
|
|
421 NTPIPE_SLURP_STREAM_DATA(stream)->thread_data;
|
274
|
422
|
|
423 /* Force thread to stop */
|
|
424 InterlockedIncrement (&s->die_p);
|
|
425
|
276
|
426 /* Set events which could possibly block slurper. Let it finish soon
|
|
427 or later. */
|
274
|
428 SetEvent (s->hev_unsleep);
|
|
429 SetEvent (s->hev_thread);
|
|
430
|
276
|
431 /* Unlock and maybe free shared data */
|
|
432 slurper_free_shared_data_maybe (s);
|
274
|
433
|
|
434 return 0;
|
|
435 }
|
|
436
|
|
437 static void
|
|
438 init_slurp_stream (void)
|
|
439 {
|
|
440 LSTREAM_HAS_METHOD (ntpipe_slurp, reader);
|
|
441 LSTREAM_HAS_METHOD (ntpipe_slurp, closer);
|
|
442 }
|
|
443
|
|
444 /************************************************************************/
|
|
445 /* Pipe outstream - writes process input */
|
|
446 /************************************************************************/
|
|
447
|
|
448 #define MAX_FLUSH_TIME 500
|
|
449
|
|
450 #define NTPIPE_SHOVE_STREAM_DATA(stream) \
|
|
451 LSTREAM_TYPE_DATA (stream, ntpipe_shove)
|
|
452
|
276
|
453 #define MAX_SHOVE_BUFFER_SIZE 128
|
|
454
|
274
|
455 struct ntpipe_shove_stream
|
|
456 {
|
|
457 LPARAM user_data; /* Any user data stored in the stream object */
|
|
458 HANDLE hev_thread; /* Our thread blocks on this, signaled by caller */
|
|
459 /* This is an auto-reset object. */
|
|
460 HANDLE hpipe; /* Pipe write end handle. */
|
|
461 HANDLE hthread; /* Reader thread handle. */
|
276
|
462 char buffer[MAX_SHOVE_BUFFER_SIZE]; /* Buffer being written */
|
274
|
463 DWORD size; /* Number of bytes to write */
|
276
|
464 LONG die_p; /* Thread must exit ASAP if non-zero */
|
|
465 LONG idle_p; /* Non-zero if thread is waiting for job */
|
274
|
466 BOOL error_p : 1; /* Read error other than EOF/broken pipe */
|
|
467 BOOL blocking_p : 1;/* Last write attempt would cause blocking */
|
|
468 };
|
|
469
|
|
470 DEFINE_LSTREAM_IMPLEMENTATION ("ntpipe-output", lstream_ntpipe_shove,
|
|
471 sizeof (struct ntpipe_shove_stream));
|
|
472
|
|
473 static DWORD WINAPI
|
|
474 shove_thread (LPVOID vparam)
|
|
475 {
|
|
476 struct ntpipe_shove_stream *s = (struct ntpipe_shove_stream*) vparam;
|
|
477
|
|
478 for (;;)
|
|
479 {
|
|
480 DWORD bytes_written;
|
|
481
|
|
482 /* Block on event and wait for a job */
|
|
483 InterlockedIncrement (&s->idle_p);
|
|
484 WaitForSingleObject (s->hev_thread, INFINITE);
|
|
485
|
|
486 if (s->die_p)
|
|
487 break;
|
|
488
|
|
489 /* Write passed buffer */
|
|
490 if (!WriteFile (s->hpipe, s->buffer, s->size, &bytes_written, NULL)
|
|
491 || bytes_written != s->size)
|
|
492 {
|
|
493 s->error_p = TRUE;
|
|
494 InterlockedIncrement (&s->die_p);
|
|
495 }
|
|
496
|
|
497 if (s->die_p)
|
|
498 break;
|
|
499 }
|
|
500
|
|
501 return 0;
|
|
502 }
|
|
503
|
|
504 static Lisp_Object
|
|
505 make_ntpipe_output_stream (HANDLE hpipe, LPARAM param)
|
|
506 {
|
|
507 Lisp_Object obj;
|
|
508 Lstream *lstr = Lstream_new (lstream_ntpipe_shove, "w");
|
|
509 struct ntpipe_shove_stream* s = NTPIPE_SHOVE_STREAM_DATA (lstr);
|
|
510 DWORD thread_id_unused;
|
|
511
|
|
512 s->die_p = 0;
|
|
513 s->error_p = FALSE;
|
|
514 s->hpipe = hpipe;
|
|
515 s->user_data = param;
|
|
516
|
|
517 /* Create reader thread. This could fail, so do not
|
|
518 create the event until thread is created */
|
|
519 s->hthread = CreateThread (NULL, 0, shove_thread, (LPVOID)s,
|
|
520 CREATE_SUSPENDED, &thread_id_unused);
|
|
521 if (s->hthread == NULL)
|
|
522 {
|
|
523 Lstream_delete (lstr);
|
|
524 return Qnil;
|
|
525 }
|
|
526
|
|
527 /* hev_thread is an auto-reset event, initially nonsignaled */
|
|
528 s->hev_thread = CreateEvent (NULL, FALSE, FALSE, NULL);
|
|
529
|
|
530 /* Now let it go */
|
|
531 ResumeThread (s->hthread);
|
|
532
|
|
533 lstr->flags |= LSTREAM_FL_CLOSE_AT_DISKSAVE;
|
|
534 XSETLSTREAM (obj, lstr);
|
|
535 return obj;
|
|
536 }
|
|
537
|
|
538 static LPARAM
|
|
539 get_ntpipe_output_stream_param (Lstream *stream)
|
|
540 {
|
|
541 struct ntpipe_shove_stream* s = NTPIPE_SHOVE_STREAM_DATA(stream);
|
|
542 return s->user_data;
|
|
543 }
|
|
544
|
|
545 static int
|
|
546 ntpipe_shove_writer (Lstream *stream, const unsigned char *data, size_t size)
|
|
547 {
|
|
548 struct ntpipe_shove_stream* s = NTPIPE_SHOVE_STREAM_DATA(stream);
|
|
549
|
|
550 if (s->error_p)
|
|
551 return -1;
|
|
552
|
|
553 s->blocking_p = !s->idle_p;
|
|
554 if (s->blocking_p)
|
|
555 return 0;
|
|
556
|
276
|
557 if (size>MAX_SHOVE_BUFFER_SIZE)
|
|
558 return 0;
|
|
559
|
274
|
560 memcpy (s->buffer, data, size);
|
|
561 s->size = size;
|
|
562
|
|
563 /* Start output */
|
|
564 InterlockedDecrement (&s->idle_p);
|
|
565 SetEvent (s->hev_thread);
|
|
566 return size;
|
|
567 }
|
|
568
|
|
569 static int
|
|
570 ntpipe_shove_was_blocked_p (Lstream *stream)
|
|
571 {
|
|
572 struct ntpipe_shove_stream* s = NTPIPE_SHOVE_STREAM_DATA(stream);
|
|
573 return s->blocking_p;
|
|
574 }
|
|
575
|
|
576 static int
|
|
577 ntpipe_shove_flusher (Lstream *stream)
|
|
578 {
|
|
579 struct ntpipe_shove_stream* s = NTPIPE_SHOVE_STREAM_DATA(stream);
|
|
580 int i;
|
|
581
|
|
582 if (s->error_p)
|
|
583 return -1;
|
|
584
|
|
585 /* We do not want to be blocked forever. Instead, we wait
|
|
586 about 0.5 second for output to finish. If this does
|
|
587 not help, we just return flush failure. */
|
|
588 for (i = 0; i < MAX_FLUSH_TIME / 50; ++i)
|
|
589 {
|
|
590 if (s->idle_p)
|
|
591 return 0;
|
|
592 Sleep (50);
|
|
593 }
|
|
594 return -1;
|
|
595 }
|
|
596
|
|
597 static int
|
|
598 ntpipe_shove_closer (Lstream *stream)
|
|
599 {
|
|
600 struct ntpipe_shove_stream* s = NTPIPE_SHOVE_STREAM_DATA(stream);
|
|
601
|
|
602 /* Force thread stop */
|
|
603 InterlockedIncrement (&s->die_p);
|
|
604
|
|
605 /* Close pipe handle, possibly breaking it */
|
|
606 CloseHandle (s->hpipe);
|
|
607
|
|
608 /* Thread will end upon unblocking */
|
|
609 SetEvent (s->hev_thread);
|
|
610
|
|
611 /* Wait while thread terminates */
|
|
612 WaitForSingleObject (s->hthread, INFINITE);
|
|
613 CloseHandle (s->hthread);
|
|
614
|
|
615 /* Destroy the event */
|
|
616 CloseHandle (s->hev_thread);
|
|
617
|
|
618 return 0;
|
|
619 }
|
|
620
|
|
621 static void
|
|
622 init_shove_stream (void)
|
|
623 {
|
|
624 LSTREAM_HAS_METHOD (ntpipe_shove, writer);
|
|
625 LSTREAM_HAS_METHOD (ntpipe_shove, flusher);
|
|
626 LSTREAM_HAS_METHOD (ntpipe_shove, was_blocked_p);
|
|
627 LSTREAM_HAS_METHOD (ntpipe_shove, closer);
|
|
628 }
|
|
629
|
|
630 /************************************************************************/
|
|
631 /* Dispatch queue management */
|
|
632 /************************************************************************/
|
227
|
633
|
223
|
634 static int
|
|
635 mswindows_user_event_p (struct Lisp_Event* sevt)
|
|
636 {
|
|
637 return (sevt->event_type == key_press_event
|
|
638 || sevt->event_type == button_press_event
|
249
|
639 || sevt->event_type == button_release_event
|
|
640 || sevt->event_type == dnd_drop_event);
|
223
|
641 }
|
|
642
|
249
|
643 /*
|
223
|
644 * Add an emacs event to the proper dispatch queue
|
219
|
645 */
|
276
|
646 static void
|
213
|
647 mswindows_enqueue_dispatch_event (Lisp_Object event)
|
|
648 {
|
223
|
649 int user_p = mswindows_user_event_p (XEVENT(event));
|
|
650 enqueue_event (event,
|
|
651 user_p ? &mswindows_u_dispatch_event_queue :
|
|
652 &mswindows_s_dispatch_event_queue,
|
|
653 user_p ? &mswindows_u_dispatch_event_queue_tail :
|
|
654 &mswindows_s_dispatch_event_queue_tail);
|
|
655
|
276
|
656 /* Avoid blocking on WaitMessage */
|
223
|
657 PostMessage (NULL, XM_BUMPQUEUE, 0, 0);
|
213
|
658 }
|
|
659
|
249
|
660 void
|
276
|
661 mswindows_bump_queue (void)
|
|
662 {
|
|
663 /* Bump queue, by putting in an empty event */
|
|
664 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
|
|
665 struct Lisp_Event* event = XEVENT (emacs_event);
|
|
666
|
|
667 event->event_type = empty_event;
|
|
668
|
|
669 mswindows_enqueue_dispatch_event (emacs_event);
|
|
670 }
|
|
671
|
|
672 static void
|
249
|
673 mswindows_enqueue_magic_event (HWND hwnd, UINT message)
|
|
674 {
|
|
675 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
|
|
676 struct Lisp_Event* event = XEVENT (emacs_event);
|
|
677
|
|
678 event->channel = mswindows_find_frame (hwnd);
|
|
679 event->timestamp = GetMessageTime();
|
|
680 event->event_type = magic_event;
|
|
681 EVENT_MSWINDOWS_MAGIC_TYPE (event) = message;
|
|
682
|
|
683 mswindows_enqueue_dispatch_event (emacs_event);
|
|
684 }
|
|
685
|
|
686 static void
|
274
|
687 mswindows_enqueue_process_event (struct Lisp_Process* p)
|
|
688 {
|
|
689 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
|
|
690 struct Lisp_Event* event = XEVENT (emacs_event);
|
|
691 Lisp_Object process;
|
|
692 XSETPROCESS (process, p);
|
|
693
|
|
694 event->event_type = process_event;
|
|
695 event->timestamp = GetTickCount ();
|
|
696 event->event.process.process = process;
|
|
697
|
|
698 mswindows_enqueue_dispatch_event (emacs_event);
|
|
699 }
|
|
700
|
|
701 static void
|
249
|
702 mswindows_enqueue_mouse_button_event (HWND hwnd, UINT message, POINTS where, DWORD when)
|
|
703 {
|
|
704
|
|
705 /* We always use last message time, because mouse button
|
|
706 events may get delayed, and XEmacs double click
|
|
707 recognition will fail */
|
|
708
|
|
709 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
|
|
710 struct Lisp_Event* event = XEVENT(emacs_event);
|
|
711
|
|
712 event->channel = mswindows_find_frame(hwnd);
|
|
713 event->timestamp = when;
|
|
714 event->event.button.button =
|
|
715 (message==WM_LBUTTONDOWN || message==WM_LBUTTONUP) ? 1 :
|
|
716 ((message==WM_RBUTTONDOWN || message==WM_RBUTTONUP) ? 3 : 2);
|
|
717 event->event.button.x = where.x;
|
|
718 event->event.button.y = where.y;
|
|
719 event->event.button.modifiers = mswindows_modifier_state (NULL, 0);
|
|
720
|
|
721 if (message==WM_LBUTTONDOWN || message==WM_MBUTTONDOWN ||
|
|
722 message==WM_RBUTTONDOWN)
|
|
723 {
|
|
724 event->event_type = button_press_event;
|
|
725 SetCapture (hwnd);
|
|
726 }
|
|
727 else
|
|
728 {
|
|
729 event->event_type = button_release_event;
|
|
730 ReleaseCapture ();
|
|
731 }
|
|
732
|
|
733 mswindows_enqueue_dispatch_event (emacs_event);
|
|
734 }
|
|
735
|
|
736 static void
|
|
737 mswindows_enqueue_keypress_event (HWND hwnd, Lisp_Object keysym, int mods)
|
|
738 {
|
|
739 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
|
|
740 struct Lisp_Event* event = XEVENT(emacs_event);
|
|
741
|
|
742 event->channel = mswindows_find_console(hwnd);
|
|
743 event->timestamp = GetMessageTime();
|
|
744 event->event_type = key_press_event;
|
|
745 event->event.key.keysym = keysym;
|
|
746 event->event.key.modifiers = mods;
|
|
747 mswindows_enqueue_dispatch_event (emacs_event);
|
|
748 }
|
|
749
|
219
|
750 /*
|
223
|
751 * Remove and return the first emacs event on the dispatch queue.
|
|
752 * Give a preference to user events over non-user ones.
|
219
|
753 */
|
213
|
754 static Lisp_Object
|
223
|
755 mswindows_dequeue_dispatch_event ()
|
213
|
756 {
|
|
757 Lisp_Object event;
|
223
|
758 struct Lisp_Event* sevt;
|
|
759
|
|
760 assert (!NILP(mswindows_u_dispatch_event_queue) ||
|
|
761 !NILP(mswindows_s_dispatch_event_queue));
|
|
762
|
|
763 event = dequeue_event (
|
|
764 NILP(mswindows_u_dispatch_event_queue) ?
|
|
765 &mswindows_s_dispatch_event_queue :
|
|
766 &mswindows_u_dispatch_event_queue,
|
|
767 NILP(mswindows_u_dispatch_event_queue) ?
|
|
768 &mswindows_s_dispatch_event_queue_tail :
|
|
769 &mswindows_u_dispatch_event_queue_tail);
|
|
770
|
|
771 sevt = XEVENT(event);
|
|
772 if (sevt->event_type == key_press_event
|
|
773 && (sevt->event.key.modifiers & FAKE_MOD_QUIT))
|
|
774 {
|
|
775 sevt->event.key.modifiers &= ~FAKE_MOD_QUIT;
|
|
776 --mswindows_quit_chars_count;
|
|
777 }
|
|
778
|
213
|
779 return event;
|
|
780 }
|
|
781
|
|
782 /*
|
219
|
783 * Remove and return the first emacs event on the dispatch queue that matches
|
223
|
784 * the supplied event
|
|
785 * Timeout event matches if interval_id equals to that of the given event.
|
|
786 * Keypress event matches if logical AND between modifiers bitmask of the
|
|
787 * event in the queue and that of the given event is non-zero
|
|
788 * For all other event types, this function asserts.
|
219
|
789 */
|
223
|
790
|
219
|
791 Lisp_Object
|
223
|
792 mswindows_cancel_dispatch_event (struct Lisp_Event* match)
|
219
|
793 {
|
|
794 Lisp_Object event;
|
|
795 Lisp_Object previous_event=Qnil;
|
223
|
796 int user_p = mswindows_user_event_p (match);
|
|
797 Lisp_Object* head = user_p ? &mswindows_u_dispatch_event_queue :
|
|
798 &mswindows_s_dispatch_event_queue;
|
|
799 Lisp_Object* tail = user_p ? &mswindows_u_dispatch_event_queue_tail :
|
|
800 &mswindows_s_dispatch_event_queue_tail;
|
219
|
801
|
223
|
802 assert (match->event_type == timeout_event
|
|
803 || match->event_type == key_press_event);
|
219
|
804
|
223
|
805 EVENT_CHAIN_LOOP (event, *head)
|
|
806 {
|
|
807 int found = 1;
|
|
808 if (XEVENT_TYPE (event) != match->event_type)
|
|
809 found = 0;
|
|
810 if (found && match->event_type == timeout_event
|
|
811 && (XEVENT(event)->event.timeout.interval_id !=
|
|
812 match->event.timeout.interval_id))
|
|
813 found = 0;
|
|
814 if (found && match->event_type == key_press_event
|
|
815 && ((XEVENT(event)->event.key.modifiers &
|
|
816 match->event.key.modifiers) == 0))
|
|
817 found = 0;
|
|
818
|
|
819 if (found)
|
|
820 {
|
|
821 if (NILP (previous_event))
|
|
822 dequeue_event (head, tail);
|
|
823 else
|
|
824 {
|
|
825 XSET_EVENT_NEXT (previous_event, XEVENT_NEXT (event));
|
|
826 if (EQ (*tail, event))
|
|
827 *tail = previous_event;
|
|
828 }
|
|
829
|
|
830 return event;
|
|
831 }
|
219
|
832 previous_event = event;
|
223
|
833 }
|
239
|
834 return Qnil;
|
219
|
835 }
|
274
|
836
|
|
837 /************************************************************************/
|
|
838 /* Waitable handles manipulation */
|
|
839 /************************************************************************/
|
|
840 static int
|
|
841 find_waitable_handle (HANDLE h)
|
|
842 {
|
|
843 int i;
|
|
844 for (i = 0; i < mswindows_waitable_count; ++i)
|
|
845 if (mswindows_waitable_handles[i] == h)
|
|
846 return i;
|
219
|
847
|
274
|
848 return -1;
|
|
849 }
|
249
|
850
|
274
|
851 static BOOL
|
|
852 add_waitable_handle (HANDLE h)
|
|
853 {
|
|
854 assert (find_waitable_handle (h) < 0);
|
|
855 if (mswindows_waitable_count == MAX_WAITABLE)
|
|
856 return FALSE;
|
|
857
|
|
858 mswindows_waitable_handles [mswindows_waitable_count++] = h;
|
|
859 return TRUE;
|
|
860 }
|
|
861
|
|
862 static void
|
|
863 remove_waitable_handle (HANDLE h)
|
|
864 {
|
|
865 int ix = find_waitable_handle (h);
|
|
866 if (ix < 0)
|
|
867 return;
|
|
868
|
|
869 mswindows_waitable_handles [ix] =
|
|
870 mswindows_waitable_handles [--mswindows_waitable_count];
|
|
871 }
|
|
872
|
|
873
|
249
|
874 /************************************************************************/
|
|
875 /* Event pump */
|
|
876 /************************************************************************/
|
|
877
|
231
|
878 static Lisp_Object
|
|
879 mswindows_modal_loop_error_handler (Lisp_Object cons_sig_data,
|
|
880 Lisp_Object u_n_u_s_e_d)
|
|
881 {
|
|
882 mswindows_error_caught_in_modal_loop = cons_sig_data;
|
|
883 return Qunbound;
|
|
884 }
|
|
885
|
|
886 Lisp_Object
|
|
887 mswindows_protect_modal_loop (Lisp_Object (*bfun) (Lisp_Object barg),
|
|
888 Lisp_Object barg)
|
|
889 {
|
|
890 Lisp_Object tmp;
|
|
891
|
|
892 ++mswindows_in_modal_loop;
|
|
893 tmp = condition_case_1 (Qt,
|
|
894 bfun, barg,
|
|
895 mswindows_modal_loop_error_handler, Qnil);
|
|
896 --mswindows_in_modal_loop;
|
|
897
|
|
898 return tmp;
|
|
899 }
|
|
900
|
|
901 void
|
|
902 mswindows_unmodalize_signal_maybe (void)
|
|
903 {
|
|
904 if (!NILP (mswindows_error_caught_in_modal_loop))
|
|
905 {
|
|
906 /* Got an error while messages were pumped while
|
|
907 in window procedure - have to resignal */
|
|
908 Lisp_Object sym = XCAR (mswindows_error_caught_in_modal_loop);
|
|
909 Lisp_Object data = XCDR (mswindows_error_caught_in_modal_loop);
|
|
910 mswindows_error_caught_in_modal_loop = Qnil;
|
|
911 Fsignal (sym, data);
|
|
912 }
|
|
913 }
|
|
914
|
219
|
915 /*
|
227
|
916 * This is an unsafe part of event pump, guarded by
|
|
917 * condition_case. See mswindows_pump_outstanding_events
|
|
918 */
|
|
919 static Lisp_Object
|
|
920 mswindows_unsafe_pump_events (Lisp_Object u_n_u_s_e_d)
|
|
921 {
|
|
922 /* This function can call lisp */
|
|
923 Lisp_Object event = Fmake_event (Qnil, Qnil);
|
|
924 struct gcpro gcpro1;
|
|
925 int do_redisplay = 0;
|
|
926 GCPRO1 (event);
|
|
927
|
|
928 while (detect_input_pending ())
|
|
929 {
|
|
930 Fnext_event (event, Qnil);
|
|
931 Fdispatch_event (event);
|
|
932 do_redisplay = 1;
|
|
933 }
|
|
934
|
|
935 if (do_redisplay)
|
|
936 redisplay ();
|
|
937
|
|
938 Fdeallocate_event (event);
|
|
939 UNGCPRO;
|
|
940
|
|
941 /* Qt becomes return value of mswindows_pump_outstanding_events
|
|
942 once we get here */
|
|
943 return Qt;
|
|
944 }
|
|
945
|
|
946 /*
|
|
947 * This function pumps emacs events, while available, by using
|
|
948 * next_message/dispatch_message loop. Errors are trapped around
|
|
949 * the loop so the function always returns.
|
|
950 *
|
|
951 * Windows message queue is not looked into during the call,
|
|
952 * neither are waitable handles checked. The function pumps
|
|
953 * thus only dispatch events already queued, as well as those
|
|
954 * resulted in dispatching thereof. This is done by setting
|
231
|
955 * module local variable mswidows_in_modal_loop to nonzero.
|
227
|
956 *
|
231
|
957 * Return value is Qt if no errors was trapped, or Qunbound if
|
227
|
958 * there was an error.
|
|
959 *
|
|
960 * In case of error, a cons representing the error, in the
|
|
961 * form (SIGNAL . DATA), is stored in the module local variable
|
231
|
962 * mswindows_error_caught_in_modal_loop. This error is signaled
|
227
|
963 * again when DispatchMessage returns. Thus, Windows internal
|
|
964 * modal loops are protected against throws, which are proven
|
|
965 * to corrupt internal Windows structures.
|
|
966 *
|
231
|
967 * In case of success, mswindows_error_caught_in_modal_loop is
|
227
|
968 * assigned Qnil.
|
|
969 *
|
231
|
970 * If the value of mswindows_error_caught_in_modal_loop is not
|
227
|
971 * nil already upon entry, the function just returns non-nil.
|
|
972 * This situation means that a new event has been queued while
|
|
973 * cancleng mode. The event will be dequeued on the next regular
|
|
974 * call of next-event; the pump is off since error is caught.
|
|
975 * The caller must *unconditionally* cancel modal loop if the
|
|
976 * value returned by this function is nil. Otherwise, everything
|
|
977 * will become frozen until the modal loop exits under normal
|
|
978 * condition (scrollbar drag is released, menu closed etc.)
|
|
979 */
|
|
980 Lisp_Object
|
|
981 mswindows_pump_outstanding_events (void)
|
|
982 {
|
|
983 /* This function can call lisp */
|
|
984
|
|
985 Lisp_Object result = Qt;
|
249
|
986 struct gcpro gcpro1;
|
|
987 GCPRO1 (result);
|
|
988
|
231
|
989 if (NILP(mswindows_error_caught_in_modal_loop))
|
|
990 result = mswindows_protect_modal_loop (mswindows_unsafe_pump_events, Qnil);
|
249
|
991 UNGCPRO;
|
227
|
992 return result;
|
|
993 }
|
|
994
|
223
|
995 static void
|
|
996 mswindows_drain_windows_queue ()
|
|
997 {
|
|
998 MSG msg;
|
|
999 while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
|
227
|
1000 {
|
|
1001 DispatchMessage (&msg);
|
231
|
1002 mswindows_unmodalize_signal_maybe ();
|
227
|
1003 }
|
|
1004 }
|
|
1005
|
|
1006 /*
|
|
1007 * This is a special flavour of the mswindows_need_event function,
|
|
1008 * used while in event pump. Actually, there is only kind of events
|
|
1009 * allowed while in event pump: a timer. An attempt to fetch any
|
|
1010 * other event leads to a dealock, as there's no source of user input
|
|
1011 * ('cause event pump mirrors windows modal loop, which is a sole
|
|
1012 * owner of thread message queue).
|
|
1013 *
|
|
1014 * To detect this, we use a counter of active timers, and allow
|
|
1015 * fetching WM_TIMER messages. Instead of trying to fetch a WM_TIMER
|
|
1016 * which will never come when there are no pending timers, which leads
|
|
1017 * to deadlock, we simply signal an error.
|
|
1018 */
|
|
1019 static void
|
274
|
1020 mswindows_need_event_in_modal_loop (int badly_p)
|
227
|
1021 {
|
|
1022 MSG msg;
|
|
1023
|
|
1024 /* Check if already have one */
|
|
1025 if (!NILP (mswindows_u_dispatch_event_queue)
|
|
1026 || !NILP (mswindows_s_dispatch_event_queue))
|
|
1027 return;
|
|
1028
|
|
1029 /* No event is ok */
|
|
1030 if (!badly_p)
|
|
1031 return;
|
|
1032
|
|
1033 /* We do not check the _u_ queue, because timers go to _s_ */
|
|
1034 while (NILP (mswindows_s_dispatch_event_queue))
|
|
1035 {
|
|
1036 /* We'll deadlock if go waiting */
|
|
1037 if (mswindows_pending_timers_count == 0)
|
|
1038 error ("Deadlock due to an attempt to call next-event in a wrong context");
|
|
1039
|
|
1040 /* Fetch and dispatch any pending timers */
|
|
1041 GetMessage (&msg, NULL, WM_TIMER, WM_TIMER);
|
|
1042 DispatchMessage (&msg);
|
|
1043 }
|
223
|
1044 }
|
|
1045
|
|
1046 /*
|
|
1047 * This drains the event queue and fills up two internal queues until
|
|
1048 * an event of a type specified by USER_P is retrieved.
|
|
1049 *
|
|
1050 *
|
|
1051 * Used by emacs_mswindows_event_pending_p and emacs_mswindows_next_event
|
|
1052 */
|
|
1053 static void
|
274
|
1054 mswindows_need_event (int badly_p)
|
223
|
1055 {
|
|
1056 int active;
|
|
1057
|
231
|
1058 if (mswindows_in_modal_loop)
|
227
|
1059 {
|
274
|
1060 mswindows_need_event_in_modal_loop (badly_p);
|
227
|
1061 return;
|
|
1062 }
|
|
1063
|
223
|
1064 /* Have to drain Windows message queue first, otherwise, we may miss
|
|
1065 quit char when called from quit_p */
|
|
1066 mswindows_drain_windows_queue ();
|
|
1067
|
274
|
1068 while (NILP (mswindows_u_dispatch_event_queue)
|
|
1069 && NILP (mswindows_s_dispatch_event_queue))
|
278
|
1070 {
|
|
1071 #ifdef HAVE_MSG_SELECT
|
|
1072 int i;
|
|
1073 SELECT_TYPE temp_mask = input_wait_mask;
|
|
1074 EMACS_TIME sometime;
|
|
1075 EMACS_SELECT_TIME select_time_to_block, *pointer_to_this;
|
|
1076
|
|
1077 if (badly_p)
|
|
1078 pointer_to_this = 0;
|
|
1079 else
|
|
1080 {
|
|
1081 EMACS_SET_SECS_USECS (sometime, 0, 0);
|
|
1082 EMACS_TIME_TO_SELECT_TIME (sometime, select_time_to_block);
|
|
1083 pointer_to_this = &select_time_to_block;
|
|
1084 }
|
|
1085 active = select (MAXDESC, &temp_mask, 0, 0, pointer_to_this);
|
|
1086
|
|
1087 if (active == 0)
|
|
1088 {
|
|
1089 return; /* timeout */
|
|
1090 }
|
|
1091 else if (active > 0)
|
|
1092 {
|
|
1093 if (FD_ISSET (windows_fd, &temp_mask))
|
|
1094 {
|
|
1095 mswindows_drain_windows_queue ();
|
|
1096 }
|
|
1097
|
|
1098 /* Look for a process event */
|
|
1099 for (i = 0; i < MAXDESC-1; i++)
|
|
1100 {
|
|
1101 if (FD_ISSET (i, &temp_mask))
|
|
1102 {
|
|
1103 if (FD_ISSET (i, &process_only_mask))
|
|
1104 {
|
|
1105 struct Lisp_Process *p =
|
|
1106 get_process_from_usid (FD_TO_USID(i));
|
|
1107
|
|
1108 mswindows_enqueue_process_event (p);
|
|
1109 }
|
|
1110 else if (FD_ISSET (i, &tty_only_mask))
|
|
1111 {
|
|
1112 /* do we care about tty events? Do we
|
|
1113 ever get tty events? */
|
|
1114 }
|
|
1115 else
|
|
1116 {
|
|
1117 /* We might get here when a fake event came
|
|
1118 through a signal. Return a dummy event, so
|
|
1119 that a cycle of the command loop will
|
|
1120 occur. */
|
|
1121 drain_signal_event_pipe ();
|
|
1122 mswindows_bump_queue();
|
|
1123 }
|
|
1124 }
|
|
1125 }
|
|
1126 }
|
|
1127 else if (active==-1)
|
|
1128 {
|
|
1129 if (errno != EINTR)
|
|
1130 {
|
|
1131 /* something bad happended */
|
|
1132 assert(0);
|
|
1133 }
|
|
1134 }
|
|
1135 else
|
|
1136 {
|
|
1137 assert(0);
|
|
1138 }
|
|
1139 #else
|
|
1140 /* Now try getting a message or process event */
|
223
|
1141 active = MsgWaitForMultipleObjects (mswindows_waitable_count,
|
274
|
1142 mswindows_waitable_handles,
|
223
|
1143 FALSE, badly_p ? INFINITE : 0,
|
|
1144 QS_ALLINPUT);
|
|
1145
|
|
1146 /* This will assert if handle being waited for becomes abandoned.
|
|
1147 Not the case currently tho */
|
|
1148 assert ((!badly_p && active == WAIT_TIMEOUT) ||
|
|
1149 (active >= WAIT_OBJECT_0 &&
|
|
1150 active <= WAIT_OBJECT_0 + mswindows_waitable_count));
|
|
1151
|
|
1152 if (active == WAIT_TIMEOUT)
|
|
1153 {
|
|
1154 /* No luck trying - just return what we've already got */
|
|
1155 return;
|
|
1156 }
|
|
1157 else if (active == WAIT_OBJECT_0 + mswindows_waitable_count)
|
|
1158 {
|
|
1159 /* Got your message, thanks */
|
|
1160 mswindows_drain_windows_queue ();
|
|
1161 }
|
|
1162 else
|
|
1163 {
|
274
|
1164 int ix = active - WAIT_OBJECT_0;
|
|
1165 /* First, try to find which process' ouptut has signaled */
|
|
1166 struct Lisp_Process *p =
|
|
1167 get_process_from_usid (HANDLE_TO_USID (mswindows_waitable_handles[ix]));
|
|
1168 if (p != NULL)
|
|
1169 {
|
|
1170 /* Found a signaled process input handle */
|
|
1171 mswindows_enqueue_process_event (p);
|
|
1172 }
|
|
1173 else
|
|
1174 {
|
|
1175 /* None. This means that the process handle itself has signaled.
|
|
1176 Remove the handle from the wait vector, and make status_ntoify
|
|
1177 note the exited process */
|
|
1178 mswindows_waitable_handles [ix] =
|
|
1179 mswindows_waitable_handles [--mswindows_waitable_count];
|
|
1180 kick_status_notify ();
|
276
|
1181 /* Have to return something: there may be no accompanying
|
|
1182 process event */
|
|
1183 mswindows_bump_queue ();
|
274
|
1184 }
|
223
|
1185 }
|
278
|
1186 #endif
|
223
|
1187 } /* while */
|
|
1188 }
|
|
1189
|
249
|
1190 /************************************************************************/
|
|
1191 /* Event generators */
|
|
1192 /************************************************************************/
|
|
1193
|
|
1194 /*
|
|
1195 * Callback procedure for synchronous timer messages
|
|
1196 */
|
|
1197 static void CALLBACK
|
|
1198 mswindows_wm_timer_callback (HWND hwnd, UINT umsg, UINT id_timer, DWORD dwtime)
|
|
1199 {
|
|
1200 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
|
|
1201 struct Lisp_Event *event = XEVENT (emacs_event);
|
|
1202
|
|
1203 if (KillTimer (NULL, id_timer))
|
|
1204 --mswindows_pending_timers_count;
|
|
1205
|
|
1206 event->channel = Qnil;
|
|
1207 event->timestamp = dwtime;
|
|
1208 event->event_type = timeout_event;
|
|
1209 event->event.timeout.interval_id = id_timer;
|
|
1210
|
|
1211 mswindows_enqueue_dispatch_event (emacs_event);
|
|
1212 }
|
|
1213
|
|
1214 /*
|
|
1215 * Callback procedure for dde messages
|
|
1216 */
|
|
1217 HDDEDATA CALLBACK
|
|
1218 mswindows_dde_callback (UINT uType, UINT uFmt, HCONV hconv,
|
|
1219 HSZ hszTopic, HSZ hszItem, HDDEDATA hdata,
|
|
1220 DWORD dwData1, DWORD dwData2)
|
|
1221 {
|
|
1222 switch (uType)
|
|
1223 {
|
|
1224 case XTYP_CONNECT:
|
|
1225 if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system))
|
|
1226 return (HDDEDATA)TRUE;
|
|
1227 return (HDDEDATA)FALSE;
|
|
1228
|
|
1229 case XTYP_WILDCONNECT:
|
|
1230 {
|
|
1231 /* We only support one {service,topic} pair */
|
|
1232 HSZPAIR pairs[2] = {
|
|
1233 { mswindows_dde_service, mswindows_dde_topic_system }, { 0, 0 } };
|
|
1234
|
|
1235 if (!(hszItem || DdeCmpStringHandles (hszItem, mswindows_dde_service)) &&
|
|
1236 !(hszTopic || DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system)));
|
|
1237 return (DdeCreateDataHandle (mswindows_dde_mlid, (LPBYTE)pairs,
|
|
1238 sizeof (pairs), 0L, 0, uFmt, 0));
|
|
1239 }
|
|
1240 return (HDDEDATA)NULL;
|
|
1241
|
|
1242 case XTYP_EXECUTE:
|
|
1243 if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system))
|
|
1244 {
|
|
1245 DWORD len = DdeGetData (hdata, NULL, 0, 0);
|
|
1246 char *cmd = alloca (len+1);
|
259
|
1247 #ifdef __CYGWIN32__
|
|
1248 char *cmd_1;
|
|
1249 #endif
|
249
|
1250 char *end;
|
|
1251 Lisp_Object l_dndlist;
|
|
1252 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
|
|
1253 struct Lisp_Event *event = XEVENT (emacs_event);
|
|
1254
|
|
1255 DdeGetData (hdata, cmd, len, 0);
|
|
1256 cmd[len] = '\0';
|
|
1257 DdeFreeDataHandle (hdata);
|
|
1258
|
|
1259 /* Check syntax & that it's an [Open("foo")] command */
|
|
1260 /* #### Ought to be generalised and accept some other commands */
|
|
1261 if (*cmd == '[')
|
|
1262 cmd++;
|
|
1263 if (strnicmp (cmd, MSWINDOWS_DDE_ITEM_OPEN,
|
|
1264 strlen (MSWINDOWS_DDE_ITEM_OPEN)))
|
|
1265 return DDE_FNOTPROCESSED;
|
|
1266 cmd += strlen (MSWINDOWS_DDE_ITEM_OPEN);
|
|
1267 while (*cmd==' ')
|
|
1268 cmd++;
|
|
1269 if (*cmd!='(' || *(cmd+1)!='\"')
|
|
1270 return DDE_FNOTPROCESSED;
|
|
1271 end = (cmd+=2);
|
|
1272 while (*end && *end!='\"')
|
|
1273 end++;
|
|
1274 if (!*end)
|
|
1275 return DDE_FNOTPROCESSED;
|
|
1276 *end = '\0';
|
|
1277 if (*(++end)!=')')
|
|
1278 return DDE_FNOTPROCESSED;
|
|
1279 if (*(++end)==']')
|
|
1280 end++;
|
|
1281 if (*end)
|
|
1282 return DDE_FNOTPROCESSED;
|
259
|
1283 #ifdef __CYGWIN32__
|
|
1284 CYGWIN_CONV_PATH(cmd,cmd_1);
|
|
1285 cmd = cmd_1;
|
|
1286 #endif
|
249
|
1287 l_dndlist = make_ext_string (cmd, strlen(cmd), FORMAT_FILENAME);
|
|
1288
|
|
1289 event->channel = Qnil;
|
|
1290 event->timestamp = GetTickCount();
|
|
1291 event->event_type = dnd_drop_event;
|
|
1292 event->event.dnd_drop.button = 0;
|
|
1293 event->event.dnd_drop.modifiers = 0;
|
|
1294 event->event.dnd_drop.x = -1;
|
|
1295 event->event.dnd_drop.y = -1;
|
|
1296 event->event.dnd_drop.data = Fcons (make_int (DndFile),
|
|
1297 Fcons (l_dndlist, Qnil));
|
|
1298 mswindows_enqueue_dispatch_event (emacs_event);
|
|
1299
|
|
1300 return (HDDEDATA) DDE_FACK;
|
|
1301 }
|
|
1302 DdeFreeDataHandle (hdata);
|
|
1303 return (HDDEDATA) DDE_FNOTPROCESSED;
|
|
1304 default:
|
|
1305 return (HDDEDATA) NULL;
|
|
1306 }
|
|
1307
|
|
1308 }
|
|
1309
|
|
1310 /*
|
|
1311 * The windows procedure for the window class XEMACS_CLASS
|
|
1312 */
|
|
1313 LRESULT WINAPI
|
|
1314 mswindows_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
1315 {
|
|
1316 /* Note: Remember to initialise emacs_event and event before use.
|
|
1317 This code calls code that can GC. You must GCPRO before calling such code. */
|
|
1318 Lisp_Object emacs_event = Qnil;
|
|
1319 Lisp_Object fobj = Qnil;
|
|
1320
|
|
1321 struct Lisp_Event *event;
|
|
1322 struct frame *frame;
|
|
1323 struct mswindows_frame* msframe;
|
|
1324
|
|
1325 switch (message)
|
|
1326 {
|
|
1327 case WM_ERASEBKGND:
|
|
1328 /* Erase background only during non-dynamic sizing */
|
|
1329 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
|
|
1330 if (msframe->sizing && !mswindows_dynamic_frame_resize)
|
|
1331 goto defproc;
|
|
1332 return 1;
|
|
1333
|
|
1334 case WM_CLOSE:
|
|
1335 fobj = mswindows_find_frame (hwnd);
|
|
1336 enqueue_misc_user_event (fobj, Qeval, list3 (Qdelete_frame, fobj, Qt));
|
276
|
1337 mswindows_bump_queue ();
|
249
|
1338 break;
|
|
1339
|
|
1340 case WM_KEYDOWN:
|
|
1341 case WM_SYSKEYDOWN:
|
|
1342 {
|
|
1343 BYTE keymap[256];
|
|
1344 int has_AltGr = mswindows_current_layout_has_AltGr ();
|
|
1345 int mods;
|
|
1346 Lisp_Object keysym;
|
|
1347
|
|
1348 GetKeyboardState (keymap);
|
|
1349 mods = mswindows_modifier_state (keymap, has_AltGr);
|
|
1350
|
|
1351 /* Handle those keys that TranslateMessage won't generate a WM_CHAR for */
|
|
1352 if (!NILP (keysym = mswindows_key_to_emacs_keysym(wParam, mods)))
|
|
1353 mswindows_enqueue_keypress_event (hwnd, keysym, mods);
|
|
1354 else
|
|
1355 {
|
|
1356 int quit_ch = CONSOLE_QUIT_CHAR (XCONSOLE (mswindows_find_console (hwnd)));
|
|
1357 BYTE keymap_orig[256];
|
|
1358 MSG msg = { hwnd, message, wParam, lParam, GetMessageTime(), (GetMessagePos()) };
|
|
1359 memcpy (keymap_orig, keymap, 256);
|
|
1360
|
|
1361 /* Clear control and alt modifiers out of the keymap */
|
|
1362 keymap [VK_RCONTROL] = 0;
|
|
1363 keymap [VK_LMENU] = 0;
|
|
1364 if (!has_AltGr || !(keymap [VK_LCONTROL] & 0x80) || !(keymap [VK_RMENU] & 0x80))
|
|
1365 {
|
|
1366 keymap [VK_LCONTROL] = 0;
|
|
1367 keymap [VK_CONTROL] = 0;
|
|
1368 keymap [VK_RMENU] = 0;
|
|
1369 keymap [VK_MENU] = 0;
|
|
1370 }
|
|
1371 SetKeyboardState (keymap);
|
|
1372
|
|
1373 /* Have some WM_[SYS]CHARS in the queue */
|
|
1374 TranslateMessage (&msg);
|
|
1375
|
|
1376 while (PeekMessage (&msg, hwnd, WM_CHAR, WM_CHAR, PM_REMOVE)
|
|
1377 ||PeekMessage (&msg, hwnd, WM_SYSCHAR, WM_SYSCHAR, PM_REMOVE))
|
|
1378 {
|
|
1379 int ch = msg.wParam;
|
|
1380 /* CH is a character code for the key:
|
|
1381 'C' for Shift+C and Ctrl+Shift+C
|
|
1382 'c' for c and Ctrl+c */
|
|
1383
|
|
1384 /* #### If locale is not C, US or other latin-1,
|
|
1385 isalpha() maybe not what do we mean */
|
|
1386
|
|
1387 /* XEmacs doesn't seem to like Shift on non-alpha keys */
|
|
1388 if (!isalpha(ch))
|
|
1389 mods &= ~MOD_SHIFT;
|
|
1390
|
|
1391 /* Un-capitalise alpha control keys */
|
|
1392 if ((mods & MOD_CONTROL) && isalpha(ch))
|
|
1393 ch |= ('A' ^ 'a');
|
|
1394
|
|
1395 /* If a quit char with no modifiers other than control and
|
|
1396 shift, then mark it with a fake modifier, which is removed
|
|
1397 upon dequeueing the event */
|
|
1398 /* #### This might also not withstand localization, if
|
|
1399 quit character is not a latin-1 symbol */
|
|
1400 if (((quit_ch < ' ' && (mods & MOD_CONTROL) && quit_ch + 'a' - 1 == ch)
|
|
1401 || (quit_ch >= ' ' && !(mods & MOD_CONTROL) && quit_ch == ch))
|
|
1402 && ((mods & ~(MOD_CONTROL | MOD_SHIFT)) == 0))
|
|
1403 {
|
|
1404 mods |= FAKE_MOD_QUIT;
|
|
1405 ++mswindows_quit_chars_count;
|
|
1406 }
|
|
1407
|
|
1408 mswindows_enqueue_keypress_event (hwnd, make_char(ch), mods);
|
|
1409 } /* while */
|
|
1410 SetKeyboardState (keymap_orig);
|
|
1411 } /* else */
|
|
1412 }
|
|
1413 goto defproc;
|
|
1414
|
|
1415 case WM_MBUTTONDOWN:
|
|
1416 case WM_MBUTTONUP:
|
|
1417 /* Real middle mouse button has nothing to do with emulated one:
|
|
1418 if one wants to exercise fingers playing chords on the mouse,
|
|
1419 he is allowed to do that! */
|
|
1420 mswindows_enqueue_mouse_button_event (hwnd, message,
|
|
1421 MAKEPOINTS (lParam), GetMessageTime());
|
|
1422 break;
|
|
1423
|
|
1424 case WM_LBUTTONUP:
|
|
1425 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
|
|
1426 msframe->last_click_time = GetMessageTime();
|
|
1427
|
|
1428 KillTimer (hwnd, BUTTON_2_TIMER_ID);
|
|
1429 msframe->button2_need_lbutton = 0;
|
|
1430 if (msframe->ignore_next_lbutton_up)
|
|
1431 {
|
|
1432 msframe->ignore_next_lbutton_up = 0;
|
|
1433 }
|
|
1434 else if (msframe->button2_is_down)
|
|
1435 {
|
|
1436 msframe->button2_is_down = 0;
|
|
1437 msframe->ignore_next_rbutton_up = 1;
|
|
1438 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONUP,
|
|
1439 MAKEPOINTS (lParam), GetMessageTime());
|
|
1440 }
|
|
1441 else
|
|
1442 {
|
|
1443 if (msframe->button2_need_rbutton)
|
|
1444 {
|
|
1445 msframe->button2_need_rbutton = 0;
|
|
1446 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
|
|
1447 MAKEPOINTS (lParam), GetMessageTime());
|
|
1448 }
|
|
1449 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONUP,
|
|
1450 MAKEPOINTS (lParam), GetMessageTime());
|
|
1451 }
|
|
1452 break;
|
|
1453
|
|
1454 case WM_RBUTTONUP:
|
|
1455 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
|
|
1456 msframe->last_click_time = GetMessageTime();
|
|
1457
|
|
1458 KillTimer (hwnd, BUTTON_2_TIMER_ID);
|
|
1459 msframe->button2_need_rbutton = 0;
|
|
1460 if (msframe->ignore_next_rbutton_up)
|
|
1461 {
|
|
1462 msframe->ignore_next_rbutton_up = 0;
|
|
1463 }
|
|
1464 else if (msframe->button2_is_down)
|
|
1465 {
|
|
1466 msframe->button2_is_down = 0;
|
|
1467 msframe->ignore_next_lbutton_up = 1;
|
|
1468 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONUP,
|
|
1469 MAKEPOINTS (lParam), GetMessageTime());
|
|
1470 }
|
|
1471 else
|
|
1472 {
|
|
1473 if (msframe->button2_need_lbutton)
|
|
1474 {
|
|
1475 msframe->button2_need_lbutton = 0;
|
|
1476 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
|
|
1477 MAKEPOINTS (lParam), GetMessageTime());
|
|
1478 }
|
|
1479 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONUP,
|
|
1480 MAKEPOINTS (lParam), GetMessageTime());
|
|
1481 }
|
|
1482 break;
|
|
1483
|
|
1484 case WM_LBUTTONDOWN:
|
|
1485 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
|
|
1486
|
|
1487 if (msframe->button2_need_lbutton)
|
|
1488 {
|
|
1489 KillTimer (hwnd, BUTTON_2_TIMER_ID);
|
|
1490 msframe->button2_need_lbutton = 0;
|
|
1491 msframe->button2_need_rbutton = 0;
|
|
1492 if (mswindows_button2_near_enough (msframe->last_click_point, MAKEPOINTS (lParam)))
|
|
1493 {
|
|
1494 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONDOWN,
|
|
1495 MAKEPOINTS (lParam), GetMessageTime());
|
|
1496 msframe->button2_is_down = 1;
|
|
1497 }
|
|
1498 else
|
|
1499 {
|
|
1500 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
|
|
1501 msframe->last_click_point, msframe->last_click_time);
|
|
1502 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
|
|
1503 MAKEPOINTS (lParam), GetMessageTime());
|
|
1504 }
|
|
1505 }
|
|
1506 else
|
|
1507 {
|
|
1508 mswindows_set_chord_timer (hwnd);
|
|
1509 msframe->button2_need_rbutton = 1;
|
|
1510 msframe->last_click_point = MAKEPOINTS (lParam);
|
|
1511 }
|
|
1512 msframe->last_click_time = GetMessageTime();
|
|
1513 break;
|
|
1514
|
|
1515 case WM_RBUTTONDOWN:
|
|
1516 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
|
|
1517
|
|
1518 if (msframe->button2_need_rbutton)
|
|
1519 {
|
|
1520 KillTimer (hwnd, BUTTON_2_TIMER_ID);
|
|
1521 msframe->button2_need_lbutton = 0;
|
|
1522 msframe->button2_need_rbutton = 0;
|
|
1523 if (mswindows_button2_near_enough (msframe->last_click_point, MAKEPOINTS (lParam)))
|
|
1524 {
|
|
1525 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONDOWN,
|
|
1526 MAKEPOINTS (lParam), GetMessageTime());
|
|
1527 msframe->button2_is_down = 1;
|
|
1528 }
|
|
1529 else
|
|
1530 {
|
|
1531 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
|
|
1532 msframe->last_click_point, msframe->last_click_time);
|
|
1533 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
|
|
1534 MAKEPOINTS (lParam), GetMessageTime());
|
|
1535 }
|
|
1536 }
|
|
1537 else
|
|
1538 {
|
|
1539 mswindows_set_chord_timer (hwnd);
|
|
1540 msframe->button2_need_lbutton = 1;
|
|
1541 msframe->last_click_point = MAKEPOINTS (lParam);
|
|
1542 }
|
|
1543 msframe->last_click_time = GetMessageTime();
|
|
1544 break;
|
|
1545
|
|
1546 case WM_TIMER:
|
|
1547 if (wParam == BUTTON_2_TIMER_ID)
|
|
1548 {
|
|
1549 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
|
|
1550 KillTimer (hwnd, BUTTON_2_TIMER_ID);
|
|
1551
|
|
1552 if (msframe->button2_need_lbutton)
|
|
1553 {
|
|
1554 msframe->button2_need_lbutton = 0;
|
|
1555 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
|
|
1556 msframe->last_click_point, msframe->last_click_time);
|
|
1557 }
|
|
1558 else if (msframe->button2_need_rbutton)
|
|
1559 {
|
|
1560 msframe->button2_need_rbutton = 0;
|
|
1561 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
|
|
1562 msframe->last_click_point, msframe->last_click_time);
|
|
1563 }
|
|
1564 }
|
|
1565 else
|
|
1566 assert ("Spurious timer fired" == 0);
|
|
1567 break;
|
|
1568
|
|
1569 case WM_MOUSEMOVE:
|
|
1570 /* Optimization: don't report mouse movement while size is changind */
|
|
1571 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
|
|
1572 if (!msframe->sizing)
|
|
1573 {
|
|
1574 /* When waiting for the second mouse button to finish
|
|
1575 button2 emulation, and have moved too far, just pretend
|
|
1576 as if timer has expired. This impoves drag-select feedback */
|
|
1577 if ((msframe->button2_need_lbutton || msframe->button2_need_rbutton)
|
|
1578 && !mswindows_button2_near_enough (msframe->last_click_point,
|
|
1579 MAKEPOINTS (lParam)))
|
|
1580 {
|
|
1581 KillTimer (hwnd, BUTTON_2_TIMER_ID);
|
|
1582 SendMessage (hwnd, WM_TIMER, BUTTON_2_TIMER_ID, 0);
|
|
1583 }
|
|
1584
|
|
1585 emacs_event = Fmake_event (Qnil, Qnil);
|
|
1586 event = XEVENT(emacs_event);
|
|
1587
|
|
1588 event->channel = mswindows_find_frame(hwnd);
|
|
1589 event->timestamp = GetMessageTime();
|
|
1590 event->event_type = pointer_motion_event;
|
|
1591 event->event.motion.x = MAKEPOINTS(lParam).x;
|
|
1592 event->event.motion.y = MAKEPOINTS(lParam).y;
|
|
1593 event->event.motion.modifiers = mswindows_modifier_state (NULL, 0);
|
|
1594
|
|
1595 mswindows_enqueue_dispatch_event (emacs_event);
|
|
1596 }
|
|
1597 break;
|
|
1598
|
278
|
1599 #ifdef HAVE_TOOLBARS
|
|
1600 case WM_NOTIFY:
|
|
1601 {
|
|
1602 LPTOOLTIPTEXT tttext = (LPTOOLTIPTEXT)lParam;
|
|
1603 Lisp_Object btext;
|
|
1604 if (tttext->hdr.code == TTN_NEEDTEXT)
|
|
1605 {
|
|
1606 /* find out which toolbar */
|
|
1607 frame = XFRAME (mswindows_find_frame (hwnd));
|
|
1608 btext = mswindows_get_toolbar_button_text ( frame,
|
|
1609 tttext->hdr.idFrom );
|
|
1610
|
|
1611 tttext->lpszText = NULL;
|
|
1612 tttext->hinst = NULL;
|
|
1613
|
|
1614 if (!NILP(btext))
|
|
1615 {
|
|
1616 strncpy (tttext->szText, XSTRING_DATA (btext), 80);
|
|
1617 tttext->lpszText=tttext->szText;
|
|
1618 }
|
|
1619 #if 0
|
|
1620 tttext->uFlags |= TTF_DI_SETITEM;
|
|
1621 #endif
|
|
1622 }
|
|
1623 }
|
|
1624 break;
|
|
1625 #endif
|
|
1626
|
249
|
1627 case WM_PAINT:
|
|
1628 {
|
|
1629 PAINTSTRUCT paintStruct;
|
|
1630
|
|
1631 frame = XFRAME (mswindows_find_frame (hwnd));
|
|
1632
|
|
1633 BeginPaint (hwnd, &paintStruct);
|
|
1634 mswindows_redraw_exposed_area (frame,
|
|
1635 paintStruct.rcPaint.left, paintStruct.rcPaint.top,
|
|
1636 paintStruct.rcPaint.right, paintStruct.rcPaint.bottom);
|
|
1637 EndPaint (hwnd, &paintStruct);
|
|
1638 }
|
|
1639 break;
|
|
1640
|
|
1641 case WM_SIZE:
|
|
1642 /* We only care about this message if our size has really changed */
|
|
1643 if (wParam==SIZE_RESTORED || wParam==SIZE_MAXIMIZED || wParam==SIZE_MINIMIZED)
|
|
1644 {
|
|
1645 RECT rect;
|
|
1646 int columns, rows;
|
|
1647
|
|
1648 fobj = mswindows_find_frame (hwnd);
|
|
1649 frame = XFRAME (fobj);
|
|
1650 msframe = FRAME_MSWINDOWS_DATA (frame);
|
|
1651
|
|
1652 /* We cannot handle frame map and unmap hooks right in
|
|
1653 this routine, because these may throw. We queue
|
|
1654 magic events to run these hooks instead - kkm */
|
|
1655
|
|
1656 if (wParam==SIZE_MINIMIZED)
|
|
1657 {
|
|
1658 /* Iconified */
|
269
|
1659 FRAME_VISIBLE_P (frame) = 0;
|
249
|
1660 mswindows_enqueue_magic_event (hwnd, XM_UNMAPFRAME);
|
|
1661 }
|
|
1662 else
|
|
1663 {
|
|
1664 GetClientRect(hwnd, &rect);
|
|
1665 FRAME_PIXWIDTH(frame) = rect.right;
|
|
1666 FRAME_PIXHEIGHT(frame) = rect.bottom;
|
269
|
1667
|
|
1668 pixel_to_real_char_size (frame, rect.right, rect.bottom,
|
274
|
1669 &FRAME_MSWINDOWS_CHARWIDTH (frame),
|
|
1670 &FRAME_MSWINDOWS_CHARHEIGHT (frame));
|
269
|
1671
|
249
|
1672 pixel_to_char_size (frame, rect.right, rect.bottom, &columns, &rows);
|
|
1673 change_frame_size (frame, rows, columns, 1);
|
|
1674
|
269
|
1675 /* If we are inside frame creation, we have to apply geometric
|
|
1676 properties now. */
|
|
1677 if (mswindows_frame_target_rect.left >= 0
|
|
1678 || mswindows_frame_target_rect.top >= 0
|
|
1679 || mswindows_frame_target_rect.width >= 0
|
|
1680 || mswindows_frame_target_rect.height >= 0)
|
|
1681 {
|
|
1682 /* Yes, we have to size again */
|
|
1683 XEMACS_RECT_WH geom;
|
|
1684
|
|
1685 geom.left = mswindows_frame_target_rect.left;
|
|
1686 geom.top = mswindows_frame_target_rect.top;
|
|
1687 char_to_real_pixel_size (frame,
|
|
1688 mswindows_frame_target_rect.width,
|
|
1689 mswindows_frame_target_rect.height,
|
|
1690 &geom.width, &geom.height);
|
|
1691 if (mswindows_frame_target_rect.width < 0)
|
|
1692 geom.width = -1;
|
|
1693 if (mswindows_frame_target_rect.height < 0)
|
|
1694 geom.height = -1;
|
|
1695
|
|
1696 /* Reset to we do not get here again */
|
|
1697 mswindows_frame_target_rect.left = -1;
|
|
1698 mswindows_frame_target_rect.top = -1;
|
|
1699 mswindows_frame_target_rect.width = -1;
|
|
1700 mswindows_frame_target_rect.height = -1;
|
|
1701
|
|
1702 /* Size the rectangle to the actual size */
|
|
1703 GetWindowRect (hwnd, &rect);
|
|
1704 SetWindowPos
|
|
1705 (hwnd, NULL,
|
|
1706 geom.left >= 0 ? geom.left : rect.left,
|
|
1707 geom.top >= 0 ? geom.top : rect.top,
|
|
1708 geom.width >= 0 ? geom.width : rect.right - rect.left,
|
|
1709 geom.height >= 0 ? geom.height : rect.bottom - rect.top,
|
|
1710 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING
|
|
1711 | ((geom.left >= 0 || geom.top >= 0) ? 0 : SWP_NOMOVE)
|
|
1712 | ((geom.width >= 0 || geom.height >= 0) ? 0 : SWP_NOSIZE));
|
|
1713 }
|
|
1714 else
|
|
1715 {
|
|
1716 if (!msframe->sizing && !FRAME_VISIBLE_P (frame))
|
|
1717 mswindows_enqueue_magic_event (hwnd, XM_MAPFRAME);
|
|
1718 FRAME_VISIBLE_P (frame) = 1;
|
|
1719
|
|
1720 if (!msframe->sizing || mswindows_dynamic_frame_resize)
|
|
1721 redisplay ();
|
|
1722 }
|
249
|
1723 }
|
|
1724 }
|
|
1725 break;
|
|
1726
|
|
1727 /* Misc magic events which only require that the frame be identified */
|
|
1728 case WM_SETFOCUS:
|
|
1729 case WM_KILLFOCUS:
|
|
1730 mswindows_enqueue_magic_event (hwnd, message);
|
|
1731 break;
|
|
1732
|
|
1733 case WM_WINDOWPOSCHANGING:
|
|
1734 {
|
|
1735 WINDOWPOS *wp = (LPWINDOWPOS) lParam;
|
|
1736 WINDOWPLACEMENT wpl = { sizeof(WINDOWPLACEMENT) };
|
|
1737 GetWindowPlacement(hwnd, &wpl);
|
|
1738
|
|
1739 /* Only interested if size is changing and we're not being iconified */
|
269
|
1740 if (wpl.showCmd != SW_SHOWMINIMIZED
|
|
1741 && wpl.showCmd != SW_SHOWMAXIMIZED
|
|
1742 && !(wp->flags & SWP_NOSIZE))
|
249
|
1743 {
|
|
1744 RECT ncsize = { 0, 0, 0, 0 };
|
|
1745 int pixwidth, pixheight;
|
|
1746 AdjustWindowRectEx (&ncsize, GetWindowLong (hwnd, GWL_STYLE),
|
|
1747 GetMenu(hwnd) != NULL,
|
|
1748 GetWindowLong (hwnd, GWL_EXSTYLE));
|
|
1749
|
269
|
1750 round_size_to_real_char (XFRAME (mswindows_find_frame (hwnd)),
|
|
1751 wp->cx - (ncsize.right - ncsize.left),
|
|
1752 wp->cy - (ncsize.bottom - ncsize.top),
|
|
1753 &pixwidth, &pixheight);
|
249
|
1754
|
|
1755 /* Convert client sizes to window sizes */
|
|
1756 pixwidth += (ncsize.right - ncsize.left);
|
|
1757 pixheight += (ncsize.bottom - ncsize.top);
|
|
1758
|
|
1759 if (wpl.showCmd != SW_SHOWMAXIMIZED)
|
|
1760 {
|
|
1761 /* Adjust so that the bottom or right doesn't move if it's
|
|
1762 * the top or left that's being changed */
|
|
1763 RECT rect;
|
|
1764 GetWindowRect (hwnd, &rect);
|
|
1765
|
|
1766 if (rect.left != wp->x)
|
|
1767 wp->x += wp->cx - pixwidth;
|
|
1768 if (rect.top != wp->y)
|
|
1769 wp->y += wp->cy - pixheight;
|
|
1770 }
|
|
1771
|
|
1772 wp->cx = pixwidth;
|
|
1773 wp->cy = pixheight;
|
|
1774 }
|
269
|
1775 /* DefWindowProc sends useful WM_GETMINMAXINFO message, and adjusts
|
|
1776 window position if the user tries to track window too small */
|
249
|
1777 }
|
269
|
1778 goto defproc;
|
249
|
1779
|
|
1780 case WM_ENTERSIZEMOVE:
|
|
1781 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
|
|
1782 msframe->sizing = 1;
|
|
1783 return 0;
|
|
1784
|
|
1785 case WM_EXITSIZEMOVE:
|
|
1786 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
|
|
1787 msframe->sizing = 0;
|
|
1788 /* Queue noop event */
|
276
|
1789 mswindows_bump_queue ();
|
249
|
1790 return 0;
|
|
1791
|
|
1792 #ifdef HAVE_SCROLLBARS
|
|
1793 case WM_VSCROLL:
|
|
1794 case WM_HSCROLL:
|
|
1795 {
|
|
1796 /* Direction of scroll is determined by scrollbar instance. */
|
|
1797 int code = (int) LOWORD(wParam);
|
|
1798 int pos = (short int) HIWORD(wParam);
|
|
1799 HWND hwndScrollBar = (HWND) lParam;
|
|
1800 struct gcpro gcpro1, gcpro2;
|
|
1801
|
|
1802 mswindows_handle_scrollbar_event (hwndScrollBar, code, pos);
|
|
1803 GCPRO2 (emacs_event, fobj);
|
|
1804 if (UNBOUNDP(mswindows_pump_outstanding_events())) /* Can GC */
|
|
1805 {
|
|
1806 /* Error during event pumping - cancel scroll */
|
|
1807 SendMessage (hwndScrollBar, WM_CANCELMODE, 0, 0);
|
|
1808 }
|
|
1809 UNGCPRO;
|
|
1810 break;
|
|
1811 }
|
|
1812 #endif
|
|
1813
|
|
1814 #ifdef HAVE_MENUBARS
|
|
1815 case WM_INITMENU:
|
|
1816 if (UNBOUNDP (mswindows_handle_wm_initmenu (
|
|
1817 (HMENU) wParam,
|
|
1818 XFRAME (mswindows_find_frame (hwnd)))))
|
|
1819 SendMessage (hwnd, WM_CANCELMODE, 0, 0);
|
|
1820 break;
|
|
1821
|
|
1822 case WM_INITMENUPOPUP:
|
|
1823 if (!HIWORD(lParam))
|
|
1824 {
|
|
1825 if (UNBOUNDP (mswindows_handle_wm_initmenupopup (
|
|
1826 (HMENU) wParam,
|
|
1827 XFRAME (mswindows_find_frame (hwnd)))))
|
|
1828 SendMessage (hwnd, WM_CANCELMODE, 0, 0);
|
|
1829 }
|
|
1830 break;
|
|
1831
|
|
1832 #endif /* HAVE_MENUBARS */
|
|
1833
|
|
1834 case WM_COMMAND:
|
|
1835 {
|
|
1836 WORD id = LOWORD (wParam);
|
278
|
1837 HWND cid = (HWND)lParam;
|
249
|
1838 frame = XFRAME (mswindows_find_frame (hwnd));
|
|
1839
|
276
|
1840 #ifdef HAVE_TOOLBARS
|
278
|
1841 if (!NILP (mswindows_handle_toolbar_wm_command (frame, cid, id)))
|
276
|
1842 break;
|
|
1843 #endif
|
|
1844
|
249
|
1845 #ifdef HAVE_MENUBARS
|
|
1846 if (!NILP (mswindows_handle_wm_command (frame, id)))
|
|
1847 break;
|
|
1848 #endif
|
|
1849
|
269
|
1850 /* Bite me - a spurious command. This cannot happen. */
|
|
1851 error ("XEMACS BUG: Cannot decode command message");
|
249
|
1852 }
|
|
1853 break;
|
|
1854
|
|
1855 case WM_DROPFILES: /* implementation ripped-off from event-Xt.c */
|
|
1856 {
|
|
1857 UINT filecount, i, len;
|
|
1858 POINT point;
|
|
1859 char filename[MAX_PATH];
|
259
|
1860 #ifdef __CYGWIN32__
|
|
1861 char* fname;
|
|
1862 #endif
|
249
|
1863 Lisp_Object l_type, l_dndlist = Qnil, l_item;
|
|
1864
|
|
1865 emacs_event = Fmake_event (Qnil, Qnil);
|
|
1866 event = XEVENT(emacs_event);
|
|
1867
|
|
1868 if (!DragQueryPoint ((HANDLE) wParam, &point))
|
|
1869 point.x = point.y = -1; /* outside client area */
|
|
1870
|
|
1871 filecount = DragQueryFile ((HANDLE) wParam, -1, NULL, 0);
|
|
1872 if (filecount == 1)
|
|
1873 {
|
|
1874 l_type = make_int (DndFile);
|
|
1875 len = DragQueryFile ((HANDLE) wParam, 0, filename, MAX_PATH);
|
259
|
1876 #ifdef __CYGWIN32__
|
|
1877 CYGWIN_CONV_PATH(filename, fname);
|
|
1878 len=strlen(fname);
|
|
1879 l_dndlist = make_ext_string (fname, len, FORMAT_FILENAME);
|
|
1880 #else
|
249
|
1881 l_dndlist = make_ext_string (filename, len, FORMAT_FILENAME);
|
259
|
1882 #endif
|
249
|
1883 }
|
|
1884 else
|
|
1885 {
|
|
1886 l_type = make_int (DndFiles);
|
|
1887 for (i=0; i<filecount; i++)
|
|
1888 {
|
|
1889 len = DragQueryFile ((HANDLE) wParam, i, filename, MAX_PATH);
|
259
|
1890 #ifdef __CYGWIN32__
|
|
1891 CYGWIN_CONV_PATH(filename, fname);
|
|
1892 len=strlen(fname);
|
|
1893 l_item = make_ext_string (fname, len, FORMAT_FILENAME);
|
|
1894 #else
|
249
|
1895 l_item = make_ext_string (filename, len, FORMAT_FILENAME);
|
259
|
1896 #endif
|
249
|
1897 l_dndlist = Fcons (l_item, l_dndlist); /* reverse order */
|
|
1898 }
|
|
1899 }
|
|
1900 DragFinish ((HANDLE) wParam);
|
|
1901
|
|
1902 event->channel = mswindows_find_frame(hwnd);
|
|
1903 event->timestamp = GetMessageTime();
|
|
1904 event->event_type = dnd_drop_event;
|
|
1905 event->event.dnd_drop.button = 1; /* #### Should try harder */
|
|
1906 event->event.dnd_drop.modifiers = mswindows_modifier_state (NULL, 0);
|
|
1907 event->event.dnd_drop.x = point.x;
|
|
1908 event->event.dnd_drop.y = point.y;
|
|
1909 event->event.dnd_drop.data = Fcons (l_type, Fcons (l_dndlist, Qnil));
|
|
1910
|
|
1911 mswindows_enqueue_dispatch_event (emacs_event);
|
|
1912 }
|
|
1913 break;
|
|
1914
|
|
1915 defproc:
|
|
1916 default:
|
|
1917 return DefWindowProc (hwnd, message, wParam, lParam);
|
|
1918 }
|
|
1919 return (0);
|
|
1920 }
|
|
1921
|
|
1922
|
|
1923 /************************************************************************/
|
|
1924 /* keyboard, mouse & other helpers for the windows procedure */
|
|
1925 /************************************************************************/
|
|
1926 static void
|
|
1927 mswindows_set_chord_timer (HWND hwnd)
|
|
1928 {
|
|
1929 int interval;
|
|
1930
|
269
|
1931 /* We get one third half system double click threshold */
|
272
|
1932 if (mswindows_mouse_button_tolerance <= 0)
|
269
|
1933 interval = GetDoubleClickTime () / 3;
|
249
|
1934 else
|
272
|
1935 interval = mswindows_mouse_button_tolerance;
|
249
|
1936
|
|
1937 SetTimer (hwnd, BUTTON_2_TIMER_ID, interval, 0);
|
|
1938 }
|
|
1939
|
|
1940 static int
|
|
1941 mswindows_button2_near_enough (POINTS p1, POINTS p2)
|
|
1942 {
|
|
1943 int dx, dy;
|
272
|
1944 if (mswindows_mouse_button_max_skew_x <= 0)
|
249
|
1945 dx = GetSystemMetrics (SM_CXDOUBLECLK) / 2;
|
|
1946 else
|
272
|
1947 dx = mswindows_mouse_button_max_skew_x;
|
249
|
1948
|
272
|
1949 if (mswindows_mouse_button_max_skew_y <= 0)
|
249
|
1950 dy = GetSystemMetrics (SM_CYDOUBLECLK) / 2;
|
|
1951 else
|
272
|
1952 dy = mswindows_mouse_button_max_skew_y;
|
249
|
1953
|
|
1954 return abs (p1.x - p2.x) < dx && abs (p1.y- p2.y)< dy;
|
|
1955 }
|
|
1956
|
|
1957 static int
|
|
1958 mswindows_current_layout_has_AltGr (void)
|
|
1959 {
|
|
1960 /* This simple caching mechanism saves 10% of CPU
|
|
1961 time when a key typed at autorepeat rate of 30 cps! */
|
|
1962 static HKL last_hkl = 0;
|
|
1963 static int last_hkl_has_AltGr;
|
|
1964
|
|
1965 HKL current_hkl = GetKeyboardLayout (0);
|
|
1966 if (current_hkl != last_hkl)
|
|
1967 {
|
|
1968 TCHAR c;
|
|
1969 last_hkl_has_AltGr = 0;
|
|
1970 /* In this loop, we query whether a character requires
|
|
1971 AltGr to be down to generate it. If at least such one
|
|
1972 found, this means that the layout does regard AltGr */
|
|
1973 for (c = ' '; c <= 0xFFU && c != 0 && !last_hkl_has_AltGr; ++c)
|
|
1974 if (HIBYTE (VkKeyScan (c)) == 6)
|
|
1975 last_hkl_has_AltGr = 1;
|
|
1976 last_hkl = current_hkl;
|
|
1977 }
|
|
1978 return last_hkl_has_AltGr;
|
|
1979 }
|
|
1980
|
|
1981
|
|
1982 /* Returns the state of the modifier keys in the format expected by the
|
|
1983 * Lisp_Event key_data, button_data and motion_data modifiers member */
|
|
1984 int mswindows_modifier_state (BYTE* keymap, int has_AltGr)
|
|
1985 {
|
|
1986 int mods = 0;
|
|
1987
|
|
1988 if (keymap == NULL)
|
|
1989 {
|
|
1990 keymap = (BYTE*) alloca(256);
|
|
1991 GetKeyboardState (keymap);
|
|
1992 has_AltGr = mswindows_current_layout_has_AltGr ();
|
|
1993 }
|
|
1994
|
|
1995 if (has_AltGr && (keymap [VK_LCONTROL] & 0x80) && (keymap [VK_RMENU] & 0x80))
|
|
1996 {
|
|
1997 mods |= (keymap [VK_LMENU] & 0x80) ? MOD_META : 0;
|
|
1998 mods |= (keymap [VK_RCONTROL] & 0x80) ? MOD_CONTROL : 0;
|
|
1999 }
|
|
2000 else
|
|
2001 {
|
|
2002 mods |= (keymap [VK_MENU] & 0x80) ? MOD_META : 0;
|
|
2003 mods |= (keymap [VK_CONTROL] & 0x80) ? MOD_CONTROL : 0;
|
|
2004 }
|
|
2005
|
|
2006 mods |= (keymap [VK_SHIFT] & 0x80) ? MOD_SHIFT : 0;
|
|
2007
|
|
2008 return mods;
|
|
2009 }
|
|
2010
|
|
2011 /*
|
|
2012 * Translate a mswindows virtual key to a keysym.
|
|
2013 * Only returns non-Qnil for keys that don't generate WM_CHAR messages
|
|
2014 * or whose ASCII codes (like space) xemacs doesn't like.
|
|
2015 * Virtual key values are defined in winresrc.h
|
|
2016 * XXX I'm not sure that KEYSYM("name") is the best thing to use here.
|
|
2017 */
|
|
2018 Lisp_Object mswindows_key_to_emacs_keysym(int mswindows_key, int mods)
|
|
2019 {
|
|
2020 switch (mswindows_key)
|
|
2021 {
|
|
2022 /* First the predefined ones */
|
|
2023 case VK_BACK: return QKbackspace;
|
|
2024 case VK_TAB: return QKtab;
|
|
2025 case '\n': return QKlinefeed; /* No VK_LINEFEED in winresrc.h */
|
|
2026 case VK_RETURN: return QKreturn;
|
|
2027 case VK_ESCAPE: return QKescape;
|
|
2028 case VK_SPACE: return QKspace;
|
|
2029 case VK_DELETE: return QKdelete;
|
|
2030
|
|
2031 /* The rest */
|
|
2032 case VK_CLEAR: return KEYSYM ("clear"); /* Should do ^L ? */
|
|
2033 case VK_PRIOR: return KEYSYM ("prior");
|
|
2034 case VK_NEXT: return KEYSYM ("next");
|
|
2035 case VK_END: return KEYSYM ("end");
|
|
2036 case VK_HOME: return KEYSYM ("home");
|
|
2037 case VK_LEFT: return KEYSYM ("left");
|
|
2038 case VK_UP: return KEYSYM ("up");
|
|
2039 case VK_RIGHT: return KEYSYM ("right");
|
|
2040 case VK_DOWN: return KEYSYM ("down");
|
|
2041 case VK_SELECT: return KEYSYM ("select");
|
|
2042 case VK_PRINT: return KEYSYM ("print");
|
|
2043 case VK_EXECUTE: return KEYSYM ("execute");
|
|
2044 case VK_SNAPSHOT: return KEYSYM ("print");
|
|
2045 case VK_INSERT: return KEYSYM ("insert");
|
|
2046 case VK_HELP: return KEYSYM ("help");
|
|
2047 #if 0 /* XXX What are these supposed to do? */
|
|
2048 case VK_LWIN return KEYSYM ("");
|
|
2049 case VK_RWIN return KEYSYM ("");
|
|
2050 #endif
|
|
2051 case VK_APPS: return KEYSYM ("menu");
|
|
2052 case VK_F1: return KEYSYM ("f1");
|
|
2053 case VK_F2: return KEYSYM ("f2");
|
|
2054 case VK_F3: return KEYSYM ("f3");
|
|
2055 case VK_F4: return KEYSYM ("f4");
|
|
2056 case VK_F5: return KEYSYM ("f5");
|
|
2057 case VK_F6: return KEYSYM ("f6");
|
|
2058 case VK_F7: return KEYSYM ("f7");
|
|
2059 case VK_F8: return KEYSYM ("f8");
|
|
2060 case VK_F9: return KEYSYM ("f9");
|
|
2061 case VK_F10: return KEYSYM ("f10");
|
|
2062 case VK_F11: return KEYSYM ("f11");
|
|
2063 case VK_F12: return KEYSYM ("f12");
|
|
2064 case VK_F13: return KEYSYM ("f13");
|
|
2065 case VK_F14: return KEYSYM ("f14");
|
|
2066 case VK_F15: return KEYSYM ("f15");
|
|
2067 case VK_F16: return KEYSYM ("f16");
|
|
2068 case VK_F17: return KEYSYM ("f17");
|
|
2069 case VK_F18: return KEYSYM ("f18");
|
|
2070 case VK_F19: return KEYSYM ("f19");
|
|
2071 case VK_F20: return KEYSYM ("f20");
|
|
2072 case VK_F21: return KEYSYM ("f21");
|
|
2073 case VK_F22: return KEYSYM ("f22");
|
|
2074 case VK_F23: return KEYSYM ("f23");
|
|
2075 case VK_F24: return KEYSYM ("f24");
|
|
2076 }
|
|
2077 return Qnil;
|
|
2078 }
|
|
2079
|
|
2080 /*
|
|
2081 * Find the console that matches the supplied mswindows window handle
|
|
2082 */
|
|
2083 Lisp_Object
|
|
2084 mswindows_find_console (HWND hwnd)
|
|
2085 {
|
274
|
2086 /* We only support one console */
|
|
2087 return XCAR (Vconsole_list);
|
249
|
2088 }
|
|
2089
|
|
2090 /*
|
|
2091 * Find the frame that matches the supplied mswindows window handle
|
|
2092 */
|
|
2093 static Lisp_Object
|
|
2094 mswindows_find_frame (HWND hwnd)
|
|
2095 {
|
269
|
2096 LONG l = GetWindowLong (hwnd, XWL_FRAMEOBJ);
|
|
2097 Lisp_Object f;
|
|
2098 if (l == 0)
|
|
2099 {
|
|
2100 /* We are in progress of frame creation. Return the frame
|
|
2101 being created, as it still not remembered in the window
|
|
2102 extra storage. */
|
276
|
2103 assert (!NILP (Vmswindows_frame_being_created));
|
|
2104 return Vmswindows_frame_being_created;
|
269
|
2105 }
|
|
2106 VOID_TO_LISP (f, l);
|
|
2107 return f;
|
249
|
2108 }
|
|
2109
|
213
|
2110
|
|
2111 /************************************************************************/
|
|
2112 /* methods */
|
|
2113 /************************************************************************/
|
|
2114
|
|
2115 static int
|
|
2116 emacs_mswindows_add_timeout (EMACS_TIME thyme)
|
|
2117 {
|
223
|
2118 int milliseconds;
|
213
|
2119 EMACS_TIME current_time;
|
|
2120 EMACS_GET_TIME (current_time);
|
|
2121 EMACS_SUB_TIME (thyme, thyme, current_time);
|
223
|
2122 milliseconds = EMACS_SECS (thyme) * 1000 +
|
|
2123 (EMACS_USECS (thyme) + 500) / 1000;
|
213
|
2124 if (milliseconds < 1)
|
|
2125 milliseconds = 1;
|
227
|
2126 ++mswindows_pending_timers_count;
|
249
|
2127 return SetTimer (NULL, 0, milliseconds,
|
|
2128 (TIMERPROC) mswindows_wm_timer_callback);
|
213
|
2129 }
|
|
2130
|
|
2131 static void
|
|
2132 emacs_mswindows_remove_timeout (int id)
|
|
2133 {
|
223
|
2134 struct Lisp_Event match_against;
|
|
2135 Lisp_Object emacs_event;
|
|
2136
|
233
|
2137 if (KillTimer (NULL, id))
|
|
2138 --mswindows_pending_timers_count;
|
223
|
2139
|
|
2140 /* If there is a dispatch event generated by this
|
|
2141 timeout in the queue, we have to remove it too. */
|
|
2142 match_against.event_type = timeout_event;
|
|
2143 match_against.event.timeout.interval_id = id;
|
|
2144 emacs_event = mswindows_cancel_dispatch_event (&match_against);
|
|
2145 if (!NILP (emacs_event))
|
|
2146 Fdeallocate_event(emacs_event);
|
213
|
2147 }
|
|
2148
|
219
|
2149 /* If `user_p' is false, then return whether there are any win32, timeout,
|
|
2150 * or subprocess events pending (that is, whether
|
|
2151 * emacs_mswindows_next_event() would return immediately without blocking).
|
|
2152 *
|
|
2153 * if `user_p' is true, then return whether there are any *user generated*
|
|
2154 * events available (that is, whether there are keyboard or mouse-click
|
|
2155 * events ready to be read). This also implies that
|
|
2156 * emacs_mswindows_next_event() would not block.
|
|
2157 */
|
213
|
2158 static int
|
|
2159 emacs_mswindows_event_pending_p (int user_p)
|
|
2160 {
|
274
|
2161 mswindows_need_event (0);
|
223
|
2162 return (!NILP (mswindows_u_dispatch_event_queue)
|
|
2163 || (!user_p && !NILP (mswindows_s_dispatch_event_queue)));
|
213
|
2164 }
|
|
2165
|
|
2166 /*
|
|
2167 * Return the next event
|
|
2168 */
|
|
2169 static void
|
|
2170 emacs_mswindows_next_event (struct Lisp_Event *emacs_event)
|
|
2171 {
|
223
|
2172 Lisp_Object event, event2;
|
|
2173
|
274
|
2174 mswindows_need_event (1);
|
213
|
2175
|
223
|
2176 event = mswindows_dequeue_dispatch_event (!NILP(mswindows_u_dispatch_event_queue));
|
|
2177 XSETEVENT (event2, emacs_event);
|
|
2178 Fcopy_event (event, event2);
|
|
2179 Fdeallocate_event (event);
|
213
|
2180 }
|
|
2181
|
|
2182 /*
|
|
2183 * Handle a magic event off the dispatch queue.
|
|
2184 */
|
|
2185 static void
|
|
2186 emacs_mswindows_handle_magic_event (struct Lisp_Event *emacs_event)
|
|
2187 {
|
|
2188 switch (EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event))
|
|
2189 {
|
|
2190 case WM_SETFOCUS:
|
|
2191 case WM_KILLFOCUS:
|
|
2192 {
|
223
|
2193 Lisp_Object frame = EVENT_CHANNEL (emacs_event);
|
|
2194 struct frame *f = XFRAME (frame);
|
213
|
2195 int in_p = (EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event) == WM_SETFOCUS);
|
|
2196 Lisp_Object conser;
|
223
|
2197
|
213
|
2198 /* struct gcpro gcpro1; */
|
|
2199
|
|
2200 /* Clear sticky modifiers here (if we had any) */
|
|
2201
|
|
2202 conser = Fcons (frame, Fcons (FRAME_DEVICE (f), in_p ? Qt : Qnil));
|
|
2203 /* GCPRO1 (conser); XXX Not necessary? */
|
|
2204 emacs_handle_focus_change_preliminary (conser);
|
|
2205 /* Under X the stuff up to here is done in the X event handler.
|
|
2206 I Don't know why */
|
|
2207 emacs_handle_focus_change_final (conser);
|
|
2208 /* UNGCPRO; */
|
223
|
2209
|
213
|
2210 }
|
|
2211 break;
|
|
2212
|
223
|
2213 case XM_MAPFRAME:
|
|
2214 case XM_UNMAPFRAME:
|
|
2215 {
|
|
2216 Lisp_Object frame = EVENT_CHANNEL (emacs_event);
|
|
2217 va_run_hook_with_args (EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event)
|
|
2218 == XM_MAPFRAME ?
|
|
2219 Qmap_frame_hook : Qunmap_frame_hook,
|
|
2220 1, frame);
|
|
2221 }
|
|
2222 break;
|
|
2223
|
249
|
2224 /* #### What about Enter & Leave */
|
213
|
2225 #if 0
|
|
2226 va_run_hook_with_args (in_p ? Qmouse_enter_frame_hook :
|
|
2227 Qmouse_leave_frame_hook, 1, frame);
|
|
2228 #endif
|
|
2229
|
|
2230 default:
|
|
2231 assert(0);
|
|
2232 }
|
|
2233 }
|
|
2234
|
274
|
2235 static HANDLE
|
|
2236 get_process_input_waitable (struct Lisp_Process *process)
|
|
2237 {
|
|
2238 Lisp_Object instr, outstr;
|
|
2239 get_process_streams (process, &instr, &outstr);
|
|
2240 assert (!NILP (instr));
|
|
2241 return get_ntpipe_input_stream_waitable (XLSTREAM (instr));
|
|
2242 }
|
|
2243
|
213
|
2244 static void
|
|
2245 emacs_mswindows_select_process (struct Lisp_Process *process)
|
|
2246 {
|
274
|
2247 HANDLE hev = get_process_input_waitable (process);
|
|
2248
|
|
2249 if (!add_waitable_handle (hev))
|
|
2250 error ("Too many active processes");
|
|
2251
|
276
|
2252 #ifdef HAVE_WIN32_PROCESSES
|
|
2253 {
|
|
2254 HANDLE hprocess = get_nt_process_handle (process);
|
|
2255 if (!add_waitable_handle (hprocess))
|
|
2256 {
|
|
2257 remove_waitable_handle (hev);
|
|
2258 error ("Too many active processes");
|
|
2259 }
|
|
2260 }
|
|
2261 #endif
|
213
|
2262 }
|
|
2263
|
|
2264 static void
|
|
2265 emacs_mswindows_unselect_process (struct Lisp_Process *process)
|
|
2266 {
|
274
|
2267 /* Process handle is removed in the event loop as soon
|
|
2268 as it is signaled, so don't bother here about it */
|
|
2269 HANDLE hev = get_process_input_waitable (process);
|
|
2270 remove_waitable_handle (hev);
|
213
|
2271 }
|
|
2272
|
|
2273 static void
|
|
2274 emacs_mswindows_select_console (struct console *con)
|
|
2275 {
|
|
2276 }
|
|
2277
|
|
2278 static void
|
|
2279 emacs_mswindows_unselect_console (struct console *con)
|
|
2280 {
|
|
2281 }
|
|
2282
|
|
2283 static void
|
|
2284 emacs_mswindows_quit_p (void)
|
|
2285 {
|
276
|
2286 /* Quit cannot happen in modal loop: all program
|
|
2287 input is dedicated to Windows. */
|
|
2288 if (mswindows_in_modal_loop)
|
|
2289 return;
|
|
2290
|
274
|
2291 /* Drain windows queue. This sets up number of quit
|
|
2292 characters in in the queue */
|
|
2293 mswindows_drain_windows_queue ();
|
223
|
2294
|
|
2295 if (mswindows_quit_chars_count > 0)
|
|
2296 {
|
|
2297 /* Yes there's a hidden one... Throw it away */
|
|
2298 struct Lisp_Event match_against;
|
|
2299 Lisp_Object emacs_event;
|
|
2300
|
|
2301 match_against.event_type = key_press_event;
|
|
2302 match_against.event.key.modifiers = FAKE_MOD_QUIT;
|
|
2303
|
|
2304 emacs_event = mswindows_cancel_dispatch_event (&match_against);
|
|
2305 assert (!NILP (emacs_event));
|
|
2306
|
|
2307 Vquit_flag = (XEVENT(emacs_event)->event.key.modifiers & MOD_SHIFT
|
|
2308 ? Qcritical : Qt);
|
|
2309
|
|
2310 Fdeallocate_event(emacs_event);
|
|
2311 --mswindows_quit_chars_count;
|
|
2312 }
|
213
|
2313 }
|
|
2314
|
274
|
2315 USID
|
|
2316 emacs_mswindows_create_stream_pair (void* inhandle, void* outhandle,
|
|
2317 Lisp_Object* instream,
|
|
2318 Lisp_Object* outstream,
|
|
2319 int flags)
|
|
2320 {
|
|
2321 /* Handles for streams */
|
|
2322 HANDLE hin, hout;
|
|
2323 /* fds. These just stored along with the streams, and are closed in
|
|
2324 delete stream pair method, because we need to handle fake unices
|
|
2325 here. */
|
|
2326 int fdi, fdo;
|
|
2327
|
|
2328 /* Decode inhandle and outhandle. Their meaning depends on
|
|
2329 the process implementation being used. */
|
|
2330 #if defined (HAVE_WIN32_PROCESSES)
|
|
2331 /* We're passed in Windows handles. That's what we like most... */
|
|
2332 hin = (HANDLE) inhandle;
|
|
2333 hout = (HANDLE) outhandle;
|
|
2334 fdi = fdo = -1;
|
|
2335 #elif defined (HAVE_UNIX_PROCESSES)
|
|
2336 /* We are passed UNIX fds. This must be Cygwin.
|
|
2337 Fetch os handles */
|
276
|
2338 hin = inhandle >= 0 ? (HANDLE)get_osfhandle ((int)inhandle) : INVALID_HANDLE_VALUE;
|
|
2339 hout = outhandle >= 0 ? (HANDLE)get_osfhandle ((int)outhandle) : INVALID_HANDLE_VALUE;
|
|
2340 fdi=(int)inhandle;
|
|
2341 fdo=(int)outhandle;
|
274
|
2342 #else
|
|
2343 #error "So, WHICH kind of processes do you want?"
|
|
2344 #endif
|
|
2345
|
|
2346 *instream = (hin != INVALID_HANDLE_VALUE
|
|
2347 ? make_ntpipe_input_stream (hin, fdi)
|
|
2348 : Qnil);
|
|
2349
|
276
|
2350 #ifdef HAVE_WIN32_PROCESSES
|
274
|
2351 *outstream = (hout != INVALID_HANDLE_VALUE
|
|
2352 ? make_ntpipe_output_stream (hout, fdo)
|
|
2353 : Qnil);
|
276
|
2354 #elif defined (HAVE_UNIX_PROCESSES)
|
|
2355 *outstream = (fdo >= 0
|
|
2356 ? make_filedesc_output_stream (fdo, 0, -1, LSTR_BLOCKED_OK)
|
|
2357 : Qnil);
|
|
2358
|
|
2359 #if defined(HAVE_UNIX_PROCESSES) && defined(HAVE_PTYS)
|
|
2360 /* FLAGS is process->pty_flag for UNIX_PROCESSES */
|
|
2361 if (flags && fdo >= 0)
|
|
2362 {
|
|
2363 Bufbyte eof_char = get_eof_char (fdo);
|
|
2364 int pty_max_bytes = get_pty_max_bytes (fdo);
|
|
2365 filedesc_stream_set_pty_flushing (XLSTREAM(*outstream), pty_max_bytes, eof_char);
|
|
2366 }
|
|
2367 #endif
|
|
2368 #endif
|
274
|
2369
|
|
2370 return (NILP (*instream) ? USID_ERROR
|
|
2371 : HANDLE_TO_USID (get_ntpipe_input_stream_waitable (XLSTREAM (*instream))));
|
|
2372 }
|
|
2373
|
|
2374 USID
|
|
2375 emacs_mswindows_delete_stream_pair (Lisp_Object instream,
|
|
2376 Lisp_Object outstream)
|
|
2377 {
|
|
2378 /* Oh nothing special here for Win32 at all */
|
|
2379 #if defined (HAVE_UNIX_PROCESSES)
|
|
2380 int in = (NILP(instream) ? -1
|
|
2381 : get_ntpipe_input_stream_param (XLSTREAM (instream)));
|
|
2382 int out = (NILP(outstream) ? -1
|
276
|
2383 : filedesc_stream_fd (XLSTREAM (outstream)));
|
274
|
2384
|
|
2385 if (in >= 0)
|
|
2386 close (in);
|
|
2387 if (out != in && out >= 0)
|
|
2388 close (out);
|
|
2389 #endif
|
|
2390
|
|
2391 return (NILP (instream) ? USID_DONTHASH
|
|
2392 : HANDLE_TO_USID (get_ntpipe_input_stream_waitable (XLSTREAM (instream))));
|
|
2393 }
|
|
2394
|
|
2395
|
263
|
2396 #ifndef HAVE_X_WINDOWS
|
213
|
2397 /* This is called from GC when a process object is about to be freed.
|
|
2398 If we've still got pointers to it in this file, we're gonna lose hard.
|
|
2399 */
|
|
2400 void
|
|
2401 debug_process_finalization (struct Lisp_Process *p)
|
|
2402 {
|
|
2403 #if 0 /* #### */
|
263
|
2404 Lisp_Object instr, outstr;
|
|
2405
|
|
2406 get_process_streams (p, &instr, &outstr);
|
213
|
2407 /* if it still has fds, then it hasn't been killed yet. */
|
263
|
2408 assert (NILP(instr));
|
|
2409 assert (NILP(outstr));
|
|
2410
|
|
2411 /* #### More checks here */
|
213
|
2412 #endif
|
|
2413 }
|
263
|
2414 #endif
|
213
|
2415
|
|
2416 /************************************************************************/
|
|
2417 /* initialization */
|
|
2418 /************************************************************************/
|
|
2419
|
|
2420 void
|
|
2421 vars_of_event_mswindows (void)
|
|
2422 {
|
223
|
2423 mswindows_u_dispatch_event_queue = Qnil;
|
|
2424 staticpro (&mswindows_u_dispatch_event_queue);
|
|
2425 mswindows_u_dispatch_event_queue_tail = Qnil;
|
|
2426
|
|
2427 mswindows_s_dispatch_event_queue = Qnil;
|
|
2428 staticpro (&mswindows_s_dispatch_event_queue);
|
|
2429 mswindows_s_dispatch_event_queue_tail = Qnil;
|
213
|
2430
|
231
|
2431 mswindows_error_caught_in_modal_loop = Qnil;
|
|
2432 staticpro (&mswindows_error_caught_in_modal_loop);
|
|
2433 mswindows_in_modal_loop = 0;
|
227
|
2434 mswindows_pending_timers_count = 0;
|
|
2435
|
213
|
2436 mswindows_event_stream = xnew (struct event_stream);
|
|
2437
|
|
2438 mswindows_event_stream->event_pending_p = emacs_mswindows_event_pending_p;
|
223
|
2439 mswindows_event_stream->next_event_cb = emacs_mswindows_next_event;
|
213
|
2440 mswindows_event_stream->handle_magic_event_cb = emacs_mswindows_handle_magic_event;
|
|
2441 mswindows_event_stream->add_timeout_cb = emacs_mswindows_add_timeout;
|
|
2442 mswindows_event_stream->remove_timeout_cb = emacs_mswindows_remove_timeout;
|
278
|
2443 mswindows_event_stream->quit_p_cb = emacs_mswindows_quit_p;
|
213
|
2444 mswindows_event_stream->select_console_cb = emacs_mswindows_select_console;
|
223
|
2445 mswindows_event_stream->unselect_console_cb = emacs_mswindows_unselect_console;
|
278
|
2446 #ifdef HAVE_MSG_SELECT
|
|
2447 mswindows_event_stream->select_process_cb =
|
|
2448 (void (*)(struct Lisp_Process*))event_stream_unixoid_select_process;
|
|
2449 mswindows_event_stream->unselect_process_cb =
|
|
2450 (void (*)(struct Lisp_Process*))event_stream_unixoid_unselect_process;
|
|
2451 mswindows_event_stream->create_stream_pair_cb = event_stream_unixoid_create_stream_pair;
|
|
2452 mswindows_event_stream->delete_stream_pair_cb = event_stream_unixoid_delete_stream_pair;
|
|
2453 #else
|
213
|
2454 mswindows_event_stream->select_process_cb = emacs_mswindows_select_process;
|
223
|
2455 mswindows_event_stream->unselect_process_cb = emacs_mswindows_unselect_process;
|
274
|
2456 mswindows_event_stream->create_stream_pair_cb = emacs_mswindows_create_stream_pair;
|
|
2457 mswindows_event_stream->delete_stream_pair_cb = emacs_mswindows_delete_stream_pair;
|
278
|
2458 #endif
|
223
|
2459
|
225
|
2460 DEFVAR_BOOL ("mswindows-dynamic-frame-resize", &mswindows_dynamic_frame_resize /*
|
223
|
2461 *Controls redrawing frame contents during mouse-drag or keyboard resize
|
|
2462 operation. When non-nil, the frame is redrawn while being resized. When
|
|
2463 nil, frame is not redrawn, and exposed areas are filled with default
|
|
2464 MDI application background color. Note that this option only has effect
|
|
2465 if "Show window contents while dragging" is on in system Display/Plus!
|
|
2466 settings.
|
|
2467 Default is t on fast machines, nil on slow.
|
|
2468 */ );
|
|
2469
|
|
2470 /* The description copied verbatim from nt-emacs. (C) Geoff Voelker */
|
272
|
2471 DEFVAR_INT ("mswindows-mouse-button-tolerance", &mswindows_mouse_button_tolerance /*
|
223
|
2472 *Analogue of double click interval for faking middle mouse events.
|
|
2473 The value is the minimum time in milliseconds that must elapse between
|
|
2474 left/right button down events before they are considered distinct events.
|
|
2475 If both mouse buttons are depressed within this interval, a middle mouse
|
|
2476 button down event is generated instead.
|
|
2477 If negative or zero, currently set system default is used instead.
|
|
2478 */ );
|
|
2479
|
|
2480 /* The description copied verbatim from nt-emacs. (C) Geoff Voelker */
|
225
|
2481 DEFVAR_INT ("mswindows-num-mouse-buttons", &mswindows_num_mouse_buttons /*
|
223
|
2482 Number of physical mouse buttons.
|
|
2483 */ );
|
|
2484
|
272
|
2485 DEFVAR_INT ("mswindows-mouse-button-max-skew-x", &mswindows_mouse_button_max_skew_x /*
|
223
|
2486 *Maximum horizontal distance in pixels between points in which left and
|
|
2487 right button clicks occured for them to be translated into single
|
|
2488 middle button event. Clicks must occur in time not longer than defined
|
272
|
2489 by the variable `mswindows-mouse-button-tolerance'.
|
223
|
2490 If negative or zero, currently set system default is used instead.
|
|
2491 */ );
|
|
2492
|
272
|
2493 DEFVAR_INT ("mswindows-mouse-button-max-skew-y", &mswindows_mouse_button_max_skew_y /*
|
223
|
2494 *Maximum vertical distance in pixels between points in which left and
|
|
2495 right button clicks occured for them to be translated into single
|
|
2496 middle button event. Clicks must occur in time not longer than defined
|
272
|
2497 by the variable `mswindows-mouse-button-tolerance'.
|
223
|
2498 If negative or zero, currently set system default is used instead.
|
|
2499 */ );
|
|
2500
|
272
|
2501 mswindows_mouse_button_max_skew_x = 0;
|
|
2502 mswindows_mouse_button_max_skew_y = 0;
|
|
2503 mswindows_mouse_button_tolerance = 0;
|
213
|
2504 }
|
|
2505
|
|
2506 void
|
|
2507 syms_of_event_mswindows (void)
|
|
2508 {
|
|
2509 }
|
|
2510
|
|
2511 void
|
274
|
2512 lstream_type_create_mswindows_selectable (void)
|
|
2513 {
|
|
2514 init_slurp_stream ();
|
|
2515 init_shove_stream ();
|
|
2516 }
|
|
2517
|
|
2518 void
|
213
|
2519 init_event_mswindows_late (void)
|
|
2520 {
|
278
|
2521 #ifdef HAVE_MSG_SELECT
|
|
2522 windows_fd = open("/dev/windows", O_RDONLY | O_NONBLOCK, 0);
|
|
2523 assert (windows_fd>=0);
|
|
2524 FD_SET (windows_fd, &input_wait_mask);
|
|
2525 /* for some reason I get blocks on the signal event pipe, which is
|
|
2526 bad...
|
|
2527 signal_event_pipe_initialized = 0; */
|
|
2528 #endif
|
|
2529
|
213
|
2530 event_stream = mswindows_event_stream;
|
223
|
2531
|
|
2532 mswindows_dynamic_frame_resize = !GetSystemMetrics (SM_SLOWMACHINE);
|
|
2533 mswindows_num_mouse_buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
|
213
|
2534 }
|