annotate src/event-msw.c @ 261:405dd6d1825b r20-5b29

Import from CVS: tag r20-5b29
author cvs
date Mon, 13 Aug 2007 10:23:51 +0200
parents 11cf20601dec
children 727739f917cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1 /* The mswindows event_stream interface.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
2 Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
3 Copyright (C) 1995 Sun Microsystems, Inc.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
4 Copyright (C) 1996 Ben Wing.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
5 Copyright (C) 1997 Jonathan Harris.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
6
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
7 This file is part of XEmacs.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
8
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
9 XEmacs is free software; you can redistribute it and/or modify it
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
11 Free Software Foundation; either version 2, or (at your option) any
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
12 later version.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
13
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
17 for more details.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
18
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
20 along with XEmacs; see the file COPYING. If not, write to
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
22 Boston, MA 02111-1307, USA. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
23
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
24 /* Synched up with: Not in FSF. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
25
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
26 /* Authorship:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
27
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
28 Ultimately based on FSF.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
29 Rewritten by Ben Wing.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
30 Rewritten for mswindows by Jonathan Harris, November 1997 for 20.4.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
31 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
32
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
33 #include <config.h>
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
34 #include "lisp.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
35
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
36 #include "console-msw.h"
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
37
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
38 #ifdef HAVE_SCROLLBARS
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
39 # include "scrollbar-msw.h"
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
40 #endif
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
41
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
42 #ifdef HAVE_MENUBARS
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
43 # include "menubar-msw.h"
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
44 #endif
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
45
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
46 #include "device.h"
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
47 #include "emacsfns.h"
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
48 #include "events.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
49 #include "frame.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
50 #include "process.h"
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
51 #include "redisplay.h"
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
52 #include "sysproc.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
53 #include "syswait.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
54 #include "systime.h"
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
55
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
56 #include "events-mod.h"
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
57
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
58 #ifdef BROKEN_CYGWIN
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
59 int WINAPI DdeCmpStringHandles (HSZ, HSZ);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
60 HDDEDATA WINAPI DdeCreateDataHandle (DWORD, LPBYTE, DWORD, DWORD, HSZ,
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
61 UINT, UINT);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
62 #endif
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 249
diff changeset
63
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
64 #ifdef HAVE_MENUBARS
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
65 #define ADJR_MENUFLAG TRUE
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
66 #else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
67 #define ADJR_MENUFLAG FALSE
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
68 #endif
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
69
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
70 /* Fake key modifier which is attached to a quit char event.
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
71 Removed upon dequeueing an event */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
72 #define FAKE_MOD_QUIT 0x80
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
73
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
74 /* Timer ID used for button2 emulation */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
75 #define BUTTON_2_TIMER_ID 1
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
76
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
77 /* Drag and drop event data types (subset of types in offix-types.h) */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
78 #define DndFile 2
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
79 #define DndFiles 3
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
80 #define DndText 4
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
81
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
82
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
83 static Lisp_Object mswindows_find_frame (HWND hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
84 static Lisp_Object mswindows_find_console (HWND hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
85 static Lisp_Object mswindows_key_to_emacs_keysym(int mswindows_key, int mods);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
86 static int mswindows_modifier_state (BYTE* keymap, int has_AltGr);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
87 static void mswindows_set_chord_timer (HWND hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
88 static int mswindows_button2_near_enough (POINTS p1, POINTS p2);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
89 static int mswindows_current_layout_has_AltGr (void);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
90
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
91 static struct event_stream *mswindows_event_stream;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
92
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
93 /*
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
94 * Two separate queues, for efficiency, one (_u_) for user events, and
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
95 * another (_s_) for non-user ones. We always return events out of the
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
96 * first one until it is empty and only then proceed with the second
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
97 * one.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
98 */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
99 static Lisp_Object mswindows_u_dispatch_event_queue, mswindows_u_dispatch_event_queue_tail;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
100 static Lisp_Object mswindows_s_dispatch_event_queue, mswindows_s_dispatch_event_queue_tail;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
101
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
102 /* The number of things we can wait on */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
103 #define MAX_WAITABLE (MAXIMUM_WAIT_OBJECTS - 1)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
104
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
105 /* List of mswindows waitable handles. */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
106 static HANDLE mswindows_waitable[MAX_WAITABLE];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
107
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
108 /* Count of quit chars currently in the queue */
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
109 /* Incremented in WM_[SYS]KEYDOWN handler in the mswindows_wnd_proc()
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
110 Decremented in mswindows_dequeue_dispatch_event() */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
111 int mswindows_quit_chars_count = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
112
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
113 /* These are Lisp integers; see DEFVARS in this file for description. */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
114 int mswindows_dynamic_frame_resize;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
115 int mswindows_num_mouse_buttons;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
116 int mswindows_button2_max_skew_x;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
117 int mswindows_button2_max_skew_y;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
118 int mswindows_button2_chord_time;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
119
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
120 /* Number of wait handles */
245
51092a27c943 Import from CVS: tag r20-5b21
cvs
parents: 239
diff changeset
121 static int mswindows_waitable_count=0;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
122
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
123 /* This is the event signaled by the event pump.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
124 See mswindows_pump_outstanding_events for comments */
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
125 static Lisp_Object mswindows_error_caught_in_modal_loop;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
126 static int mswindows_in_modal_loop;
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
127
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
128 /* Count of wound timers */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
129 static int mswindows_pending_timers_count;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
130
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
131 static int
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
132 mswindows_user_event_p (struct Lisp_Event* sevt)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
133 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
134 return (sevt->event_type == key_press_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
135 || sevt->event_type == button_press_event
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
136 || sevt->event_type == button_release_event
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
137 || sevt->event_type == dnd_drop_event);
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
138 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
139
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
140 /************************************************************************/
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
141 /* Dispatch queue management */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
142 /************************************************************************/
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
143
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
144 /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
145 * Add an emacs event to the proper dispatch queue
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
146 */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
147 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
148 mswindows_enqueue_dispatch_event (Lisp_Object event)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
149 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
150 int user_p = mswindows_user_event_p (XEVENT(event));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
151 enqueue_event (event,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
152 user_p ? &mswindows_u_dispatch_event_queue :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
153 &mswindows_s_dispatch_event_queue,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
154 user_p ? &mswindows_u_dispatch_event_queue_tail :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
155 &mswindows_s_dispatch_event_queue_tail);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
156
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
157 /* This one does not go to window procedure, hence does not
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
158 generate XM_BUMPQUEUE magic event! */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
159 PostMessage (NULL, XM_BUMPQUEUE, 0, 0);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
160 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
161
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
162 void
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
163 mswindows_enqueue_magic_event (HWND hwnd, UINT message)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
164 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
165 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
166 struct Lisp_Event* event = XEVENT (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
167
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
168 event->channel = mswindows_find_frame (hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
169 event->timestamp = GetMessageTime();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
170 event->event_type = magic_event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
171 EVENT_MSWINDOWS_MAGIC_TYPE (event) = message;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
172
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
173 mswindows_enqueue_dispatch_event (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
174 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
175
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
176 static void
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
177 mswindows_enqueue_mouse_button_event (HWND hwnd, UINT message, POINTS where, DWORD when)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
178 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
179
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
180 /* We always use last message time, because mouse button
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
181 events may get delayed, and XEmacs double click
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
182 recognition will fail */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
183
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
184 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
185 struct Lisp_Event* event = XEVENT(emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
186
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
187 event->channel = mswindows_find_frame(hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
188 event->timestamp = when;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
189 event->event.button.button =
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
190 (message==WM_LBUTTONDOWN || message==WM_LBUTTONUP) ? 1 :
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
191 ((message==WM_RBUTTONDOWN || message==WM_RBUTTONUP) ? 3 : 2);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
192 event->event.button.x = where.x;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
193 event->event.button.y = where.y;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
194 event->event.button.modifiers = mswindows_modifier_state (NULL, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
195
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
196 if (message==WM_LBUTTONDOWN || message==WM_MBUTTONDOWN ||
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
197 message==WM_RBUTTONDOWN)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
198 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
199 event->event_type = button_press_event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
200 SetCapture (hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
201 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
202 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
203 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
204 event->event_type = button_release_event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
205 ReleaseCapture ();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
206 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
207
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
208 mswindows_enqueue_dispatch_event (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
209 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
210
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
211 static void
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
212 mswindows_enqueue_keypress_event (HWND hwnd, Lisp_Object keysym, int mods)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
213 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
214 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
215 struct Lisp_Event* event = XEVENT(emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
216
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
217 event->channel = mswindows_find_console(hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
218 event->timestamp = GetMessageTime();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
219 event->event_type = key_press_event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
220 event->event.key.keysym = keysym;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
221 event->event.key.modifiers = mods;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
222 mswindows_enqueue_dispatch_event (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
223 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
224
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
225 /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
226 * Remove and return the first emacs event on the dispatch queue.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
227 * Give a preference to user events over non-user ones.
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
228 */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
229 static Lisp_Object
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
230 mswindows_dequeue_dispatch_event ()
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
231 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
232 Lisp_Object event;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
233 struct Lisp_Event* sevt;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
234
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
235 assert (!NILP(mswindows_u_dispatch_event_queue) ||
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
236 !NILP(mswindows_s_dispatch_event_queue));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
237
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
238 event = dequeue_event (
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
239 NILP(mswindows_u_dispatch_event_queue) ?
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
240 &mswindows_s_dispatch_event_queue :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
241 &mswindows_u_dispatch_event_queue,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
242 NILP(mswindows_u_dispatch_event_queue) ?
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
243 &mswindows_s_dispatch_event_queue_tail :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
244 &mswindows_u_dispatch_event_queue_tail);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
245
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
246 sevt = XEVENT(event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
247 if (sevt->event_type == key_press_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
248 && (sevt->event.key.modifiers & FAKE_MOD_QUIT))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
249 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
250 sevt->event.key.modifiers &= ~FAKE_MOD_QUIT;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
251 --mswindows_quit_chars_count;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
252 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
253
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
254 return event;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
255 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
256
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
257 /*
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
258 * Remove and return the first emacs event on the dispatch queue that matches
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
259 * the supplied event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
260 * Timeout event matches if interval_id equals to that of the given event.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
261 * Keypress event matches if logical AND between modifiers bitmask of the
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
262 * event in the queue and that of the given event is non-zero
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
263 * For all other event types, this function asserts.
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
264 */
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
265
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
266 Lisp_Object
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
267 mswindows_cancel_dispatch_event (struct Lisp_Event* match)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
268 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
269 Lisp_Object event;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
270 Lisp_Object previous_event=Qnil;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
271 int user_p = mswindows_user_event_p (match);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
272 Lisp_Object* head = user_p ? &mswindows_u_dispatch_event_queue :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
273 &mswindows_s_dispatch_event_queue;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
274 Lisp_Object* tail = user_p ? &mswindows_u_dispatch_event_queue_tail :
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
275 &mswindows_s_dispatch_event_queue_tail;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
276
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
277 assert (match->event_type == timeout_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
278 || match->event_type == key_press_event);
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
279
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
280 EVENT_CHAIN_LOOP (event, *head)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
281 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
282 int found = 1;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
283 if (XEVENT_TYPE (event) != match->event_type)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
284 found = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
285 if (found && match->event_type == timeout_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
286 && (XEVENT(event)->event.timeout.interval_id !=
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
287 match->event.timeout.interval_id))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
288 found = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
289 if (found && match->event_type == key_press_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
290 && ((XEVENT(event)->event.key.modifiers &
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
291 match->event.key.modifiers) == 0))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
292 found = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
293
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
294 if (found)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
295 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
296 if (NILP (previous_event))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
297 dequeue_event (head, tail);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
298 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
299 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
300 XSET_EVENT_NEXT (previous_event, XEVENT_NEXT (event));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
301 if (EQ (*tail, event))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
302 *tail = previous_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
303 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
304
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
305 return event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
306 }
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
307 previous_event = event;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
308 }
239
41f2f0e326e9 Import from CVS: tag r20-5b18
cvs
parents: 233
diff changeset
309 return Qnil;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
310 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
311
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
312
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
313 /************************************************************************/
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
314 /* Event pump */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
315 /************************************************************************/
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
316
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
317 static Lisp_Object
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
318 mswindows_modal_loop_error_handler (Lisp_Object cons_sig_data,
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
319 Lisp_Object u_n_u_s_e_d)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
320 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
321 mswindows_error_caught_in_modal_loop = cons_sig_data;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
322 return Qunbound;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
323 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
324
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
325 Lisp_Object
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
326 mswindows_protect_modal_loop (Lisp_Object (*bfun) (Lisp_Object barg),
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
327 Lisp_Object barg)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
328 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
329 Lisp_Object tmp;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
330
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
331 ++mswindows_in_modal_loop;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
332 tmp = condition_case_1 (Qt,
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
333 bfun, barg,
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
334 mswindows_modal_loop_error_handler, Qnil);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
335 --mswindows_in_modal_loop;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
336
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
337 return tmp;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
338 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
339
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
340 void
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
341 mswindows_unmodalize_signal_maybe (void)
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
342 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
343 if (!NILP (mswindows_error_caught_in_modal_loop))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
344 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
345 /* Got an error while messages were pumped while
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
346 in window procedure - have to resignal */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
347 Lisp_Object sym = XCAR (mswindows_error_caught_in_modal_loop);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
348 Lisp_Object data = XCDR (mswindows_error_caught_in_modal_loop);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
349 mswindows_error_caught_in_modal_loop = Qnil;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
350 Fsignal (sym, data);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
351 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
352 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
353
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
354 /*
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
355 * This is an unsafe part of event pump, guarded by
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
356 * condition_case. See mswindows_pump_outstanding_events
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
357 */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
358 static Lisp_Object
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
359 mswindows_unsafe_pump_events (Lisp_Object u_n_u_s_e_d)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
360 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
361 /* This function can call lisp */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
362 Lisp_Object event = Fmake_event (Qnil, Qnil);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
363 struct gcpro gcpro1;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
364 int do_redisplay = 0;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
365 GCPRO1 (event);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
366
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
367 while (detect_input_pending ())
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
368 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
369 Fnext_event (event, Qnil);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
370 Fdispatch_event (event);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
371 do_redisplay = 1;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
372 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
373
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
374 if (do_redisplay)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
375 redisplay ();
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
376
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
377 Fdeallocate_event (event);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
378 UNGCPRO;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
379
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
380 /* Qt becomes return value of mswindows_pump_outstanding_events
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
381 once we get here */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
382 return Qt;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
383 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
384
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
385 /*
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
386 * This function pumps emacs events, while available, by using
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
387 * next_message/dispatch_message loop. Errors are trapped around
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
388 * the loop so the function always returns.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
389 *
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
390 * Windows message queue is not looked into during the call,
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
391 * neither are waitable handles checked. The function pumps
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
392 * thus only dispatch events already queued, as well as those
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
393 * resulted in dispatching thereof. This is done by setting
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
394 * module local variable mswidows_in_modal_loop to nonzero.
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
395 *
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
396 * Return value is Qt if no errors was trapped, or Qunbound if
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
397 * there was an error.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
398 *
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
399 * In case of error, a cons representing the error, in the
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
400 * form (SIGNAL . DATA), is stored in the module local variable
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
401 * mswindows_error_caught_in_modal_loop. This error is signaled
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
402 * again when DispatchMessage returns. Thus, Windows internal
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
403 * modal loops are protected against throws, which are proven
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
404 * to corrupt internal Windows structures.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
405 *
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
406 * In case of success, mswindows_error_caught_in_modal_loop is
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
407 * assigned Qnil.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
408 *
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
409 * If the value of mswindows_error_caught_in_modal_loop is not
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
410 * nil already upon entry, the function just returns non-nil.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
411 * This situation means that a new event has been queued while
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
412 * cancleng mode. The event will be dequeued on the next regular
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
413 * call of next-event; the pump is off since error is caught.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
414 * The caller must *unconditionally* cancel modal loop if the
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
415 * value returned by this function is nil. Otherwise, everything
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
416 * will become frozen until the modal loop exits under normal
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
417 * condition (scrollbar drag is released, menu closed etc.)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
418 */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
419 Lisp_Object
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
420 mswindows_pump_outstanding_events (void)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
421 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
422 /* This function can call lisp */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
423
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
424 Lisp_Object result = Qt;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
425 struct gcpro gcpro1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
426 GCPRO1 (result);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
427
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
428 if (NILP(mswindows_error_caught_in_modal_loop))
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
429 result = mswindows_protect_modal_loop (mswindows_unsafe_pump_events, Qnil);
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
430 UNGCPRO;
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
431 return result;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
432 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
433
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
434
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
435
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
436 static void
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
437 mswindows_drain_windows_queue ()
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
438 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
439 MSG msg;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
440 while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
441 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
442 DispatchMessage (&msg);
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
443 mswindows_unmodalize_signal_maybe ();
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
444 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
445 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
446
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
447 /*
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
448 * This is a special flavour of the mswindows_need_event function,
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
449 * used while in event pump. Actually, there is only kind of events
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
450 * allowed while in event pump: a timer. An attempt to fetch any
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
451 * other event leads to a dealock, as there's no source of user input
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
452 * ('cause event pump mirrors windows modal loop, which is a sole
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
453 * owner of thread message queue).
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
454 *
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
455 * To detect this, we use a counter of active timers, and allow
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
456 * fetching WM_TIMER messages. Instead of trying to fetch a WM_TIMER
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
457 * which will never come when there are no pending timers, which leads
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
458 * to deadlock, we simply signal an error.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
459 *
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
460 * The implementation does not honor user_p by design.
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
461 */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
462 static void
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
463 mswindows_need_event_in_modal_loop (int user_p, int badly_p)
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
464 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
465 MSG msg;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
466
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
467 /* Check if already have one */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
468 if (!NILP (mswindows_u_dispatch_event_queue)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
469 || !NILP (mswindows_s_dispatch_event_queue))
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
470 return;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
471
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
472 /* No event is ok */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
473 if (!badly_p)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
474 return;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
475
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
476 /* We do not check the _u_ queue, because timers go to _s_ */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
477 while (NILP (mswindows_s_dispatch_event_queue))
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
478 {
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
479 /* We'll deadlock if go waiting */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
480 if (mswindows_pending_timers_count == 0)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
481 error ("Deadlock due to an attempt to call next-event in a wrong context");
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
482
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
483 /* Fetch and dispatch any pending timers */
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
484 GetMessage (&msg, NULL, WM_TIMER, WM_TIMER);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
485 DispatchMessage (&msg);
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
486 }
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
487 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
488
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
489 /*
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
490 * This drains the event queue and fills up two internal queues until
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
491 * an event of a type specified by USER_P is retrieved.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
492 *
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
493 * If user_p, then the function drains until the first user event, or
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
494 * the first non-user event if there no user events. Otherwise, If
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
495 * not user_p, it does not give preference to user events.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
496 *
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
497 * If badly_p, then the function does not return until an event is
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
498 * available.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
499 *
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
500 * The code does not rely on MsgWaitForMultipleObjects preference for
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
501 * messages over waitable handles.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
502 *
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
503 * Used by emacs_mswindows_event_pending_p and emacs_mswindows_next_event
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
504 */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
505 static void
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
506 mswindows_need_event (int user_p, int badly_p)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
507 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
508 int active;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
509
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
510 if (mswindows_in_modal_loop)
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
511 {
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
512 mswindows_need_event_in_modal_loop (user_p, badly_p);
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
513 return;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
514 }
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
515
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
516 /* Have to drain Windows message queue first, otherwise, we may miss
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
517 quit char when called from quit_p */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
518 mswindows_drain_windows_queue ();
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
519
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
520 while (NILP (mswindows_u_dispatch_event_queue) &&
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
521 (user_p || NILP (mswindows_s_dispatch_event_queue)))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
522 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
523 /* If we already have an event, we've got someting to return - no wait! */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
524 if (!NILP (mswindows_u_dispatch_event_queue)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
525 || !NILP (mswindows_s_dispatch_event_queue))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
526 badly_p = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
527
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
528 /* Now try getting a message */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
529 active = MsgWaitForMultipleObjects (mswindows_waitable_count,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
530 mswindows_waitable,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
531 FALSE, badly_p ? INFINITE : 0,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
532 QS_ALLINPUT);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
533
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
534 /* This will assert if handle being waited for becomes abandoned.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
535 Not the case currently tho */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
536 assert ((!badly_p && active == WAIT_TIMEOUT) ||
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
537 (active >= WAIT_OBJECT_0 &&
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
538 active <= WAIT_OBJECT_0 + mswindows_waitable_count));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
539
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
540 if (active == WAIT_TIMEOUT)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
541 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
542 /* No luck trying - just return what we've already got */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
543 return;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
544 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
545 else if (active == WAIT_OBJECT_0 + mswindows_waitable_count)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
546 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
547 /* Got your message, thanks */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
548 mswindows_drain_windows_queue ();
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
549 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
550 else
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
551 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
552 /* XXX FIXME: We should do some kind of round-robin scheme to ensure fairness */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
553 int waitable = active - WAIT_OBJECT_0;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
554 assert(0); /* #### */
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
555 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
556 } /* while */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
557
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
558 return;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
559 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
560
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
561 /************************************************************************/
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
562 /* Event generators */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
563 /************************************************************************/
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
564
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
565 /*
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
566 * Callback procedure for synchronous timer messages
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
567 */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
568 static void CALLBACK
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
569 mswindows_wm_timer_callback (HWND hwnd, UINT umsg, UINT id_timer, DWORD dwtime)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
570 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
571 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
572 struct Lisp_Event *event = XEVENT (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
573
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
574 if (KillTimer (NULL, id_timer))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
575 --mswindows_pending_timers_count;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
576
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
577 event->channel = Qnil;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
578 event->timestamp = dwtime;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
579 event->event_type = timeout_event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
580 event->event.timeout.interval_id = id_timer;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
581
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
582 mswindows_enqueue_dispatch_event (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
583 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
584
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
585 /*
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
586 * Callback procedure for dde messages
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
587 */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
588 HDDEDATA CALLBACK
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
589 mswindows_dde_callback (UINT uType, UINT uFmt, HCONV hconv,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
590 HSZ hszTopic, HSZ hszItem, HDDEDATA hdata,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
591 DWORD dwData1, DWORD dwData2)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
592 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
593 switch (uType)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
594 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
595 case XTYP_CONNECT:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
596 if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
597 return (HDDEDATA)TRUE;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
598 return (HDDEDATA)FALSE;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
599
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
600 case XTYP_WILDCONNECT:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
601 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
602 /* We only support one {service,topic} pair */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
603 HSZPAIR pairs[2] = {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
604 { mswindows_dde_service, mswindows_dde_topic_system }, { 0, 0 } };
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
605
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
606 if (!(hszItem || DdeCmpStringHandles (hszItem, mswindows_dde_service)) &&
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
607 !(hszTopic || DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
608 return (DdeCreateDataHandle (mswindows_dde_mlid, (LPBYTE)pairs,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
609 sizeof (pairs), 0L, 0, uFmt, 0));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
610 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
611 return (HDDEDATA)NULL;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
612
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
613 case XTYP_EXECUTE:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
614 if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
615 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
616 DWORD len = DdeGetData (hdata, NULL, 0, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
617 char *cmd = alloca (len+1);
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
618 #ifdef __CYGWIN32__
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
619 char *cmd_1;
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
620 #endif
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
621 char *end;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
622 Lisp_Object l_dndlist;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
623 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
624 struct Lisp_Event *event = XEVENT (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
625
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
626 DdeGetData (hdata, cmd, len, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
627 cmd[len] = '\0';
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
628 DdeFreeDataHandle (hdata);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
629
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
630 /* Check syntax & that it's an [Open("foo")] command */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
631 /* #### Ought to be generalised and accept some other commands */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
632 if (*cmd == '[')
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
633 cmd++;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
634 if (strnicmp (cmd, MSWINDOWS_DDE_ITEM_OPEN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
635 strlen (MSWINDOWS_DDE_ITEM_OPEN)))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
636 return DDE_FNOTPROCESSED;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
637 cmd += strlen (MSWINDOWS_DDE_ITEM_OPEN);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
638 while (*cmd==' ')
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
639 cmd++;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
640 if (*cmd!='(' || *(cmd+1)!='\"')
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
641 return DDE_FNOTPROCESSED;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
642 end = (cmd+=2);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
643 while (*end && *end!='\"')
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
644 end++;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
645 if (!*end)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
646 return DDE_FNOTPROCESSED;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
647 *end = '\0';
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
648 if (*(++end)!=')')
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
649 return DDE_FNOTPROCESSED;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
650 if (*(++end)==']')
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
651 end++;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
652 if (*end)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
653 return DDE_FNOTPROCESSED;
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
654 #ifdef __CYGWIN32__
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
655 CYGWIN_CONV_PATH(cmd,cmd_1);
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
656 cmd = cmd_1;
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
657 #endif
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
658 l_dndlist = make_ext_string (cmd, strlen(cmd), FORMAT_FILENAME);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
659
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
660 event->channel = Qnil;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
661 event->timestamp = GetTickCount();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
662 event->event_type = dnd_drop_event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
663 event->event.dnd_drop.button = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
664 event->event.dnd_drop.modifiers = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
665 event->event.dnd_drop.x = -1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
666 event->event.dnd_drop.y = -1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
667 event->event.dnd_drop.data = Fcons (make_int (DndFile),
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
668 Fcons (l_dndlist, Qnil));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
669 mswindows_enqueue_dispatch_event (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
670
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
671 return (HDDEDATA) DDE_FACK;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
672 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
673 DdeFreeDataHandle (hdata);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
674 return (HDDEDATA) DDE_FNOTPROCESSED;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
675 default:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
676 return (HDDEDATA) NULL;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
677 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
678
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
679 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
680
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
681 /*
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
682 * The windows procedure for the window class XEMACS_CLASS
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
683 */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
684 LRESULT WINAPI
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
685 mswindows_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
686 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
687 /* Note: Remember to initialise emacs_event and event before use.
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
688 This code calls code that can GC. You must GCPRO before calling such code. */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
689 Lisp_Object emacs_event = Qnil;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
690 Lisp_Object fobj = Qnil;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
691
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
692 struct Lisp_Event *event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
693 struct frame *frame;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
694 struct mswindows_frame* msframe;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
695
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
696 switch (message)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
697 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
698 case WM_ERASEBKGND:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
699 /* Erase background only during non-dynamic sizing */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
700 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
701 if (msframe->sizing && !mswindows_dynamic_frame_resize)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
702 goto defproc;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
703 return 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
704
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
705 case WM_CLOSE:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
706 fobj = mswindows_find_frame (hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
707 enqueue_misc_user_event (fobj, Qeval, list3 (Qdelete_frame, fobj, Qt));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
708 mswindows_enqueue_magic_event (hwnd, XM_BUMPQUEUE);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
709 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
710
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
711 case WM_KEYDOWN:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
712 case WM_SYSKEYDOWN:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
713 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
714 BYTE keymap[256];
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
715 int has_AltGr = mswindows_current_layout_has_AltGr ();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
716 int mods;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
717 Lisp_Object keysym;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
718
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
719 GetKeyboardState (keymap);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
720 mods = mswindows_modifier_state (keymap, has_AltGr);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
721
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
722 /* Handle those keys that TranslateMessage won't generate a WM_CHAR for */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
723 if (!NILP (keysym = mswindows_key_to_emacs_keysym(wParam, mods)))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
724 mswindows_enqueue_keypress_event (hwnd, keysym, mods);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
725 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
726 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
727 int quit_ch = CONSOLE_QUIT_CHAR (XCONSOLE (mswindows_find_console (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
728 BYTE keymap_orig[256];
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
729 MSG msg = { hwnd, message, wParam, lParam, GetMessageTime(), (GetMessagePos()) };
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
730 memcpy (keymap_orig, keymap, 256);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
731
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
732 /* Clear control and alt modifiers out of the keymap */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
733 keymap [VK_RCONTROL] = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
734 keymap [VK_LMENU] = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
735 if (!has_AltGr || !(keymap [VK_LCONTROL] & 0x80) || !(keymap [VK_RMENU] & 0x80))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
736 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
737 keymap [VK_LCONTROL] = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
738 keymap [VK_CONTROL] = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
739 keymap [VK_RMENU] = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
740 keymap [VK_MENU] = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
741 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
742 SetKeyboardState (keymap);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
743
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
744 /* Have some WM_[SYS]CHARS in the queue */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
745 TranslateMessage (&msg);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
746
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
747 while (PeekMessage (&msg, hwnd, WM_CHAR, WM_CHAR, PM_REMOVE)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
748 ||PeekMessage (&msg, hwnd, WM_SYSCHAR, WM_SYSCHAR, PM_REMOVE))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
749 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
750 int ch = msg.wParam;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
751 /* CH is a character code for the key:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
752 'C' for Shift+C and Ctrl+Shift+C
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
753 'c' for c and Ctrl+c */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
754
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
755 /* #### If locale is not C, US or other latin-1,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
756 isalpha() maybe not what do we mean */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
757
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
758 /* XEmacs doesn't seem to like Shift on non-alpha keys */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
759 if (!isalpha(ch))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
760 mods &= ~MOD_SHIFT;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
761
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
762 /* Un-capitalise alpha control keys */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
763 if ((mods & MOD_CONTROL) && isalpha(ch))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
764 ch |= ('A' ^ 'a');
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
765
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
766 /* If a quit char with no modifiers other than control and
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
767 shift, then mark it with a fake modifier, which is removed
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
768 upon dequeueing the event */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
769 /* #### This might also not withstand localization, if
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
770 quit character is not a latin-1 symbol */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
771 if (((quit_ch < ' ' && (mods & MOD_CONTROL) && quit_ch + 'a' - 1 == ch)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
772 || (quit_ch >= ' ' && !(mods & MOD_CONTROL) && quit_ch == ch))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
773 && ((mods & ~(MOD_CONTROL | MOD_SHIFT)) == 0))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
774 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
775 mods |= FAKE_MOD_QUIT;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
776 ++mswindows_quit_chars_count;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
777 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
778
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
779 mswindows_enqueue_keypress_event (hwnd, make_char(ch), mods);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
780 } /* while */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
781 SetKeyboardState (keymap_orig);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
782 } /* else */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
783 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
784 goto defproc;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
785
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
786 case WM_MBUTTONDOWN:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
787 case WM_MBUTTONUP:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
788 /* Real middle mouse button has nothing to do with emulated one:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
789 if one wants to exercise fingers playing chords on the mouse,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
790 he is allowed to do that! */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
791 mswindows_enqueue_mouse_button_event (hwnd, message,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
792 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
793 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
794
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
795 case WM_LBUTTONUP:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
796 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
797 msframe->last_click_time = GetMessageTime();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
798
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
799 KillTimer (hwnd, BUTTON_2_TIMER_ID);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
800 msframe->button2_need_lbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
801 if (msframe->ignore_next_lbutton_up)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
802 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
803 msframe->ignore_next_lbutton_up = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
804 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
805 else if (msframe->button2_is_down)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
806 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
807 msframe->button2_is_down = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
808 msframe->ignore_next_rbutton_up = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
809 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONUP,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
810 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
811 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
812 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
813 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
814 if (msframe->button2_need_rbutton)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
815 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
816 msframe->button2_need_rbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
817 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
818 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
819 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
820 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONUP,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
821 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
822 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
823 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
824
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
825 case WM_RBUTTONUP:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
826 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
827 msframe->last_click_time = GetMessageTime();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
828
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
829 KillTimer (hwnd, BUTTON_2_TIMER_ID);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
830 msframe->button2_need_rbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
831 if (msframe->ignore_next_rbutton_up)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
832 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
833 msframe->ignore_next_rbutton_up = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
834 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
835 else if (msframe->button2_is_down)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
836 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
837 msframe->button2_is_down = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
838 msframe->ignore_next_lbutton_up = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
839 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONUP,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
840 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
841 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
842 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
843 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
844 if (msframe->button2_need_lbutton)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
845 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
846 msframe->button2_need_lbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
847 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
848 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
849 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
850 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONUP,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
851 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
852 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
853 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
854
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
855 case WM_LBUTTONDOWN:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
856 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
857
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
858 if (msframe->button2_need_lbutton)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
859 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
860 KillTimer (hwnd, BUTTON_2_TIMER_ID);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
861 msframe->button2_need_lbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
862 msframe->button2_need_rbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
863 if (mswindows_button2_near_enough (msframe->last_click_point, MAKEPOINTS (lParam)))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
864 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
865 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
866 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
867 msframe->button2_is_down = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
868 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
869 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
870 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
871 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
872 msframe->last_click_point, msframe->last_click_time);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
873 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
874 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
875 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
876 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
877 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
878 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
879 mswindows_set_chord_timer (hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
880 msframe->button2_need_rbutton = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
881 msframe->last_click_point = MAKEPOINTS (lParam);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
882 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
883 msframe->last_click_time = GetMessageTime();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
884 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
885
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
886 case WM_RBUTTONDOWN:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
887 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
888
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
889 if (msframe->button2_need_rbutton)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
890 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
891 KillTimer (hwnd, BUTTON_2_TIMER_ID);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
892 msframe->button2_need_lbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
893 msframe->button2_need_rbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
894 if (mswindows_button2_near_enough (msframe->last_click_point, MAKEPOINTS (lParam)))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
895 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
896 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
897 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
898 msframe->button2_is_down = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
899 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
900 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
901 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
902 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
903 msframe->last_click_point, msframe->last_click_time);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
904 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
905 MAKEPOINTS (lParam), GetMessageTime());
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
906 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
907 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
908 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
909 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
910 mswindows_set_chord_timer (hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
911 msframe->button2_need_lbutton = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
912 msframe->last_click_point = MAKEPOINTS (lParam);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
913 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
914 msframe->last_click_time = GetMessageTime();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
915 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
916
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
917 case WM_TIMER:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
918 if (wParam == BUTTON_2_TIMER_ID)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
919 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
920 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
921 KillTimer (hwnd, BUTTON_2_TIMER_ID);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
922
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
923 if (msframe->button2_need_lbutton)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
924 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
925 msframe->button2_need_lbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
926 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
927 msframe->last_click_point, msframe->last_click_time);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
928 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
929 else if (msframe->button2_need_rbutton)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
930 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
931 msframe->button2_need_rbutton = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
932 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
933 msframe->last_click_point, msframe->last_click_time);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
934 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
935 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
936 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
937 assert ("Spurious timer fired" == 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
938 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
939
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
940 case WM_MOUSEMOVE:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
941 /* Optimization: don't report mouse movement while size is changind */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
942 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
943 if (!msframe->sizing)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
944 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
945 /* When waiting for the second mouse button to finish
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
946 button2 emulation, and have moved too far, just pretend
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
947 as if timer has expired. This impoves drag-select feedback */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
948 if ((msframe->button2_need_lbutton || msframe->button2_need_rbutton)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
949 && !mswindows_button2_near_enough (msframe->last_click_point,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
950 MAKEPOINTS (lParam)))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
951 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
952 KillTimer (hwnd, BUTTON_2_TIMER_ID);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
953 SendMessage (hwnd, WM_TIMER, BUTTON_2_TIMER_ID, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
954 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
955
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
956 emacs_event = Fmake_event (Qnil, Qnil);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
957 event = XEVENT(emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
958
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
959 event->channel = mswindows_find_frame(hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
960 event->timestamp = GetMessageTime();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
961 event->event_type = pointer_motion_event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
962 event->event.motion.x = MAKEPOINTS(lParam).x;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
963 event->event.motion.y = MAKEPOINTS(lParam).y;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
964 event->event.motion.modifiers = mswindows_modifier_state (NULL, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
965
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
966 mswindows_enqueue_dispatch_event (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
967 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
968 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
969
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
970 case WM_PAINT:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
971 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
972 PAINTSTRUCT paintStruct;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
973
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
974 frame = XFRAME (mswindows_find_frame (hwnd));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
975
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
976 BeginPaint (hwnd, &paintStruct);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
977 mswindows_redraw_exposed_area (frame,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
978 paintStruct.rcPaint.left, paintStruct.rcPaint.top,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
979 paintStruct.rcPaint.right, paintStruct.rcPaint.bottom);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
980 EndPaint (hwnd, &paintStruct);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
981 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
982 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
983
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
984 case WM_SIZE:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
985 /* We only care about this message if our size has really changed */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
986 if (wParam==SIZE_RESTORED || wParam==SIZE_MAXIMIZED || wParam==SIZE_MINIMIZED)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
987 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
988 RECT rect;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
989 int columns, rows;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
990
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
991 fobj = mswindows_find_frame (hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
992 frame = XFRAME (fobj);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
993 msframe = FRAME_MSWINDOWS_DATA (frame);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
994
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
995 /* We cannot handle frame map and unmap hooks right in
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
996 this routine, because these may throw. We queue
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
997 magic events to run these hooks instead - kkm */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
998
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
999 if (wParam==SIZE_MINIMIZED)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1000 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1001 /* Iconified */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1002 FRAME_VISIBLE_P (frame) = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1003 mswindows_enqueue_magic_event (hwnd, XM_UNMAPFRAME);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1004 Fframe_iconified_p (fobj);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1005 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1006 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1007 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1008 int was_visible = FRAME_VISIBLE_P (frame);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1009 if (!msframe->sizing && !was_visible)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1010 mswindows_enqueue_magic_event (hwnd, XM_MAPFRAME);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1011
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1012 GetClientRect(hwnd, &rect);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1013 FRAME_VISIBLE_P(frame) = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1014 FRAME_PIXWIDTH(frame) = rect.right;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1015 FRAME_PIXHEIGHT(frame) = rect.bottom;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1016 pixel_to_char_size (frame, rect.right, rect.bottom, &columns, &rows);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1017 change_frame_size (frame, rows, columns, 1);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1018
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1019 if (msframe->sizing && mswindows_dynamic_frame_resize)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1020 redisplay ();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1021 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1022 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1023 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1024
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1025 /* Misc magic events which only require that the frame be identified */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1026 case WM_SETFOCUS:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1027 case WM_KILLFOCUS:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1028 mswindows_enqueue_magic_event (hwnd, message);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1029 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1030
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1031 case WM_WINDOWPOSCHANGING:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1032 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1033 WINDOWPOS *wp = (LPWINDOWPOS) lParam;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1034 WINDOWPLACEMENT wpl = { sizeof(WINDOWPLACEMENT) };
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1035 GetWindowPlacement(hwnd, &wpl);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1036
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1037 /* Only interested if size is changing and we're not being iconified */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1038 if ((wpl.showCmd != SW_SHOWMINIMIZED) && !(wp->flags & SWP_NOSIZE))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1039 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1040 RECT ncsize = { 0, 0, 0, 0 };
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1041 int pixwidth, pixheight;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1042 AdjustWindowRectEx (&ncsize, GetWindowLong (hwnd, GWL_STYLE),
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1043 GetMenu(hwnd) != NULL,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1044 GetWindowLong (hwnd, GWL_EXSTYLE));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1045
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1046 round_size_to_char (XFRAME (mswindows_find_frame (hwnd)),
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1047 wp->cx - (ncsize.right - ncsize.left),
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1048 wp->cy - (ncsize.bottom - ncsize.top),
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1049 &pixwidth, &pixheight);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1050
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1051 /* Convert client sizes to window sizes */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1052 pixwidth += (ncsize.right - ncsize.left);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1053 pixheight += (ncsize.bottom - ncsize.top);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1054
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1055 if (wpl.showCmd != SW_SHOWMAXIMIZED)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1056 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1057 /* Adjust so that the bottom or right doesn't move if it's
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1058 * the top or left that's being changed */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1059 RECT rect;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1060 GetWindowRect (hwnd, &rect);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1061
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1062 if (rect.left != wp->x)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1063 wp->x += wp->cx - pixwidth;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1064 if (rect.top != wp->y)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1065 wp->y += wp->cy - pixheight;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1066 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1067
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1068 wp->cx = pixwidth;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1069 wp->cy = pixheight;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1070 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1071 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1072 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1073
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1074 case WM_ENTERSIZEMOVE:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1075 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1076 msframe->sizing = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1077 return 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1078
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1079 case WM_EXITSIZEMOVE:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1080 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1081 msframe->sizing = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1082 /* Queue noop event */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1083 mswindows_enqueue_magic_event (hwnd, XM_BUMPQUEUE);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1084 return 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1085
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1086 #ifdef HAVE_SCROLLBARS
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1087 case WM_VSCROLL:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1088 case WM_HSCROLL:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1089 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1090 /* Direction of scroll is determined by scrollbar instance. */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1091 int code = (int) LOWORD(wParam);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1092 int pos = (short int) HIWORD(wParam);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1093 HWND hwndScrollBar = (HWND) lParam;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1094 struct gcpro gcpro1, gcpro2;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1095
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1096 mswindows_handle_scrollbar_event (hwndScrollBar, code, pos);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1097 GCPRO2 (emacs_event, fobj);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1098 if (UNBOUNDP(mswindows_pump_outstanding_events())) /* Can GC */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1099 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1100 /* Error during event pumping - cancel scroll */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1101 SendMessage (hwndScrollBar, WM_CANCELMODE, 0, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1102 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1103 UNGCPRO;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1104 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1105 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1106 #endif
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1107
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1108 #ifdef HAVE_MENUBARS
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1109 case WM_INITMENU:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1110 if (UNBOUNDP (mswindows_handle_wm_initmenu (
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1111 (HMENU) wParam,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1112 XFRAME (mswindows_find_frame (hwnd)))))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1113 SendMessage (hwnd, WM_CANCELMODE, 0, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1114 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1115
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1116 case WM_INITMENUPOPUP:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1117 if (!HIWORD(lParam))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1118 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1119 if (UNBOUNDP (mswindows_handle_wm_initmenupopup (
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1120 (HMENU) wParam,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1121 XFRAME (mswindows_find_frame (hwnd)))))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1122 SendMessage (hwnd, WM_CANCELMODE, 0, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1123 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1124 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1125
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1126 case WM_EXITMENULOOP:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1127 if (UNBOUNDP (mswindows_handle_wm_exitmenuloop (
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1128 XFRAME (mswindows_find_frame (hwnd)))))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1129 SendMessage (hwnd, WM_CANCELMODE, 0, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1130 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1131
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1132 #endif /* HAVE_MENUBARS */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1133
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1134 case WM_COMMAND:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1135 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1136 WORD id = LOWORD (wParam);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1137 frame = XFRAME (mswindows_find_frame (hwnd));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1138
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1139 #ifdef HAVE_MENUBARS
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1140 if (!NILP (mswindows_handle_wm_command (frame, id)))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1141 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1142 #endif
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1143
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1144 #ifdef HAVE_TOOLBARS
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1145 O Toolbar Implementor, this place may have something for you!;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1146 #endif
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1147
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1148 /* Bite me - a spurious command. No abort(), for safety */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1149 /* #### Perhaps, this message should be changed */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1150 error ("Cannot decode command. Tell kkm he's a parallelogramm, if you know"
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1151 " what does that mean!");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1152 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1153 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1154
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1155 case WM_DROPFILES: /* implementation ripped-off from event-Xt.c */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1156 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1157 UINT filecount, i, len;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1158 POINT point;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1159 char filename[MAX_PATH];
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
1160 #ifdef __CYGWIN32__
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
1161 char* fname;
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
1162 #endif
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1163 Lisp_Object l_type, l_dndlist = Qnil, l_item;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1164
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1165 emacs_event = Fmake_event (Qnil, Qnil);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1166 event = XEVENT(emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1167
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1168 if (!DragQueryPoint ((HANDLE) wParam, &point))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1169 point.x = point.y = -1; /* outside client area */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1170
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1171 filecount = DragQueryFile ((HANDLE) wParam, -1, NULL, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1172 if (filecount == 1)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1173 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1174 l_type = make_int (DndFile);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1175 len = DragQueryFile ((HANDLE) wParam, 0, filename, MAX_PATH);
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
1176 #ifdef __CYGWIN32__
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
1177 CYGWIN_CONV_PATH(filename, fname);
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
1178 len=strlen(fname);
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
1179 l_dndlist = make_ext_string (fname, len, FORMAT_FILENAME);
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
1180 #else
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1181 l_dndlist = make_ext_string (filename, len, FORMAT_FILENAME);
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
1182 #endif
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1183 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1184 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1185 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1186 l_type = make_int (DndFiles);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1187 for (i=0; i<filecount; i++)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1188 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1189 len = DragQueryFile ((HANDLE) wParam, i, filename, MAX_PATH);
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
1190 #ifdef __CYGWIN32__
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
1191 CYGWIN_CONV_PATH(filename, fname);
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
1192 len=strlen(fname);
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
1193 l_item = make_ext_string (fname, len, FORMAT_FILENAME);
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
1194 #else
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1195 l_item = make_ext_string (filename, len, FORMAT_FILENAME);
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
1196 #endif
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1197 l_dndlist = Fcons (l_item, l_dndlist); /* reverse order */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1198 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1199 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1200 DragFinish ((HANDLE) wParam);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1201
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1202 event->channel = mswindows_find_frame(hwnd);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1203 event->timestamp = GetMessageTime();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1204 event->event_type = dnd_drop_event;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1205 event->event.dnd_drop.button = 1; /* #### Should try harder */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1206 event->event.dnd_drop.modifiers = mswindows_modifier_state (NULL, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1207 event->event.dnd_drop.x = point.x;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1208 event->event.dnd_drop.y = point.y;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1209 event->event.dnd_drop.data = Fcons (l_type, Fcons (l_dndlist, Qnil));
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1210
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1211 mswindows_enqueue_dispatch_event (emacs_event);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1212 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1213 break;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1214
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1215 defproc:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1216 default:
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1217 return DefWindowProc (hwnd, message, wParam, lParam);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1218 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1219 return (0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1220 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1221
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1222
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1223 /************************************************************************/
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1224 /* keyboard, mouse & other helpers for the windows procedure */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1225 /************************************************************************/
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1226 static void
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1227 mswindows_set_chord_timer (HWND hwnd)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1228 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1229 int interval;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1230
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1231 /* We get half system threshold as it seems to
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1232 long before drag-selection is shown */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1233 if (mswindows_button2_chord_time <= 0)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1234 interval = GetDoubleClickTime () / 2;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1235 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1236 interval = mswindows_button2_chord_time;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1237
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1238 SetTimer (hwnd, BUTTON_2_TIMER_ID, interval, 0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1239 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1240
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1241 static int
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1242 mswindows_button2_near_enough (POINTS p1, POINTS p2)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1243 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1244 int dx, dy;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1245 if (mswindows_button2_max_skew_x <= 0)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1246 dx = GetSystemMetrics (SM_CXDOUBLECLK) / 2;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1247 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1248 dx = mswindows_button2_max_skew_x;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1250 if (mswindows_button2_max_skew_y <= 0)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1251 dy = GetSystemMetrics (SM_CYDOUBLECLK) / 2;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1252 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1253 dy = mswindows_button2_max_skew_y;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1254
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1255 return abs (p1.x - p2.x) < dx && abs (p1.y- p2.y)< dy;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1256 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1257
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1258 static int
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1259 mswindows_current_layout_has_AltGr (void)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1260 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1261 /* This simple caching mechanism saves 10% of CPU
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1262 time when a key typed at autorepeat rate of 30 cps! */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1263 static HKL last_hkl = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1264 static int last_hkl_has_AltGr;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1265
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1266 HKL current_hkl = GetKeyboardLayout (0);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1267 if (current_hkl != last_hkl)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1268 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1269 TCHAR c;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1270 last_hkl_has_AltGr = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1271 /* In this loop, we query whether a character requires
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1272 AltGr to be down to generate it. If at least such one
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1273 found, this means that the layout does regard AltGr */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1274 for (c = ' '; c <= 0xFFU && c != 0 && !last_hkl_has_AltGr; ++c)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1275 if (HIBYTE (VkKeyScan (c)) == 6)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1276 last_hkl_has_AltGr = 1;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1277 last_hkl = current_hkl;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1278 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1279 return last_hkl_has_AltGr;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1280 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1281
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1282
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1283 /* Returns the state of the modifier keys in the format expected by the
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1284 * Lisp_Event key_data, button_data and motion_data modifiers member */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1285 int mswindows_modifier_state (BYTE* keymap, int has_AltGr)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1286 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1287 int mods = 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1288
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1289 if (keymap == NULL)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1290 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1291 keymap = (BYTE*) alloca(256);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1292 GetKeyboardState (keymap);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1293 has_AltGr = mswindows_current_layout_has_AltGr ();
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1294 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1295
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1296 if (has_AltGr && (keymap [VK_LCONTROL] & 0x80) && (keymap [VK_RMENU] & 0x80))
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1297 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1298 mods |= (keymap [VK_LMENU] & 0x80) ? MOD_META : 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1299 mods |= (keymap [VK_RCONTROL] & 0x80) ? MOD_CONTROL : 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1300 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1301 else
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1302 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1303 mods |= (keymap [VK_MENU] & 0x80) ? MOD_META : 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1304 mods |= (keymap [VK_CONTROL] & 0x80) ? MOD_CONTROL : 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1305 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1306
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1307 mods |= (keymap [VK_SHIFT] & 0x80) ? MOD_SHIFT : 0;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1308
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1309 return mods;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1310 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1311
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1312 /*
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1313 * Translate a mswindows virtual key to a keysym.
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1314 * Only returns non-Qnil for keys that don't generate WM_CHAR messages
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1315 * or whose ASCII codes (like space) xemacs doesn't like.
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1316 * Virtual key values are defined in winresrc.h
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1317 * XXX I'm not sure that KEYSYM("name") is the best thing to use here.
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1318 */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1319 Lisp_Object mswindows_key_to_emacs_keysym(int mswindows_key, int mods)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1320 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1321 switch (mswindows_key)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1322 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1323 /* First the predefined ones */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1324 case VK_BACK: return QKbackspace;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1325 case VK_TAB: return QKtab;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1326 case '\n': return QKlinefeed; /* No VK_LINEFEED in winresrc.h */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1327 case VK_RETURN: return QKreturn;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1328 case VK_ESCAPE: return QKescape;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1329 case VK_SPACE: return QKspace;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1330 case VK_DELETE: return QKdelete;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1331
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1332 /* The rest */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1333 case VK_CLEAR: return KEYSYM ("clear"); /* Should do ^L ? */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1334 case VK_PRIOR: return KEYSYM ("prior");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1335 case VK_NEXT: return KEYSYM ("next");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1336 case VK_END: return KEYSYM ("end");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1337 case VK_HOME: return KEYSYM ("home");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1338 case VK_LEFT: return KEYSYM ("left");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1339 case VK_UP: return KEYSYM ("up");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1340 case VK_RIGHT: return KEYSYM ("right");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1341 case VK_DOWN: return KEYSYM ("down");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1342 case VK_SELECT: return KEYSYM ("select");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1343 case VK_PRINT: return KEYSYM ("print");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1344 case VK_EXECUTE: return KEYSYM ("execute");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1345 case VK_SNAPSHOT: return KEYSYM ("print");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1346 case VK_INSERT: return KEYSYM ("insert");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1347 case VK_HELP: return KEYSYM ("help");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1348 #if 0 /* XXX What are these supposed to do? */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1349 case VK_LWIN return KEYSYM ("");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1350 case VK_RWIN return KEYSYM ("");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1351 #endif
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1352 case VK_APPS: return KEYSYM ("menu");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1353 case VK_F1: return KEYSYM ("f1");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1354 case VK_F2: return KEYSYM ("f2");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1355 case VK_F3: return KEYSYM ("f3");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1356 case VK_F4: return KEYSYM ("f4");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1357 case VK_F5: return KEYSYM ("f5");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1358 case VK_F6: return KEYSYM ("f6");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1359 case VK_F7: return KEYSYM ("f7");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1360 case VK_F8: return KEYSYM ("f8");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1361 case VK_F9: return KEYSYM ("f9");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1362 case VK_F10: return KEYSYM ("f10");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1363 case VK_F11: return KEYSYM ("f11");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1364 case VK_F12: return KEYSYM ("f12");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1365 case VK_F13: return KEYSYM ("f13");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1366 case VK_F14: return KEYSYM ("f14");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1367 case VK_F15: return KEYSYM ("f15");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1368 case VK_F16: return KEYSYM ("f16");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1369 case VK_F17: return KEYSYM ("f17");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1370 case VK_F18: return KEYSYM ("f18");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1371 case VK_F19: return KEYSYM ("f19");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1372 case VK_F20: return KEYSYM ("f20");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1373 case VK_F21: return KEYSYM ("f21");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1374 case VK_F22: return KEYSYM ("f22");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1375 case VK_F23: return KEYSYM ("f23");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1376 case VK_F24: return KEYSYM ("f24");
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1377 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1378 return Qnil;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1379 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1380
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1381 /*
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1382 * Find the console that matches the supplied mswindows window handle
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1383 */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1384 Lisp_Object
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1385 mswindows_find_console (HWND hwnd)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1386 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1387 Lisp_Object concons;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1388
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1389 CONSOLE_LOOP (concons)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1390 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1391 Lisp_Object console = XCAR (concons);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1392 /* We only support one console so this must be it */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1393 return console;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1394 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1395
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1396 return Qnil;
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1397 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1398
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1399 /*
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1400 * Find the frame that matches the supplied mswindows window handle
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1401 */
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1402 static Lisp_Object
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1403 mswindows_find_frame (HWND hwnd)
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1404 {
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1405 return (Lisp_Object) GetWindowLong (hwnd, XWL_FRAMEOBJ);
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1406 }
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1407
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1408
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1409
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1410 /************************************************************************/
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1411 /* methods */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1412 /************************************************************************/
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1413
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1414 static int
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1415 emacs_mswindows_add_timeout (EMACS_TIME thyme)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1416 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1417 int milliseconds;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1418 EMACS_TIME current_time;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1419 EMACS_GET_TIME (current_time);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1420 EMACS_SUB_TIME (thyme, thyme, current_time);
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1421 milliseconds = EMACS_SECS (thyme) * 1000 +
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1422 (EMACS_USECS (thyme) + 500) / 1000;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1423 if (milliseconds < 1)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1424 milliseconds = 1;
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
1425 ++mswindows_pending_timers_count;
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1426 return SetTimer (NULL, 0, milliseconds,
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1427 (TIMERPROC) mswindows_wm_timer_callback);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1428 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1429
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1430 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1431 emacs_mswindows_remove_timeout (int id)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1432 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1433 struct Lisp_Event match_against;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1434 Lisp_Object emacs_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1435
233
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
1436 if (KillTimer (NULL, id))
52952cbfc5b5 Import from CVS: tag r20-5b15
cvs
parents: 231
diff changeset
1437 --mswindows_pending_timers_count;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1438
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1439 /* If there is a dispatch event generated by this
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1440 timeout in the queue, we have to remove it too. */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1441 match_against.event_type = timeout_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1442 match_against.event.timeout.interval_id = id;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1443 emacs_event = mswindows_cancel_dispatch_event (&match_against);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1444 if (!NILP (emacs_event))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1445 Fdeallocate_event(emacs_event);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1446 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1447
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1448 /* If `user_p' is false, then return whether there are any win32, timeout,
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1449 * or subprocess events pending (that is, whether
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1450 * emacs_mswindows_next_event() would return immediately without blocking).
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1451 *
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1452 * if `user_p' is true, then return whether there are any *user generated*
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1453 * events available (that is, whether there are keyboard or mouse-click
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1454 * events ready to be read). This also implies that
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1455 * emacs_mswindows_next_event() would not block.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1456 */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1457 static int
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1458 emacs_mswindows_event_pending_p (int user_p)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1459 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1460 mswindows_need_event (user_p, 0);
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 213
diff changeset
1461
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1462 return (!NILP (mswindows_u_dispatch_event_queue)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1463 || (!user_p && !NILP (mswindows_s_dispatch_event_queue)));
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1464 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1465
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1466 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1467 * Return the next event
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1468 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1469 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1470 emacs_mswindows_next_event (struct Lisp_Event *emacs_event)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1471 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1472 Lisp_Object event, event2;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1473
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1474 /* Give strong preference to user events */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1475 mswindows_need_event (1, 1);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1476
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1477 /* XXX Copied from event-Xt.c */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1478 event = mswindows_dequeue_dispatch_event (!NILP(mswindows_u_dispatch_event_queue));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1479 XSETEVENT (event2, emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1480 Fcopy_event (event, event2);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1481 Fdeallocate_event (event);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1482 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1483
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1484 /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1485 * Handle a magic event off the dispatch queue.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1486 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1487 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1488 emacs_mswindows_handle_magic_event (struct Lisp_Event *emacs_event)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1489 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1490 switch (EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1491 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1492 case WM_SETFOCUS:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1493 case WM_KILLFOCUS:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1494 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1495 Lisp_Object frame = EVENT_CHANNEL (emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1496 struct frame *f = XFRAME (frame);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1497 int in_p = (EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event) == WM_SETFOCUS);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1498 Lisp_Object conser;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1499
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1500 /* struct gcpro gcpro1; */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1501
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1502 /* Clear sticky modifiers here (if we had any) */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1503
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1504 conser = Fcons (frame, Fcons (FRAME_DEVICE (f), in_p ? Qt : Qnil));
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1505 /* GCPRO1 (conser); XXX Not necessary? */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1506 emacs_handle_focus_change_preliminary (conser);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1507 /* Under X the stuff up to here is done in the X event handler.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1508 I Don't know why */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1509 emacs_handle_focus_change_final (conser);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1510 /* UNGCPRO; */
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1511
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1512 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1513 break;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1514
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1515 case XM_BUMPQUEUE:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1516 /* This is a nice event, when we're in need to queue *something* */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1517 break;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1518
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1519 case XM_MAPFRAME:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1520 case XM_UNMAPFRAME:
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1521 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1522 Lisp_Object frame = EVENT_CHANNEL (emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1523 va_run_hook_with_args (EVENT_MSWINDOWS_MAGIC_TYPE(emacs_event)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1524 == XM_MAPFRAME ?
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1525 Qmap_frame_hook : Qunmap_frame_hook,
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1526 1, frame);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1527 }
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1528 break;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1529
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 245
diff changeset
1530 /* #### What about Enter & Leave */
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1531 #if 0
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1532 va_run_hook_with_args (in_p ? Qmouse_enter_frame_hook :
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1533 Qmouse_leave_frame_hook, 1, frame);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1534 #endif
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1535
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1536 default:
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1537 assert(0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1538 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1539 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1540
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1541 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1542 emacs_mswindows_select_process (struct Lisp_Process *process)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1543 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1544 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1545
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1546 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1547 emacs_mswindows_unselect_process (struct Lisp_Process *process)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1548 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1549 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1550
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1551 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1552 emacs_mswindows_select_console (struct console *con)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1553 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1554 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1555
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1556 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1557 emacs_mswindows_unselect_console (struct console *con)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1558 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1559 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1560
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1561 static void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1562 emacs_mswindows_quit_p (void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1563 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1564 mswindows_need_event (1, 0);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1565
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1566 if (mswindows_quit_chars_count > 0)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1567 {
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1568 /* Yes there's a hidden one... Throw it away */
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1569 struct Lisp_Event match_against;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1570 Lisp_Object emacs_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1571
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1572 match_against.event_type = key_press_event;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1573 match_against.event.key.modifiers = FAKE_MOD_QUIT;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1574
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1575 emacs_event = mswindows_cancel_dispatch_event (&match_against);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1576 assert (!NILP (emacs_event));
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1577
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1578 Vquit_flag = (XEVENT(emacs_event)->event.key.modifiers & MOD_SHIFT
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1579 ? Qcritical : Qt);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1580
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1581 Fdeallocate_event(emacs_event);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1582 --mswindows_quit_chars_count;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1583 }
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1584 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1585
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1586 /* This is called from GC when a process object is about to be freed.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1587 If we've still got pointers to it in this file, we're gonna lose hard.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1588 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1589 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1590 debug_process_finalization (struct Lisp_Process *p)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1591 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1592 #if 0 /* #### */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1593 int i;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1594 int infd, outfd;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1595 get_process_file_descriptors (p, &infd, &outfd);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1596 /* if it still has fds, then it hasn't been killed yet. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1597 assert (infd < 0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1598 assert (outfd < 0);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1599 /* Better not still be in the "with input" table; we know it's got no fds. */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1600 for (i = 0; i < MAXDESC; i++)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1601 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1602 Lisp_Object process = filedesc_fds_with_input [i];
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1603 assert (!PROCESSP (process) || XPROCESS (process) != p);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1604 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1605 #endif
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1606 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1607
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1608 /************************************************************************/
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1609 /* initialization */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1610 /************************************************************************/
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1611
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1612 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1613 vars_of_event_mswindows (void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1614 {
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1615 mswindows_u_dispatch_event_queue = Qnil;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1616 staticpro (&mswindows_u_dispatch_event_queue);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1617 mswindows_u_dispatch_event_queue_tail = Qnil;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1618
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1619 mswindows_s_dispatch_event_queue = Qnil;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1620 staticpro (&mswindows_s_dispatch_event_queue);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1621 mswindows_s_dispatch_event_queue_tail = Qnil;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1622
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
1623 mswindows_error_caught_in_modal_loop = Qnil;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
1624 staticpro (&mswindows_error_caught_in_modal_loop);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 227
diff changeset
1625 mswindows_in_modal_loop = 0;
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
1626 mswindows_pending_timers_count = 0;
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 225
diff changeset
1627
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1628 mswindows_event_stream = xnew (struct event_stream);
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1629
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1630 mswindows_event_stream->event_pending_p = emacs_mswindows_event_pending_p;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1631 mswindows_event_stream->next_event_cb = emacs_mswindows_next_event;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1632 mswindows_event_stream->handle_magic_event_cb = emacs_mswindows_handle_magic_event;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1633 mswindows_event_stream->add_timeout_cb = emacs_mswindows_add_timeout;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1634 mswindows_event_stream->remove_timeout_cb = emacs_mswindows_remove_timeout;
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1635 mswindows_event_stream->select_console_cb = emacs_mswindows_select_console;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1636 mswindows_event_stream->unselect_console_cb = emacs_mswindows_unselect_console;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1637 mswindows_event_stream->select_process_cb = emacs_mswindows_select_process;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1638 mswindows_event_stream->unselect_process_cb = emacs_mswindows_unselect_process;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1639 mswindows_event_stream->quit_p_cb = emacs_mswindows_quit_p;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1640
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1641 DEFVAR_BOOL ("mswindows-dynamic-frame-resize", &mswindows_dynamic_frame_resize /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1642 *Controls redrawing frame contents during mouse-drag or keyboard resize
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1643 operation. When non-nil, the frame is redrawn while being resized. When
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1644 nil, frame is not redrawn, and exposed areas are filled with default
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1645 MDI application background color. Note that this option only has effect
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1646 if "Show window contents while dragging" is on in system Display/Plus!
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1647 settings.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1648 Default is t on fast machines, nil on slow.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1649 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1650
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1651 /* The description copied verbatim from nt-emacs. (C) Geoff Voelker */
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1652 DEFVAR_INT ("mswindows-mouse-button-tolerance", &mswindows_button2_chord_time /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1653 *Analogue of double click interval for faking middle mouse events.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1654 The value is the minimum time in milliseconds that must elapse between
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1655 left/right button down events before they are considered distinct events.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1656 If both mouse buttons are depressed within this interval, a middle mouse
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1657 button down event is generated instead.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1658 If negative or zero, currently set system default is used instead.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1659 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1660
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1661 /* The description copied verbatim from nt-emacs. (C) Geoff Voelker */
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1662 DEFVAR_INT ("mswindows-num-mouse-buttons", &mswindows_num_mouse_buttons /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1663 Number of physical mouse buttons.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1664 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1665
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1666 DEFVAR_INT ("mswindows-mouse-button-max-skew-x", &mswindows_button2_max_skew_x /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1667 *Maximum horizontal distance in pixels between points in which left and
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1668 right button clicks occured for them to be translated into single
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1669 middle button event. Clicks must occur in time not longer than defined
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1670 by the variable mswindows-mouse-button-tolerance.
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1671 If negative or zero, currently set system default is used instead.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1672 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1673
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1674 DEFVAR_INT ("mswindows-mouse-button-max-skew-y", &mswindows_button2_max_skew_y /*
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1675 *Maximum vertical distance in pixels between points in which left and
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1676 right button clicks occured for them to be translated into single
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1677 middle button event. Clicks must occur in time not longer than defined
225
12579d965149 Import from CVS: tag r20-4b11
cvs
parents: 223
diff changeset
1678 by the variable mswindows-mouse-button-tolerance.
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1679 If negative or zero, currently set system default is used instead.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1680 */ );
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1681
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1682 mswindows_button2_max_skew_x = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1683 mswindows_button2_max_skew_y = 0;
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1684 mswindows_button2_chord_time = 0;
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1685 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1686
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1687 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1688 syms_of_event_mswindows (void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1689 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1690 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1691
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1692 void
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1693 init_event_mswindows_late (void)
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1694 {
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1695 event_stream = mswindows_event_stream;
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1696
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1697 mswindows_dynamic_frame_resize = !GetSystemMetrics (SM_SLOWMACHINE);
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 219
diff changeset
1698 mswindows_num_mouse_buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents:
diff changeset
1699 }