annotate src/event-msw.c @ 3767:6b2ef948e140

[xemacs-hg @ 2006-12-29 18:09:38 by aidan] etc/ChangeLog addition: 2006-12-21 Aidan Kehoe <kehoea@parhasard.net> * unicode/unicode-consortium/8859-7.TXT: Update the mapping to the 2003 version of ISO 8859-7. lisp/ChangeLog addition: 2006-12-21 Aidan Kehoe <kehoea@parhasard.net> * mule/cyrillic.el: * mule/cyrillic.el (iso-8859-5): * mule/cyrillic.el (cyrillic-koi8-r-encode-table): Add syntax, case support for Cyrillic; make some parentheses more Lispy. * mule/european.el: Content moved to latin.el, file deleted. * mule/general-late.el: If Unicode tables are to be loaded at dump time, do it here, not in loadup.el. * mule/greek.el: Add syntax, case support for Greek. * mule/latin.el: Move the content of european.el here. Change the case table mappings to use hexadecimal codes, to make cross reference to the standards easier. In all cases, take character syntax from similar characters in Latin-1 , rather than deciding separately what syntax they should take. Add (incomplete) support for case with Turkish. Remove description of the character sets used from the language environments' doc strings, since now that we create variant language environments on the fly, such descriptions will often be inaccurate. Set the native-coding-system language info property while setting the other coding-system properties of the language. * mule/misc-lang.el (ipa): Remove the language environment. The International Phonetic _Alphabet_ is not a language, it's inane to have a corresponding language environment in XEmacs. * mule/mule-cmds.el (create-variant-language-environment): Also modify the coding-priority when creating a new language environment; document that. * mule/mule-cmds.el (get-language-environment-from-locale): Recognise that the 'native-coding-system language-info property can be a list, interpret it correctly when it is one. 2006-12-21 Aidan Kehoe <kehoea@parhasard.net> * coding.el (coding-system-category): Use the new 'unicode-type property for finding what sort of Unicode coding system subtype a coding system is, instead of the overshadowed 'type property. * dumped-lisp.el (preloaded-file-list): mule/european.el has been removed. * loadup.el (really-early-error-handler): Unicode tables loaded at dump time are now in mule/general-late.el. * simple.el (count-lines): Add some backslashes to to parentheses in docstrings to help fontification along. * simple.el (what-cursor-position): Wrap a line to fit in 80 characters. * unicode.el: Use the 'unicode-type property, not 'type, for setting the Unicode coding-system subtype. src/ChangeLog addition: 2006-12-21 Aidan Kehoe <kehoea@parhasard.net> * file-coding.c: Update the make-coding-system docstring to reflect unicode-type * general-slots.h: New symbol, unicode-type, since 'type was being overridden when accessing a coding system's Unicode subtype. * intl-win32.c: Backslash a few parentheses, to help fontification along. * intl-win32.c (complex_vars_of_intl_win32): Use the 'unicode-type symbol, not 'type, when creating the Microsoft Unicode coding system. * unicode.c (unicode_putprop): * unicode.c (unicode_getprop): * unicode.c (unicode_print): Using 'type as the property name when working out what Unicode subtype a given coding system is was broken, since there's a general coding system property called 'type. Change the former to use 'unicode-type instead.
author aidan
date Fri, 29 Dec 2006 18:09:51 +0000
parents d674024a8674
children 8f1ee2d15784
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1 /* The mswindows event_stream interface.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1995 Sun Microsystems, Inc.
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2828
diff changeset
4 Copyright (C) 1996, 2000, 2001, 2002, 2003, 2005 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 Copyright (C) 1997 Jonathan Harris.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
26 /* This file essentially Mule-ized (except perhaps some Unicode splitting).
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
27 5-2000. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
28
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 /* Authorship:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 Ultimately based on FSF.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 Rewritten by Ben Wing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 Subprocess and modal loop support by Kirill M. Katsnelson.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
37 #define NEED_MSWINDOWS_SHLOBJ /* for IShellLink */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
38
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
42 #ifdef CYGWIN
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
43 # define USED_IF_CYGWIN(decl) decl
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
44 # define UNUSED_IF_CYGWIN(decl) UNUSED (decl)
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
45 #else
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
46 # define USED_IF_CYGWIN(decl) UNUSED (decl)
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
47 # define UNUSED_IF_CYGWIN(decl) decl
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
48 #endif
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
49
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
50 #if defined (CYGWIN) && !defined (HAVE_MSG_SELECT)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
51 #error We do not support non-select() versions (i.e. very old) of Cygwin.
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
52 #endif
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
53
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
54 /* Acceptable are:
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
55
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
56 WIN32_NATIVE and HAVE_WIN32_PROCESSES and nothing else
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
57
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
58 CYGWIN and HAVE_MSG_SELECT and HAVE_UNIX_PROCESSES and nothing else
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
59 */
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
60 #ifdef WIN32_NATIVE
856
b27b70c1252a [xemacs-hg @ 2002-05-29 13:48:53 by ben]
ben
parents: 853
diff changeset
61 # if !(defined (HAVE_WIN32_PROCESSES) && !defined (HAVE_UNIX_PROCESSES) && !defined (HAVE_MSG_SELECT) && !defined (CYGWIN))
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
62 # error Something is wrong with your process definitions for Windows native.
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
63 # endif
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
64 #elif defined (CYGWIN)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
65 # if !(defined (HAVE_UNIX_PROCESSES) && defined (HAVE_MSG_SELECT) && !defined (HAVE_WIN32_PROCESSES) && !defined (WIN32_NATIVE))
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
66 # error Something is wrong with your process definitions for Cygwin.
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
67 # endif
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
68 #else
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
69 # error Something is wrong -- you are neither Windows native (possibly MinGW) nor Cygwin.
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
70 #endif
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
71
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
72 #include "buffer.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
73 #include "device-impl.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
74 #include "events.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
75 #include "faces.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
76 #include "frame-impl.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
77 #include "glyphs.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
78 #include "lstream.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
79 #include "process.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
80 #include "redisplay.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
81 #include "sysdep.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
82 #include "window.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
83
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
84 #include "console-stream-impl.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
85 #include "console-msw-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
86 #include "objects-msw-impl.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 #ifdef HAVE_SCROLLBARS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 # include "scrollbar-msw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 #ifdef HAVE_MENUBARS
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
93 # include "menubar.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 #ifdef HAVE_DRAGNDROP
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 # include "dragdrop.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
100 #include "sysfile.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 #include "sysproc.h"
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
102 #include "systime.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 #include "syswait.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 #ifdef HAVE_MENUBARS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 #define ADJR_MENUFLAG TRUE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 #define ADJR_MENUFLAG FALSE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 /* Timer ID used for button2 emulation */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 #define BUTTON_2_TIMER_ID 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 static Lisp_Object mswindows_find_console (HWND hwnd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 static Lisp_Object mswindows_key_to_emacs_keysym (int mswindows_key, int mods,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 int extendedp);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
117 static int mswindows_modifier_state (BYTE *keymap, DWORD fwKeys,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
118 int has_AltGr);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 static void mswindows_set_chord_timer (HWND hwnd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 static int mswindows_button2_near_enough (POINTS p1, POINTS p2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 static int mswindows_current_layout_has_AltGr (void);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
122 static int mswindows_handle_sticky_modifiers (WPARAM wParam, LPARAM lParam,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
123 int downp, int keyp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 static struct event_stream *mswindows_event_stream;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
127 #ifdef CYGWIN
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
128
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 extern SELECT_TYPE input_wait_mask, non_fake_input_wait_mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 extern SELECT_TYPE process_only_mask, tty_only_mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 SELECT_TYPE zero_mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 extern int signal_event_pipe_initialized;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 int windows_fd;
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
134
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
135 #else
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
136
856
b27b70c1252a [xemacs-hg @ 2002-05-29 13:48:53 by ben]
ben
parents: 853
diff changeset
137 /* The number of things we can wait on */
b27b70c1252a [xemacs-hg @ 2002-05-29 13:48:53 by ben]
ben
parents: 853
diff changeset
138 #define MAX_WAITABLE (MAXIMUM_WAIT_OBJECTS - 1)
b27b70c1252a [xemacs-hg @ 2002-05-29 13:48:53 by ben]
ben
parents: 853
diff changeset
139
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
140 /* List of mswindows waitable handles. */
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
141 static HANDLE mswindows_waitable_handles[MAX_WAITABLE];
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
142
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
143 /* Number of wait handles */
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
144 static int mswindows_waitable_count = 0;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
145
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 /*
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
149 * We use an additional queue, as well as the normal dispatch queue, for
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
150 * efficiency, the normal one for user events, and another (_s_) for non-user
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
151 * ones. We always return events out of the first one until it is empty and
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
152 * only then proceed with the second one.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
154 static Lisp_Object mswindows_s_dispatch_event_queue;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
155 static Lisp_Object mswindows_s_dispatch_event_queue_tail;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 /* Brush for painting widgets */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 static HBRUSH widget_brush = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 static LONG last_widget_brushed = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 /* These are Lisp integers; see DEFVARS in this file for description. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 int mswindows_dynamic_frame_resize;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
163 int mswindows_alt_by_itself_activates_menu;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
164 Fixnum mswindows_num_mouse_buttons;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
165 Fixnum mswindows_mouse_button_max_skew_x;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
166 Fixnum mswindows_mouse_button_max_skew_y;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
167 Fixnum mswindows_mouse_button_tolerance;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
169 #ifdef DEBUG_XEMACS
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
170 Fixnum debug_mswindows_events;
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
171
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
172 static void debug_output_mswin_message (HWND hwnd, UINT message_,
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
173 WPARAM wParam, LPARAM lParam);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
174 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
175
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 /* This is the event signaled by the event pump.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 See mswindows_pump_outstanding_events for comments */
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
178 static int mswindows_error_caught_in_modal_loop;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 /* Count of wound timers */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 static int mswindows_pending_timers_count;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
182
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
183 static DWORD mswindows_last_mouse_button_state;
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
184
1292
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1279
diff changeset
185 extern int mswindows_is_blocking;
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1279
diff changeset
186
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
188 #ifndef CYGWIN /* Skips past slurp, shove, or winsock streams */
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
189
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 /* Pipe instream - reads process output */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 #define PIPE_READ_DELAY 20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 #define HANDLE_TO_USID(h) ((USID)(h))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 #define NTPIPE_SLURP_STREAM_DATA(stream) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 LSTREAM_TYPE_DATA (stream, ntpipe_slurp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 /* This structure is allocated by the main thread, and is deallocated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 in the thread upon exit. There are situations when a thread
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 remains blocked for a long time, much longer than the lstream
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 exists. For example, "start notepad" command is issued from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 shell, then the shell is closed by C-c C-d. Although the shell
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 process exits, its output pipe will not get closed until the
656
4035041996d8 [xemacs-hg @ 2001-09-08 09:12:08 by adrian]
adrian
parents: 647
diff changeset
207 notepad process exits also, because it inherits the pipe from the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 shell. In this case, we abandon the thread, and let it live until
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 all such processes exit. While struct ntpipe_slurp_stream is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 deallocated in this case, ntpipe_slurp_stream_shared_data are not. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 struct ntpipe_slurp_stream_shared_data
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 HANDLE hev_thread; /* Our thread blocks on this, signaled by caller */
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
215 /* This is a manual-reset object. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 HANDLE hev_caller; /* Caller blocks on this, and we signal it */
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
217 /* This is a manual-reset object. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 HANDLE hev_unsleep; /* Pipe read delay is canceled if this is set */
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
219 /* This is a manual-reset object. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 HANDLE hpipe; /* Pipe read end handle. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 LONG die_p; /* Thread must exit ASAP if non-zero */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 BOOL eof_p : 1; /* Set when thread saw EOF */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 BOOL error_p : 1; /* Read error other than EOF/broken pipe */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 BOOL inuse_p : 1; /* this structure is in use */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 LONG lock_count; /* Client count of this struct, 0=safe to free */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 BYTE onebyte; /* One byte buffer read by thread */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 #define MAX_SLURP_STREAMS 32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 struct ntpipe_slurp_stream_shared_data
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 shared_data_block[MAX_SLURP_STREAMS]={{0}};
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 struct ntpipe_slurp_stream
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 LPARAM user_data; /* Any user data stored in the stream object */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
236 struct ntpipe_slurp_stream_shared_data *thread_data;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
239 DEFINE_LSTREAM_IMPLEMENTATION ("ntpipe-input", ntpipe_slurp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 /* This function is thread-safe, and is called from either thread
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 context. It serializes freeing shared data structure */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 static void
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
244 slurper_free_shared_data_maybe (struct ntpipe_slurp_stream_shared_data *s)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 if (InterlockedDecrement (&s->lock_count) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 /* Destroy events */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 CloseHandle (s->hev_thread);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 CloseHandle (s->hev_caller);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 CloseHandle (s->hev_unsleep);
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
252 CloseHandle (s->hpipe);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 s->inuse_p = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
257 static struct ntpipe_slurp_stream_shared_data *
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
258 slurper_allocate_shared_data (void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 int i=0;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
261 for (i = 0; i < MAX_SLURP_STREAMS; i++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 if (!shared_data_block[i].inuse_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
265 shared_data_block[i].inuse_p = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 return &shared_data_block[i];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
269 return (struct ntpipe_slurp_stream_shared_data *)0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 static DWORD WINAPI
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 slurp_thread (LPVOID vparam)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 struct ntpipe_slurp_stream_shared_data *s =
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
276 (struct ntpipe_slurp_stream_shared_data *)vparam;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 for (;;)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 /* Read one byte from the pipe */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 DWORD actually_read;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 if (!ReadFile (s->hpipe, &s->onebyte, 1, &actually_read, NULL))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 DWORD err = GetLastError ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 if (err == ERROR_BROKEN_PIPE || err == ERROR_NO_DATA)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 s->eof_p = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 s->error_p = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 else if (actually_read == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 s->eof_p = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 /* We must terminate on an error or eof */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 if (s->eof_p || s->error_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 InterlockedIncrement (&s->die_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 /* Before we notify caller, we unsignal our event. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 ResetEvent (s->hev_thread);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 /* Now we got something to notify caller, either a byte or an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 error/eof indication. Before we do, allow internal pipe
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 buffer to accumulate little bit more data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 Reader function pulses this event before waiting for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 a character, to avoid pipe delay, and to get the byte
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 immediately. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 if (!s->die_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 WaitForSingleObject (s->hev_unsleep, PIPE_READ_DELAY);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 /* Either make event loop generate a process event, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 inblock reader */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 SetEvent (s->hev_caller);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 /* Cleanup and exit if we're shot off */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 if (s->die_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 /* Block until the client finishes with retrieving the rest of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 pipe data */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 WaitForSingleObject (s->hev_thread, INFINITE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 slurper_free_shared_data_maybe (s);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 make_ntpipe_input_stream (HANDLE hpipe, LPARAM param)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 Lstream *lstr = Lstream_new (lstream_ntpipe_slurp, "r");
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
331 struct ntpipe_slurp_stream *s = NTPIPE_SLURP_STREAM_DATA (lstr);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 DWORD thread_id_unused;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 HANDLE hthread;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 /* We deal only with pipes, for we're using PeekNamedPipe api */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 assert (GetFileType (hpipe) == FILE_TYPE_PIPE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 s->thread_data = slurper_allocate_shared_data();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 /* Create reader thread. This could fail, so do not create events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 until thread is created */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 hthread = CreateThread (NULL, 0, slurp_thread, (LPVOID)s->thread_data,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 CREATE_SUSPENDED, &thread_id_unused);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 if (hthread == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 Lstream_delete (lstr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 s->thread_data->inuse_p=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 /* Shared data are initially owned by both main and slurper
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 threads. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 s->thread_data->lock_count = 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 s->thread_data->die_p = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 s->thread_data->eof_p = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 s->thread_data->error_p = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 s->thread_data->hpipe = hpipe;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 s->user_data = param;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 /* hev_thread is a manual-reset event, initially signaled */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
361 s->thread_data->hev_thread = qxeCreateEvent (NULL, TRUE, TRUE, NULL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 /* hev_caller is a manual-reset event, initially nonsignaled */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
363 s->thread_data->hev_caller = qxeCreateEvent (NULL, TRUE, FALSE, NULL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 /* hev_unsleep is a manual-reset event, initially nonsignaled */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
365 s->thread_data->hev_unsleep = qxeCreateEvent (NULL, TRUE, FALSE, NULL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 /* Now let it go */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 ResumeThread (hthread);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 CloseHandle (hthread);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 lstr->flags |= LSTREAM_FL_CLOSE_AT_DISKSAVE;
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
372 return wrap_lstream (lstr);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 static LPARAM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 get_ntpipe_input_stream_param (Lstream *stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
378 struct ntpipe_slurp_stream *s = NTPIPE_SLURP_STREAM_DATA(stream);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 return s->user_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 static HANDLE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 get_ntpipe_input_stream_waitable (Lstream *stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
385 struct ntpipe_slurp_stream *s = NTPIPE_SLURP_STREAM_DATA(stream);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 return s->thread_data->hev_caller;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
389 static Bytecount
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 458
diff changeset
390 ntpipe_slurp_reader (Lstream *stream, unsigned char *data,
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
391 Bytecount size)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 /* This function must be called from the main thread only */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
394 struct ntpipe_slurp_stream_shared_data *s =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 NTPIPE_SLURP_STREAM_DATA(stream)->thread_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 if (!s->die_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 DWORD wait_result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 /* Disallow pipe read delay for the thread: we need a character
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 ASAP */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 SetEvent (s->hev_unsleep);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 /* Check if we have a character ready. Give it a short delay,
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
405 for the thread to awake from pipe delay, just ion case */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 wait_result = WaitForSingleObject (s->hev_caller, 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 /* Revert to the normal sleep behavior. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 ResetEvent (s->hev_unsleep);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 /* If there's no byte buffered yet, give up */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 if (wait_result == WAIT_TIMEOUT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 errno = EAGAIN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 /* Reset caller unlock event now, as we've handled the pending
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 process output event */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 ResetEvent (s->hev_caller);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 /* It is now safe to do anything with contents of S, except for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 changing s->die_p, which still should be interlocked */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 if (s->eof_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 if (s->error_p || s->die_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 /* Ok, there were no error neither eof - we've got a byte from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 pipe */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 *(data++) = s->onebyte;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 --size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 DWORD bytes_read = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 if (size > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 DWORD bytes_available;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 /* If the api call fails, return at least one byte already
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 read. ReadFile in thread will return error */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 if (PeekNamedPipe (s->hpipe, NULL, 0, NULL, &bytes_available, NULL))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 /* Fetch available bytes. The same consideration applies,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 so do not check for errors. ReadFile in the thread will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 fail if the next call fails. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 if (bytes_available)
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
451 ReadFile (s->hpipe, data, min (bytes_available, (DWORD) size),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 &bytes_read, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 /* Now we can unblock thread, so it attempts to read more */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 SetEvent (s->hev_thread);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 return bytes_read + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 ntpipe_slurp_closer (Lstream *stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 /* This function must be called from the main thread only */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
467 struct ntpipe_slurp_stream_shared_data *s =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 NTPIPE_SLURP_STREAM_DATA(stream)->thread_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 /* Force thread to stop */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 InterlockedIncrement (&s->die_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 /* Set events which could possibly block slurper. Let it finish soon
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 or later. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 SetEvent (s->hev_unsleep);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 SetEvent (s->hev_thread);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 /* Unlock and maybe free shared data */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 slurper_free_shared_data_maybe (s);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 init_slurp_stream (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 LSTREAM_HAS_METHOD (ntpipe_slurp, reader);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 LSTREAM_HAS_METHOD (ntpipe_slurp, closer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 }
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
490
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 /* Pipe outstream - writes process input */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 #define NTPIPE_SHOVE_STREAM_DATA(stream) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 LSTREAM_TYPE_DATA (stream, ntpipe_shove)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
499 #define MAX_SHOVE_BUFFER_SIZE 512
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 struct ntpipe_shove_stream
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 LPARAM user_data; /* Any user data stored in the stream object */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 HANDLE hev_thread; /* Our thread blocks on this, signaled by caller */
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
505 /* This is an auto-reset object. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 HANDLE hpipe; /* Pipe write end handle. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 HANDLE hthread; /* Reader thread handle. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 char buffer[MAX_SHOVE_BUFFER_SIZE]; /* Buffer being written */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 DWORD size; /* Number of bytes to write */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 LONG die_p; /* Thread must exit ASAP if non-zero */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 LONG idle_p; /* Non-zero if thread is waiting for job */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 BOOL error_p : 1; /* Read error other than EOF/broken pipe */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 BOOL blocking_p : 1;/* Last write attempt would cause blocking */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
516 DEFINE_LSTREAM_IMPLEMENTATION ("ntpipe-output", ntpipe_shove);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 static DWORD WINAPI
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 shove_thread (LPVOID vparam)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
521 struct ntpipe_shove_stream *s = (struct ntpipe_shove_stream *) vparam;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 for (;;)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 DWORD bytes_written;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 /* Block on event and wait for a job */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 InterlockedIncrement (&s->idle_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 WaitForSingleObject (s->hev_thread, INFINITE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
531 if (s->die_p)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
532 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
533
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
534 /* Write passed buffer if any */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
535 if (s->size > 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
537 if (!WriteFile (s->hpipe, s->buffer, s->size, &bytes_written, NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
538 || bytes_written != s->size)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
539 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
540 s->error_p = TRUE;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
541 InterlockedIncrement (&s->die_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
542 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
543 /* Set size to zero so we won't write it again if the closer sets
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
544 die_p and kicks us */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
545 s->size = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 if (s->die_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 make_ntpipe_output_stream (HANDLE hpipe, LPARAM param)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 Lstream *lstr = Lstream_new (lstream_ntpipe_shove, "w");
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
559 struct ntpipe_shove_stream *s = NTPIPE_SHOVE_STREAM_DATA (lstr);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 DWORD thread_id_unused;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 s->die_p = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 s->error_p = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 s->hpipe = hpipe;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 s->user_data = param;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 /* Create reader thread. This could fail, so do not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 create the event until thread is created */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 s->hthread = CreateThread (NULL, 0, shove_thread, (LPVOID)s,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 CREATE_SUSPENDED, &thread_id_unused);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 if (s->hthread == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 Lstream_delete (lstr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
577 /* Set the priority of the thread higher so we don't end up waiting
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
578 on it to send things. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
579 if (!SetThreadPriority (s->hthread, THREAD_PRIORITY_HIGHEST))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
580 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
581 CloseHandle (s->hthread);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
582 Lstream_delete (lstr);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
583 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
584 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
585
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 /* hev_thread is an auto-reset event, initially nonsignaled */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
587 s->hev_thread = qxeCreateEvent (NULL, FALSE, FALSE, NULL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 /* Now let it go */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 ResumeThread (s->hthread);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 lstr->flags |= LSTREAM_FL_CLOSE_AT_DISKSAVE;
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
593 return wrap_lstream (lstr);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 static LPARAM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 get_ntpipe_output_stream_param (Lstream *stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
599 struct ntpipe_shove_stream *s = NTPIPE_SHOVE_STREAM_DATA(stream);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 return s->user_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
603 static Bytecount
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 458
diff changeset
604 ntpipe_shove_writer (Lstream *stream, const unsigned char *data,
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
605 Bytecount size)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
607 struct ntpipe_shove_stream *s = NTPIPE_SHOVE_STREAM_DATA(stream);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 if (s->error_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 s->blocking_p = !s->idle_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 if (s->blocking_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 if (size>MAX_SHOVE_BUFFER_SIZE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 memcpy (s->buffer, data, size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 s->size = size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 /* Start output */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 InterlockedDecrement (&s->idle_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 SetEvent (s->hev_thread);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
625 /* Give it a chance to run -- this dramatically improves performance
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
626 of things like crypt. */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
627 if (xSwitchToThread) /* not in Win9x */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
628 (void) xSwitchToThread ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 return size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 ntpipe_shove_was_blocked_p (Lstream *stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
635 struct ntpipe_shove_stream *s = NTPIPE_SHOVE_STREAM_DATA(stream);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 return s->blocking_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 ntpipe_shove_closer (Lstream *stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
642 struct ntpipe_shove_stream *s = NTPIPE_SHOVE_STREAM_DATA(stream);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 /* Force thread stop */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 InterlockedIncrement (&s->die_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
647 /* Close pipe handle, possibly breaking it */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
648 CloseHandle (s->hpipe);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
649
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
650 /* Thread will end upon unblocking. If it's already unblocked this will
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
651 do nothing, but the thread won't look at die_p until it's written any
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
652 pending output. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 SetEvent (s->hev_thread);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 /* Wait while thread terminates */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 WaitForSingleObject (s->hthread, INFINITE);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
657
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
658 /* Close the thread handle */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 CloseHandle (s->hthread);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 /* Destroy the event */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 CloseHandle (s->hev_thread);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 init_shove_stream (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 LSTREAM_HAS_METHOD (ntpipe_shove, writer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 LSTREAM_HAS_METHOD (ntpipe_shove, was_blocked_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 LSTREAM_HAS_METHOD (ntpipe_shove, closer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 /* Winsock I/O stream */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 #define WINSOCK_READ_BUFFER_SIZE 1024
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 struct winsock_stream
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 LPARAM user_data; /* Any user data stored in the stream object */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 SOCKET s; /* Socket handle (which is a Win32 handle) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 OVERLAPPED ov; /* Overlapped I/O structure */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
686 void *buffer; /* Buffer. */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
687 DWORD bufsize; /* Number of bytes last read */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
688 DWORD charbpos; /* Position in buffer for next fetch */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 unsigned int error_p :1; /* I/O Error seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 unsigned int eof_p :1; /* EOF Error seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 unsigned int pending_p :1; /* There is a pending I/O operation */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 unsigned int blocking_p :1; /* Last write attempt would block */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 #define WINSOCK_STREAM_DATA(stream) LSTREAM_TYPE_DATA (stream, winsock)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
697 DEFINE_LSTREAM_IMPLEMENTATION ("winsock", winsock);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 winsock_initiate_read (struct winsock_stream *str)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 ResetEvent (str->ov.hEvent);
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
703 str->charbpos = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 if (!ReadFile ((HANDLE)str->s, str->buffer, WINSOCK_READ_BUFFER_SIZE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 &str->bufsize, &str->ov))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 if (GetLastError () == ERROR_IO_PENDING)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 str->pending_p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 else if (GetLastError () == ERROR_HANDLE_EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 str->eof_p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 str->error_p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 else if (str->bufsize == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 str->eof_p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
719 static Bytecount
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
720 winsock_reader (Lstream *stream, unsigned char *data, Bytecount size)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 struct winsock_stream *str = WINSOCK_STREAM_DATA (stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 /* If the current operation is not yet complete, there's nothing to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 give back */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 if (str->pending_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 if (WaitForSingleObject (str->ov.hEvent, 0) == WAIT_TIMEOUT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 errno = EAGAIN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
735 if (!GetOverlappedResult ((HANDLE)str->s, &str->ov, &str->bufsize,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
736 TRUE))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 if (GetLastError() == ERROR_HANDLE_EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 str->bufsize = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 str->error_p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 if (str->bufsize == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 str->eof_p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 str->pending_p = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 if (str->eof_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 if (str->error_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 /* Return as much of buffer as we have */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
755 size = min (size, (Bytecount) (str->bufsize - str->charbpos));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
756 memcpy (data, (void *) ((BYTE *) str->buffer + str->charbpos), size);
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
757 str->charbpos += size;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 /* Read more if buffer is exhausted */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
760 if (str->bufsize == str->charbpos)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 winsock_initiate_read (str);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 return size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
766 static Bytecount
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 458
diff changeset
767 winsock_writer (Lstream *stream, const unsigned char *data,
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
768 Bytecount size)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 struct winsock_stream *str = WINSOCK_STREAM_DATA (stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 if (str->pending_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 if (WaitForSingleObject (str->ov.hEvent, 0) == WAIT_TIMEOUT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 str->blocking_p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 DWORD dw_unused;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
782 if (!GetOverlappedResult ((HANDLE)str->s, &str->ov, &dw_unused,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
783 TRUE))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 str->error_p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 str->pending_p = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 str->blocking_p = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 if (str->error_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 if (size == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
797 ResetEvent (str->ov.hEvent);
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
798
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
799 /* According to WriteFile docs, we must hold onto the data we pass to it
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
800 and not make any changes until it finishes -- which may not be until
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
801 the next time we get here, since we use asynchronous I/O. We have
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
802 in fact seen data loss as a result of not doing this. */
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
803 str->buffer = xrealloc (str->buffer, size);
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
804 memcpy (str->buffer, data, size);
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
805
560
b202fbfc7dea [xemacs-hg @ 2001-05-23 11:29:58 by ben]
ben
parents: 558
diff changeset
806 /* According to MSDN WriteFile docs, the fourth parameter cannot be NULL
b202fbfc7dea [xemacs-hg @ 2001-05-23 11:29:58 by ben]
ben
parents: 558
diff changeset
807 on Win95 even when doing an overlapped operation, as we are, where
b202fbfc7dea [xemacs-hg @ 2001-05-23 11:29:58 by ben]
ben
parents: 558
diff changeset
808 the return value through that parameter is not meaningful. */
b202fbfc7dea [xemacs-hg @ 2001-05-23 11:29:58 by ben]
ben
parents: 558
diff changeset
809 if (WriteFile ((HANDLE)str->s, str->buffer, size, &str->bufsize,
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
810 &str->ov)
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
811 || GetLastError() == ERROR_IO_PENDING)
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
812 str->pending_p = 1;
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
813 else
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
814 str->error_p = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 return str->error_p ? -1 : size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 winsock_closer (Lstream *lstr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 struct winsock_stream *str = WINSOCK_STREAM_DATA (lstr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 if (lstr->flags & LSTREAM_FL_READ)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 shutdown (str->s, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 shutdown (str->s, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828
986
9b80efded6a5 [xemacs-hg @ 2002-09-01 06:49:49 by youngs]
youngs
parents: 964
diff changeset
829 closesocket (str->s);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 if (str->pending_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 WaitForSingleObject (str->ov.hEvent, INFINITE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
833 if (str->buffer)
560
b202fbfc7dea [xemacs-hg @ 2001-05-23 11:29:58 by ben]
ben
parents: 558
diff changeset
834 {
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1687
diff changeset
835 xfree (str->buffer, void *);
560
b202fbfc7dea [xemacs-hg @ 2001-05-23 11:29:58 by ben]
ben
parents: 558
diff changeset
836 str->buffer = 0;
b202fbfc7dea [xemacs-hg @ 2001-05-23 11:29:58 by ben]
ben
parents: 558
diff changeset
837 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 CloseHandle (str->ov.hEvent);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 winsock_was_blocked_p (Lstream *stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 struct winsock_stream *str = WINSOCK_STREAM_DATA (stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 return str->blocking_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 static Lisp_Object
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
851 make_winsock_stream_1 (SOCKET s, LPARAM param, const char *mode)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 Lstream *lstr = Lstream_new (lstream_winsock, mode);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 struct winsock_stream *str = WINSOCK_STREAM_DATA (lstr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
856 xzero (*str);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 str->s = s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 str->user_data = param;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
860 str->ov.hEvent = qxeCreateEvent (NULL, TRUE, FALSE, NULL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 if (lstr->flags & LSTREAM_FL_READ)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 str->buffer = xmalloc (WINSOCK_READ_BUFFER_SIZE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 winsock_initiate_read (str);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 lstr->flags |= LSTREAM_FL_CLOSE_AT_DISKSAVE;
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
869 return wrap_lstream (lstr);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 make_winsock_input_stream (SOCKET s, LPARAM param)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 return make_winsock_stream_1 (s, param, "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 make_winsock_output_stream (SOCKET s, LPARAM param)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 return make_winsock_stream_1 (s, param, "w");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 static HANDLE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 get_winsock_stream_waitable (Lstream *lstr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 struct winsock_stream *str = WINSOCK_STREAM_DATA (lstr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 return str->ov.hEvent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 static LPARAM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 get_winsock_stream_param (Lstream *lstr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 struct winsock_stream *str = WINSOCK_STREAM_DATA (lstr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 return str->user_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 init_winsock_stream (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 LSTREAM_HAS_METHOD (winsock, reader);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 LSTREAM_HAS_METHOD (winsock, writer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 LSTREAM_HAS_METHOD (winsock, closer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 LSTREAM_HAS_METHOD (winsock, was_blocked_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 }
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
906 #endif /* ! CYGWIN */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 /* Dispatch queue management */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 static int
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
913 mswindows_user_event_p (Lisp_Event *sevt)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 return (sevt->event_type == key_press_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 || sevt->event_type == button_press_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 || sevt->event_type == button_release_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 || sevt->event_type == misc_user_event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 * Add an emacs event to the proper dispatch queue
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
924 void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 mswindows_enqueue_dispatch_event (Lisp_Object event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
927 int user_p = mswindows_user_event_p (XEVENT (event));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
928 if (user_p)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
929 enqueue_dispatch_event (event);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
930 else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
931 enqueue_event (event, &mswindows_s_dispatch_event_queue,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
932 &mswindows_s_dispatch_event_queue_tail);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 /* Avoid blocking on WaitMessage */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
935 qxePostMessage (NULL, XM_BUMPQUEUE, 0, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 * Add a misc-user event to the dispatch queue.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 mswindows_enqueue_misc_user_event (Lisp_Object channel, Lisp_Object function,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 Lisp_Object object)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 Lisp_Object event = Fmake_event (Qnil, Qnil);
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
946
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
947 XSET_EVENT_TYPE (event, misc_user_event);
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
948 XSET_EVENT_CHANNEL (event, channel);
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
949 XSET_EVENT_TIMESTAMP (event, GetTickCount());
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
950 XSET_EVENT_MISC_USER_FUNCTION (event, function);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
951 XSET_EVENT_MISC_USER_OBJECT (event, object);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 mswindows_enqueue_dispatch_event (event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
957 mswindows_enqueue_magic_event (HWND hwnd, UINT msg)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
960
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
961 XSET_EVENT_CHANNEL (emacs_event, hwnd ? mswindows_find_frame (hwnd) : Qnil);
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
962 XSET_EVENT_TIMESTAMP (emacs_event, GetMessageTime ());
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
963 XSET_EVENT_TYPE (emacs_event, magic_event);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
964 XSET_EVENT_MAGIC_MSWINDOWS_EVENT (emacs_event, msg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 mswindows_enqueue_dispatch_event (emacs_event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 static void
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
970 mswindows_enqueue_process_event (Lisp_Process *p)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
973 Lisp_Object process = wrap_process (p);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
974
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
975 XSET_EVENT_TYPE (emacs_event, process_event);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
976 XSET_EVENT_TIMESTAMP (emacs_event, GetTickCount ());
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
977 XSET_EVENT_PROCESS_PROCESS (emacs_event, process);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 mswindows_enqueue_dispatch_event (emacs_event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
983 mswindows_enqueue_mouse_button_event (HWND hwnd, UINT msg, POINTS where,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
984 int mods, DWORD when)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
986 int downp = (msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
987 msg == WM_RBUTTONDOWN);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988
1622
bf2a986fcb17 [xemacs-hg @ 2003-08-13 11:27:47 by stephent]
stephent
parents: 1346
diff changeset
989 /* Wheel rotation amount: positive is away from user, negative towards user */
bf2a986fcb17 [xemacs-hg @ 2003-08-13 11:27:47 by stephent]
stephent
parents: 1346
diff changeset
990 int delta = (short) HIWORD (mods);
bf2a986fcb17 [xemacs-hg @ 2003-08-13 11:27:47 by stephent]
stephent
parents: 1346
diff changeset
991
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 /* We always use last message time, because mouse button
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 events may get delayed, and XEmacs double click
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 recognition will fail */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
997
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
998 mswindows_handle_sticky_modifiers (0, 0, downp, 0);
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
999
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1000 if (downp)
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1001 {
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1002 XSET_EVENT_TYPE (emacs_event, button_press_event);
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1003 }
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1004 else
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1005 {
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1006 XSET_EVENT_TYPE (emacs_event, button_release_event);
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1007 }
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1008
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1009 XSET_EVENT_CHANNEL (emacs_event, mswindows_find_frame (hwnd));
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1010 XSET_EVENT_TIMESTAMP (emacs_event, when);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1011 XSET_EVENT_BUTTON_BUTTON (emacs_event,
1622
bf2a986fcb17 [xemacs-hg @ 2003-08-13 11:27:47 by stephent]
stephent
parents: 1346
diff changeset
1012 (msg==WM_LBUTTONDOWN || msg==WM_LBUTTONUP) ? 1 :
bf2a986fcb17 [xemacs-hg @ 2003-08-13 11:27:47 by stephent]
stephent
parents: 1346
diff changeset
1013 (msg==WM_MBUTTONDOWN || msg==WM_MBUTTONUP) ? 2 :
bf2a986fcb17 [xemacs-hg @ 2003-08-13 11:27:47 by stephent]
stephent
parents: 1346
diff changeset
1014 (msg==WM_RBUTTONDOWN || msg==WM_RBUTTONUP) ? 3 :
bf2a986fcb17 [xemacs-hg @ 2003-08-13 11:27:47 by stephent]
stephent
parents: 1346
diff changeset
1015 (msg==WM_MOUSEWHEEL && delta>0) ? 4 : 5);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1016 XSET_EVENT_BUTTON_X (emacs_event, where.x);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1017 XSET_EVENT_BUTTON_Y (emacs_event, where.y);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1018 XSET_EVENT_BUTTON_MODIFIERS (emacs_event,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1019 mswindows_modifier_state (NULL, mods, 0));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1020
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1021 if (downp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 SetCapture (hwnd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 /* we need this to make sure the main window regains the focus
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 from control subwindows */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 if (GetFocus() != hwnd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 SetFocus (hwnd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 mswindows_enqueue_magic_event (hwnd, WM_SETFOCUS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 ReleaseCapture ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 mswindows_enqueue_dispatch_event (emacs_event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1040 static Lisp_Object
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 mswindows_enqueue_keypress_event (HWND hwnd, Lisp_Object keysym, int mods)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1044
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1045 XSET_EVENT_CHANNEL (emacs_event, mswindows_find_console(hwnd));
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1046 XSET_EVENT_TIMESTAMP (emacs_event, GetMessageTime());
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1047 XSET_EVENT_TYPE (emacs_event, key_press_event);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1048 XSET_EVENT_KEY_KEYSYM (emacs_event, keysym);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1049 XSET_EVENT_KEY_MODIFIERS (emacs_event, mods);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 mswindows_enqueue_dispatch_event (emacs_event);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1051 return emacs_event;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 * Remove and return the first emacs event on the dispatch queue.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 * Give a preference to user events over non-user ones.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 static Lisp_Object
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1059 mswindows_dequeue_dispatch_event (void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1061 assert (!NILP (dispatch_event_queue) ||
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1062 !NILP (mswindows_s_dispatch_event_queue));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1063
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1064 if (!NILP (dispatch_event_queue))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1065 return dequeue_dispatch_event ();
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1066 else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1067 return dequeue_event (&mswindows_s_dispatch_event_queue,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1068 &mswindows_s_dispatch_event_queue_tail);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1071 #ifndef CYGWIN
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 /* Waitable handles manipulation */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 find_waitable_handle (HANDLE h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 for (i = 0; i < mswindows_waitable_count; ++i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 if (mswindows_waitable_handles[i] == h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 return i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 static BOOL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 add_waitable_handle (HANDLE h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 assert (find_waitable_handle (h) < 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 if (mswindows_waitable_count == MAX_WAITABLE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 mswindows_waitable_handles [mswindows_waitable_count++] = h;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 remove_waitable_handle (HANDLE h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 int ix = find_waitable_handle (h);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 if (ix < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 mswindows_waitable_handles [ix] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 mswindows_waitable_handles [--mswindows_waitable_count];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 }
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1107
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1108 #endif /* CYGWIN */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109
791
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1110 /*
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1111 * Given a lisp process pointer remove the corresponding process handle
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1112 * from mswindows_waitable_handles if it is in it. Normally the handle is
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1113 * removed when the process terminates, but if the lisp process structure
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1114 * is deleted before the process terminates we must delete the process
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1115 * handle since it will be invalid and will cause the wait to fail
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1116 */
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1117 void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
1118 mswindows_unwait_process (Lisp_Process *UNUSED_IF_CYGWIN (p))
791
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1119 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1120 #ifndef CYGWIN
791
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1121 remove_waitable_handle (get_nt_process_handle (p));
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1122 #endif /* CYGWIN */
791
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1123 }
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1124
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 /* Event pump */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1130 int
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1131 mswindows_window_is_xemacs (HWND hwnd)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1132 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1133 /* GetClassName will truncate a longer class name. By adding one
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1134 extra character, we are forcing textual comparison to fail
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1135 if the name is longer than XEMACS_CLASS */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1136 Extbyte class_name_buf[sizeof (XEMACS_CLASS) + 2];
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1137
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1138 /* Use GetClassNameA because XEMACS_CLASS is not in Unicode format. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1139 if (!GetClassNameA (hwnd, class_name_buf, sizeof (class_name_buf) - 1))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1140 return 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1141
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1142 return !ascii_strcasecmp (class_name_buf, XEMACS_CLASS);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1143 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1144
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 mswindows_unmodalize_signal_maybe (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1148 mswindows_error_caught_in_modal_loop = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 * This is an unsafe part of event pump, guarded by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 * condition_case. See mswindows_pump_outstanding_events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 static Lisp_Object
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
1156 mswindows_unsafe_pump_events (void *UNUSED (arg))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 Lisp_Object event = Fmake_event (Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 int do_redisplay = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 GCPRO1 (event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163
1268
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1164 while (detect_input_pending (1))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 Fnext_event (event, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 Fdispatch_event (event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 do_redisplay = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 if (do_redisplay)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 redisplay ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 Fdeallocate_event (event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 /* Qt becomes return value of mswindows_pump_outstanding_events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 once we get here */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 return Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 * This function pumps emacs events, while available, by using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 * next_message/dispatch_message loop. Errors are trapped around
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 * the loop so the function always returns.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 * Windows message queue is not looked into during the call,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 * neither are waitable handles checked. The function pumps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 * thus only dispatch events already queued, as well as those
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 * resulted in dispatching thereof. This is done by setting
1268
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1191 * in_modal_loop to nonzero.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 * Return value is Qt if no errors was trapped, or Qunbound if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 * there was an error.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 *
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1196 * In case of error, a warning is issued and the module local variable
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1197 * mswindows_error_caught_in_modal_loop is set to non-zero. Thus,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1198 * Windows internal modal loops are protected against throws, which
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1199 * are proven to corrupt internal Windows structures.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 * In case of success, mswindows_error_caught_in_modal_loop is
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1202 * assigned 0.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 * If the value of mswindows_error_caught_in_modal_loop is not
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1205 * zero already upon entry, the function just returns non-nil.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 * This situation means that a new event has been queued while
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 * in cancel mode. The event will be dequeued on the next regular
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 * call of next-event; the pump is off since error is caught.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 * The caller must *unconditionally* cancel modal loop if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 * value returned by this function is nil. Otherwise, everything
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 * will become frozen until the modal loop exits under normal
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1212 * condition (scrollbar drag is released, menu closed etc.) */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 mswindows_pump_outstanding_events (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 Lisp_Object result = Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 GCPRO1 (result);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1222 if (!mswindows_error_caught_in_modal_loop)
1268
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1223 result = event_stream_protect_modal_loop
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1224 ("Error during event handling", mswindows_unsafe_pump_events, 0, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 UNGCPRO;
1268
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1226 if (UNBOUNDP (result))
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1227 mswindows_error_caught_in_modal_loop = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1231 /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 * This is a special flavor of the mswindows_need_event function,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 * used while in event pump. Actually, there is only kind of events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234 * allowed while in event pump: a timer. An attempt to fetch any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 * other event leads to a deadlock, as there's no source of user input
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 * ('cause event pump mirrors windows modal loop, which is a sole
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 * owner of thread message queue).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 * To detect this, we use a counter of active timers, and allow
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 * fetching WM_TIMER messages. Instead of trying to fetch a WM_TIMER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 * which will never come when there are no pending timers, which leads
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242 * to deadlock, we simply signal an error.
487
54fa1a5c2d12 [xemacs-hg @ 2001-04-28 07:48:36 by ben]
ben
parents: 464
diff changeset
1243 *
54fa1a5c2d12 [xemacs-hg @ 2001-04-28 07:48:36 by ben]
ben
parents: 464
diff changeset
1244 * It might be possible to combine this with mswindows_drain_windows_queue
54fa1a5c2d12 [xemacs-hg @ 2001-04-28 07:48:36 by ben]
ben
parents: 464
diff changeset
1245 * which fetches events when not in a modal loop. It's not clear
54fa1a5c2d12 [xemacs-hg @ 2001-04-28 07:48:36 by ben]
ben
parents: 464
diff changeset
1246 * whether the result would be more complex than is justified.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 mswindows_need_event_in_modal_loop (int badly_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 MSG msg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 /* Check if already have one */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1254 if (!NILP (dispatch_event_queue)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 || !NILP (mswindows_s_dispatch_event_queue))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 /* No event is ok */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 if (!badly_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1262 /* We do not check the user queue, because timers go to _s_ */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263 while (NILP (mswindows_s_dispatch_event_queue))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265 /* We'll deadlock if go waiting */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 if (mswindows_pending_timers_count == 0)
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1267 invalid_operation
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1268 ("Deadlock due to an attempt to call next-event in a wrong context",
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1269 Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 /* Fetch and dispatch any pending timers */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1272 if (qxeGetMessage (&msg, NULL, WM_TIMER, WM_TIMER) > 0)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1273 qxeDispatchMessage (&msg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276
1268
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1277 /* BADLY_P non-zero means we were called from mswindows_need_event(1). It
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1278 only matters when we are in a modal loop, and causes us to fetch timer
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1279 events (the only kinds we can fetch in such a case).
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1280 */
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1281 static void
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1282 mswindows_drain_windows_queue (int badly_p)
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1283 {
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1284 MSG msg;
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1285
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1286 if (in_modal_loop)
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1287 mswindows_need_event_in_modal_loop (badly_p);
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1288 else
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1289 while (qxePeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1290 {
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1291 #ifdef HAVE_DIALOGS
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1292 /* Don't translate messages destined for a dialog box, this
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1293 makes keyboard traversal work. I think?? */
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1294 if (mswindows_is_dialog_msg (&msg))
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1295 {
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1296 mswindows_unmodalize_signal_maybe ();
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1297 continue;
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1298 }
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1299 #endif /* HAVE_DIALOGS */
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1300
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1301 /* We have to translate messages that are not sent to an XEmacs
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1302 frame. This is so that key presses work ok in things like
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1303 edit fields. However, we *musn't* translate message for XEmacs
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1304 frames as this is handled in the wnd proc.
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1305 We also have to avoid generating paint magic events for windows
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1306 that aren't XEmacs frames */
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1307
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1308 if (!mswindows_window_is_xemacs (msg.hwnd))
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1309 TranslateMessage (&msg);
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1310 else if (msg.message == WM_PAINT)
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1311 {
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1312 struct mswindows_frame *msframe;
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1313
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1314 /* hdc will be NULL unless this is a subwindow - in which case we
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1315 shouldn't have received a paint message for it here. */
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1316 assert (msg.wParam == 0);
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1317
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1318 /* Queue a magic event for handling when safe */
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1319 msframe =
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1320 FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (msg.hwnd)));
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1321 if (!msframe->paint_pending)
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1322 {
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1323 msframe->paint_pending = 1;
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1324 mswindows_enqueue_magic_event (msg.hwnd, WM_PAINT);
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1325 }
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1326 /* Don't dispatch. WM_PAINT is always the last message in the
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1327 queue so it's OK to just return. */
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1328 return;
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1329 }
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1330 qxeDispatchMessage (&msg);
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1331 mswindows_unmodalize_signal_maybe ();
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1332 }
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1333 }
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1334
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1335 static void
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1336 emacs_mswindows_drain_queue (void)
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1337 {
1318
b531bf8658e9 [xemacs-hg @ 2003-02-21 06:56:46 by ben]
ben
parents: 1304
diff changeset
1338 /* This can call Lisp */
1268
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1339 mswindows_drain_windows_queue (0);
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1340 #ifdef HAVE_TTY
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1341 drain_tty_devices ();
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1342 #endif
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1343 }
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1344
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 * This drains the event queue and fills up two internal queues until
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347 * an event of a type specified by USER_P is retrieved.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 * Used by emacs_mswindows_event_pending_p and emacs_mswindows_next_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 mswindows_need_event (int badly_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1355 while (NILP (dispatch_event_queue)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 && NILP (mswindows_s_dispatch_event_queue))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1358 #ifdef CYGWIN
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 int i;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
1360 int active;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 SELECT_TYPE temp_mask = input_wait_mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362 EMACS_TIME sometime;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 EMACS_SELECT_TIME select_time_to_block, *pointer_to_this;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365 if (badly_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 pointer_to_this = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 EMACS_SET_SECS_USECS (sometime, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370 EMACS_TIME_TO_SELECT_TIME (sometime, select_time_to_block);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 pointer_to_this = &select_time_to_block;
1268
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1372 if (in_modal_loop)
534
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1373 /* In modal loop with badly_p false, don't care about
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1374 Windows events. */
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1375 FD_CLR (windows_fd, &temp_mask);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377
1292
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1279
diff changeset
1378 mswindows_is_blocking = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 active = select (MAXDESC, &temp_mask, 0, 0, pointer_to_this);
1292
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1279
diff changeset
1380 mswindows_is_blocking = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382 if (active == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 assert (!badly_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 return; /* timeout */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 else if (active > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 if (FD_ISSET (windows_fd, &temp_mask))
1268
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1390 mswindows_drain_windows_queue (badly_p);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1391 else
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1393 #ifdef HAVE_TTY
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1394 /* Look for a TTY event */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1395 for (i = 0; i < MAXDESC; i++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1397 /* To avoid race conditions (among other things, an infinite
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1398 loop when called from Fdiscard_input()), we must return
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1399 user events ahead of process events. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1400 if (FD_ISSET (i, &temp_mask) && FD_ISSET (i, &tty_only_mask))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1402 struct console *c =
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1403 find_tty_or_stream_console_from_fd (i);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1404 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1405 Lisp_Event *event = XEVENT (emacs_event);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1406
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1407 assert (c);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1408 if (read_event_from_tty_or_stream_desc (event, c))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1409 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1410 mswindows_enqueue_dispatch_event (emacs_event);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1411 return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1412 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 #endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1416 /* Look for a process event */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1417 for (i = 0; i < MAXDESC; i++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1419 if (FD_ISSET (i, &temp_mask))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1421 if (FD_ISSET (i, &process_only_mask))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1422 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1423 Lisp_Process *p =
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1424 get_process_from_usid (FD_TO_USID (i));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1425
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1426 mswindows_enqueue_process_event (p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1427 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1428 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1429 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1430 /* We might get here when a fake event came
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1431 through a signal. Return a dummy event, so
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1432 that a cycle of the command loop will
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1433 occur. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1434 drain_signal_event_pipe ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1435 mswindows_enqueue_magic_event (NULL, XM_BUMPQUEUE);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1436 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1441 else if (active == -1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 if (errno != EINTR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445 /* something bad happened */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1446 assert (0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1451 assert (0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 }
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1453 #else /* not CYGWIN */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454 /* Now try getting a message or process event */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
1455 DWORD active;
487
54fa1a5c2d12 [xemacs-hg @ 2001-04-28 07:48:36 by ben]
ben
parents: 464
diff changeset
1456 DWORD what_events;
1268
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1457 if (in_modal_loop)
534
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1458 /* In a modal loop, only look for timer events, and only if
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1459 we really need one. */
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1460 {
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1461 if (badly_p)
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1462 what_events = QS_TIMER;
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1463 else
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1464 what_events = 0;
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1465 }
487
54fa1a5c2d12 [xemacs-hg @ 2001-04-28 07:48:36 by ben]
ben
parents: 464
diff changeset
1466 else
534
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1467 /* Look for any event */
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1468 what_events = QS_ALLINPUT;
487
54fa1a5c2d12 [xemacs-hg @ 2001-04-28 07:48:36 by ben]
ben
parents: 464
diff changeset
1469
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1470 /*
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1471 #### YUCK YUCK YUCK!!!!
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1472
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1473 When running under a debugger, every time I hit F12 (which for me
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1474 is mapped to right-brace) I hit a breakpoint inside of Windows!
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1475
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1476 NTDLL! DbgBreakPoint@0 address 0x77f9eea9
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1477 KERNEL32! BaseAttachComplete@4 + 41 bytes
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1478 KERNEL32! BaseAttachCompleteThunk@0 + 19 bytes
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1479 USER32! MsgWaitForMultipleObjectsEx@20 + 224 bytes
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1480 USER32! MsgWaitForMultipleObjects@20 + 30 bytes
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1481
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1482 Microsoft says:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1483
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1484 (Knowledge Base Q130667, PRB: F12 Causes Hard-Coded Breakpoint
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1485 Exception When Debugging)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1486
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1487 CAUSE
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1488
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1489 When the F12 key is pressed and the application in focus is being
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1490 debugged, Windows NT calls a function similar to DebugBreak(),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1491 which executes a hard coded breakpoint instruction. The integrated
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1492 debugger then traps the exception generated by this instruction.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1493
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1494 This behavior is intentional and occurs with other debuggers such
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1495 as WinDbg from the Windows 32-bit SDK.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1496
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1497 RESOLUTION
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1498
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1499 While there is no way to disable this functionality, it doesn't
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1500 affect the application that's being debugged other than to pause
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1501 debugging and change focus. You can continue debugging by pressing
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1502 the F5 key.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1503
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1504 This can be annoying if you have an application that heavily uses
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1505 the F12 key, so you may want to temporarily assign another key to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1506 handle the F12 key functionality in your program when debugging.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1507
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1508 STATUS
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1509
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1510 This behavior is by design.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1511
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1512
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1513 However, elsewhere I found this:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1514
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1515 UserDebuggerHotKey
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1516 HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1517
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1518 Data type Range Default value
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1519 REG_DWORD 0x0 - 0xFF 0x0
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1520
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1521 Description
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1522
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1523 Specifies the key that, when pressed, establishes a breakpoint in
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1524 code being debugged.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1525
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1526 The debugger interrupts code processing at the breakpoint so the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1527 programmer can examine a suspected problem.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1528
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1529 The key specified in this value only sets a breakpoint. It does
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1530 not invoke the debugger (the debugger must be running before the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1531 key is pressed) and it does not switch the debugger to single-step
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1532 mode.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1533
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1534 The value of this entry is a keyboard scan code. The default
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1535 value, 0x0, represents the F12 key on a 101-key keyboard or the -
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1536 (hyphen, VK_SUBTRACT) key on an 82-key keyboard.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1537 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1538
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1539 __try
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1540 {
923
3b122a8e1d51 [xemacs-hg @ 2002-07-14 23:20:35 by mta]
mta
parents: 903
diff changeset
1541 /* This fixes a long outstanding bug, where XEmacs would occasionally
3b122a8e1d51 [xemacs-hg @ 2002-07-14 23:20:35 by mta]
mta
parents: 903
diff changeset
1542 * not redraw its window (or process other events) until "something
3b122a8e1d51 [xemacs-hg @ 2002-07-14 23:20:35 by mta]
mta
parents: 903
diff changeset
1543 * happened" - usually the mouse moving over a frame.
3b122a8e1d51 [xemacs-hg @ 2002-07-14 23:20:35 by mta]
mta
parents: 903
diff changeset
1544 *
3b122a8e1d51 [xemacs-hg @ 2002-07-14 23:20:35 by mta]
mta
parents: 903
diff changeset
1545 * The problem is that MsgWaitForMultipleObjects only checks to see
3b122a8e1d51 [xemacs-hg @ 2002-07-14 23:20:35 by mta]
mta
parents: 903
diff changeset
1546 * if NEW messages have been placed into the thread queue. So we
3b122a8e1d51 [xemacs-hg @ 2002-07-14 23:20:35 by mta]
mta
parents: 903
diff changeset
1547 * specifically check to see if the queue is empty (using PeekMessage
3b122a8e1d51 [xemacs-hg @ 2002-07-14 23:20:35 by mta]
mta
parents: 903
diff changeset
1548 * with the PM_NOREMOVE flag) before we wait.
3b122a8e1d51 [xemacs-hg @ 2002-07-14 23:20:35 by mta]
mta
parents: 903
diff changeset
1549 */
3b122a8e1d51 [xemacs-hg @ 2002-07-14 23:20:35 by mta]
mta
parents: 903
diff changeset
1550 MSG msg;
3b122a8e1d51 [xemacs-hg @ 2002-07-14 23:20:35 by mta]
mta
parents: 903
diff changeset
1551 if (what_events == QS_ALLINPUT && badly_p &&
3b122a8e1d51 [xemacs-hg @ 2002-07-14 23:20:35 by mta]
mta
parents: 903
diff changeset
1552 qxePeekMessage (&msg, 0, 0, 0, PM_NOREMOVE))
3b122a8e1d51 [xemacs-hg @ 2002-07-14 23:20:35 by mta]
mta
parents: 903
diff changeset
1553 active = WAIT_OBJECT_0 + mswindows_waitable_count;
3b122a8e1d51 [xemacs-hg @ 2002-07-14 23:20:35 by mta]
mta
parents: 903
diff changeset
1554 else
1292
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1279
diff changeset
1555 {
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1279
diff changeset
1556 mswindows_is_blocking = 1;
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1279
diff changeset
1557 active = MsgWaitForMultipleObjects (mswindows_waitable_count,
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1279
diff changeset
1558 mswindows_waitable_handles,
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1279
diff changeset
1559 FALSE,
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1279
diff changeset
1560 badly_p ? INFINITE : 0,
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1279
diff changeset
1561 what_events);
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1279
diff changeset
1562 mswindows_is_blocking = 0;
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1279
diff changeset
1563 }
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1564 }
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1565 __except (GetExceptionCode () == EXCEPTION_BREAKPOINT ?
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1566 EXCEPTION_CONTINUE_EXECUTION :
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1567 EXCEPTION_CONTINUE_SEARCH)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1568 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1569 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1570
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1571 /* This will assert if handle being waited for becomes abandoned.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1572 Not the case currently tho */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1573 assert ((!badly_p && active == WAIT_TIMEOUT) ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1574 (active >= WAIT_OBJECT_0 &&
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1575 active <= WAIT_OBJECT_0 + mswindows_waitable_count));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1576
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1577 if (active == WAIT_TIMEOUT)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1578 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1579 /* No luck trying - just return what we've already got */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1580 return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1581 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1582 else if (active == WAIT_OBJECT_0 + mswindows_waitable_count)
1268
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
1583 mswindows_drain_windows_queue (badly_p);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1584 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1585 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1586 int ix = active - WAIT_OBJECT_0;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1587
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1588 /* look for a stream console event; see
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1589 emacs_mswindows_select_console below. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1590 LIST_LOOP_3 (porca_troia, Vconsole_list, vcontail)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1591 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1592 struct console *con = XCONSOLE (porca_troia);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1593
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1594 if (CONSOLE_STREAM_P (con))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1595 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1596 Lisp_Object instr = CONSOLE_STREAM_DATA (con)->instream;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1597 if (!NILP (instr) && !UNBOUNDP (instr) &&
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1598 get_ntpipe_input_stream_waitable (XLSTREAM (instr)) ==
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1599 mswindows_waitable_handles [ix])
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1600 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1601 Ichar ch = Lstream_get_ichar (XLSTREAM (instr));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1602 if (ch < 0)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1603 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1604 /* deleting the console might not be safe right now
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1605 ... */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1606 enqueue_magic_eval_event (io_error_delete_console,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1607 porca_troia);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1608 /* but we definitely need to unselect it to avoid
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1609 infinite loops reading EOF's */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1610 Fconsole_disable_input (porca_troia);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1611 mswindows_enqueue_magic_event (NULL, XM_BUMPQUEUE);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1612 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1613 else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1614 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1615 Lisp_Object event = Fmake_event (Qnil, Qnil);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1616 /* Here we really do want to set the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1617 use_console_meta_flag because the char is from the
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1618 TTY. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1619 character_to_event (ch, XEVENT (event), con, 1, 1);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1620 XSET_EVENT_CHANNEL (event, porca_troia);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1621 enqueue_dispatch_event (event);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1622 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1623 break;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1624 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1625 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1626 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1627
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1628 if (NILP (vcontail))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1629 { /* no stream console event, look for process event */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1630 /* First, try to find which process' output has signaled */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1631 Lisp_Process *p =
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1632 get_process_from_usid (HANDLE_TO_USID
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1633 (mswindows_waitable_handles[ix]));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1634 if (p != NULL)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1635 /* Found a signaled process input handle */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1636 mswindows_enqueue_process_event (p);
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1637 else
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1638 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1639 /* None. This means that the process handle itself has
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1640 signaled. Remove the handle from the wait vector, and
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1641 make status_notify note the exited process. First
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1642 find the process object if possible. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1643 LIST_LOOP_3 (vaffanculo, Vprocess_list, vproctail)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1644 if (get_nt_process_handle (XPROCESS (vaffanculo)) ==
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1645 mswindows_waitable_handles [ix])
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1646 break;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1647 mswindows_waitable_handles [ix] =
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1648 mswindows_waitable_handles [--mswindows_waitable_count];
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1649 kick_status_notify ();
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1650 /* We need to return a process event here so that (1)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1651 accept-process-output will return when called on this
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1652 process, and (2) status notifications will happen in
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1653 accept-process-output, sleep-for, and sit-for. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1654 if (!NILP (vproctail))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1655 mswindows_enqueue_process_event (XPROCESS (vaffanculo));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1656 else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1657 {
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2421
diff changeset
1658 /* ABORT (); */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1659 /* #### FUCKME! When can this happen? I hit this
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2421
diff changeset
1660 ABORT() when I tried enabling it. */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1661 /* Have to return something: there may be no
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1662 accompanying process event */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1663 mswindows_enqueue_magic_event (NULL, XM_BUMPQUEUE);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1664 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1665 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1666 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1667 }
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1668 #endif /* not CYGWIN */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1669 } /* while */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 /* Event generators */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1677 * Callback procedure for synchronous timer messages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679 static void CALLBACK
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
1680 mswindows_wm_timer_callback (HWND UNUSED (hwnd), UINT UNUSED (umsg),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
1681 UINT id_timer, DWORD dwtime)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 if (KillTimer (NULL, id_timer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 --mswindows_pending_timers_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1688 XSET_EVENT_CHANNEL (emacs_event, Qnil);
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1689 XSET_EVENT_TIMESTAMP (emacs_event, dwtime);
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
1690 XSET_EVENT_TYPE (emacs_event, timeout_event);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1691 XSET_EVENT_TIMEOUT_INTERVAL_ID (emacs_event, id_timer);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1692 XSET_EVENT_TIMEOUT_FUNCTION (emacs_event, Qnil);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1693 XSET_EVENT_TIMEOUT_OBJECT (emacs_event, Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695 mswindows_enqueue_dispatch_event (emacs_event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1697
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1698 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1699 * Callback procedure for dde messages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1700 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1701 * We execute a dde Open("file") by simulating a file drop, so dde support
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1702 * depends on dnd support.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1703 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1704 #ifdef HAVE_DRAGNDROP
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 656
diff changeset
1705 extern int mswindows_dde_enable;
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 656
diff changeset
1706
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1707 EXFUN(Fread_from_string, 3);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1708
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1709 /* The following variables are used to maintain consistency of result and
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1710 * error reporting to the client.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1711 * The basic protocol is to Execute a lisp form, and then Request one or
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1712 * more of the following items: Status (1 = OK, 0 = Error), Result, or Error.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1713 * When the lisp form is queued, the dde_eval_pending flag is set to 1,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1714 * to indicate that the items are not yet available. The dde_eval_pending
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1715 * flag is set to 0 when the evaluation is complete. Requests for the result
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1716 * items will block while the dde_eval_pending flag is 1, to avoid clients
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1717 * getting inconsistent results.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1718 */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1719 static int dde_eval_pending;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1720 static Lisp_Object dde_eval_result;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1721 static Lisp_Object dde_eval_error;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1722
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1723 static Lisp_Object
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
1724 dde_error (Lisp_Object err, Lisp_Object UNUSED (obj))
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1725 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1726 dde_eval_error = err;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1727 return Qnil;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1728 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1729
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1730 /* Read lisp forms from a string. Evaluate the forms as if they were
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1731 * wrapped in a progn form. Return the result of the form.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1732 */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1733 static Lisp_Object
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1734 dde_eval_string (Lisp_Object str)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1735 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1736 struct gcpro gcpro1, gcpro2;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1737 Lisp_Object args[3];
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1738 Lisp_Object obj;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1739
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1740 /* Heavy handed GCPROing, on the principle of it's better to be safe than
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1741 * sorry...
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1742 */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1743 args[0] = Qnil;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1744 args[1] = Qnil;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1745 args[2] = Qnil;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1746 GCPRO2 (args[0], str);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1747 gcpro1.nvars = 3;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1748
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1749 /* Wrap the user supplied string in string "(progn ...)".
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1750 * We can now just read-from-string a single form. If we
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1751 * get an error, or finish before the end of the string,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1752 * we know the original string had syntax errors.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1753 */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1754 args[0] = build_string ("(progn ");
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1755 args[1] = str;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1756 args[2] = build_string (")");
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1757 str = Fconcat (3, args);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1758
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1759 obj = Fread_from_string (str, Qnil, Qnil);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1760 UNGCPRO;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1761
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1762 /* The following doesn't check that the length fits in an EMACS_INT.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1763 * This won't be a problem in reality...?
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1764 *
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1765 * If the read didn't get to the end of the string, we have a syntax
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1766 * error in the string supplied by the user.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1767 */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1768 if (XINT (XCDR (obj)) != XSTRING_LENGTH (str))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1769 return Qnil;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1770
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1771 GCPRO1 (obj);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1772 obj = Feval (XCAR (obj));
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1773
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1774 RETURN_UNGCPRO (obj);
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1775 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1776
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1777 /* Evaluate the supplied string as a sequence of Lisp forms, wrapped in
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1778 * a progn. Catch any evaluation errors. Set the evaluation status and
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1779 * result variables.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1780 */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1781 static void
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1782 dde_eval (Lisp_Object str)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1783 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1784 dde_eval_error = Qnil;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1785 dde_eval_result = condition_case_1 (Qt, dde_eval_string, str,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1786 dde_error, Qnil);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1787 dde_eval_pending = 0;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1788
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1789 /* Re-enable callbacks in case the client is waiting on a request */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1790 DdeEnableCallback (mswindows_dde_mlid, NULL, EC_ENABLEALL);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1791
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1792 /* Post advise notifications on the result item */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1793 DdePostAdvise (mswindows_dde_mlid, mswindows_dde_topic_eval,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1794 mswindows_dde_item_result);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1795 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1796
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1797 /* A list of DDE advise tokens. Each token is an uninterned symbol,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1798 * whose value is the DDE string handle for its name (stored as a float,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1799 * as a Lisp int cannot hold a full C int).
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2828
diff changeset
1800 * The token's `dde-data' property is used to store data for a dde-advise.
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1801 */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1802 Lisp_Object Vdde_advise_items;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1803
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2828
diff changeset
1804 /* The symbol `HSZ' */
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1805 Lisp_Object QHSZ;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1806
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1807 DEFUN("dde-alloc-advise-item", Fdde_alloc_advise_item, 0, 1, 0, /*
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1808 Allocate an advise item, and return its token.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1809 */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1810 (name))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1811 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1812 Lisp_Object token;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1813 Extbyte *str;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1814 HSZ hsz;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1815 struct gcpro gcpro1, gcpro2;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1816
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1817 if (!NILP (name))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1818 CHECK_STRING (name);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1819 else
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1820 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1821 static int num = 0;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1822 char buf[20];
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1823 sprintf (buf, "Tok%d", num);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1824 ++num;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1825 name = build_string (buf);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1826 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1827
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1828 token = Qnil;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1829 GCPRO2 (name, token);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1830 token = Fmake_symbol (name);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1831 TO_EXTERNAL_FORMAT (LISP_STRING, name, C_STRING_ALLOCA, str,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1832 Qmswindows_tstr);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1833 hsz = qxeDdeCreateStringHandle (mswindows_dde_mlid, str,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1834 XEUNICODE_P ? CP_WINUNICODE : CP_WINANSI);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1835
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1836 Fput(token, QHSZ, make_float ((int)hsz));
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1837 Vdde_advise_items = Fcons (token, Vdde_advise_items);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1838
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
1839 RETURN_UNGCPRO (token);
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1840 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1841
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1842 DEFUN("dde-free-advise-item", Fdde_free_advise_item, 1, 1, 0, /*
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1843 Free the resources associated with advise item ITEM.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1844
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1845 Frees all resources allocated to allow clients to set up advise loops
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1846 on ITEM. It is assumed that no active advise loops remain. However, no
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1847 problems should arise if they do - it's just that we won't ever send any
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1848 notifications again.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1849
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1850 If the user does not free an advise item, resources will be leaked.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1851 */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1852 (item))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1853 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1854 HSZ hsz;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1855 Lisp_Object val;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1856
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1857 CHECK_SYMBOL (item);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1858 val = Fget (item, QHSZ, Qnil);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1859 if (!FLOATP (val))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1860 return Qnil;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1861 hsz = (HSZ)(int)XFLOAT_DATA (val);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1862 DdeFreeStringHandle (mswindows_dde_mlid, hsz);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1863 Vdde_advise_items = delq_no_quit (item, Vdde_advise_items);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1864 return Qnil;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1865 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1866
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1867 DEFUN("dde-advise", Fdde_advise, 2, 2, 0, /*
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1868 Post a DDE advise for ITEM with associated data DATA.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1869
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1870 Records the value DATA for sending back to clients waiting for
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1871 notifications on DDE item ITEM in the system topic, and posts
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1872 the advise transaction.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1873
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1874 ITEM must be an advise token allocated using dde-alloc-advise-item.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1875 */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1876 (item, data))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1877 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1878 HSZ hsz;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1879 Lisp_Object val;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1880
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1881 CHECK_SYMBOL (item);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1882 val = Fget (item, QHSZ, Qnil);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1883 if (!FLOATP (val))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1884 return Qnil;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1885 hsz = (HSZ)(int)XFLOAT_DATA (val);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1886
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1887 Fset (item, data);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1888 DdePostAdvise (mswindows_dde_mlid, mswindows_dde_topic_eval, hsz);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1889 return Qnil;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1890 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1891
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1892 HDDEDATA CALLBACK
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
1893 mswindows_dde_callback (UINT uType, UINT uFmt, HCONV UNUSED (hconv),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1894 HSZ hszTopic, HSZ hszItem, HDDEDATA hdata,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
1895 DWORD UNUSED (dwData1), DWORD UNUSED (dwData2))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1896 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1897 switch (uType)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1898 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1899 case XTYP_CONNECT:
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1900 if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1901 || !DdeCmpStringHandles (hszTopic, mswindows_dde_topic_eval))
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1902 return (HDDEDATA) TRUE;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1903 return (HDDEDATA) FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1904
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1905 case XTYP_WILDCONNECT:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1906 {
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1907 /* We support two {service,topic} pairs */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1908 HSZPAIR pairs[3] =
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1909 {
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1910 { mswindows_dde_service, mswindows_dde_topic_system },
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1911 { mswindows_dde_service, mswindows_dde_topic_eval },
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1912 { 0, 0 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1913 };
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1914
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1915 if ((!hszItem
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1916 || !DdeCmpStringHandles (hszItem, mswindows_dde_service)) &&
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1917 (!hszTopic
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1918 || !DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1919 || !DdeCmpStringHandles (hszTopic, mswindows_dde_topic_eval)))
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1920 return (DdeCreateDataHandle (mswindows_dde_mlid, (LPBYTE) pairs,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1921 sizeof (pairs), 0L, 0, uFmt, 0));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1922 }
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
1923 return (HDDEDATA) NULL;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1924
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1925 case XTYP_ADVSTART:
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1926 if (!mswindows_dde_enable)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1927 return (HDDEDATA) FALSE;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1928
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1929 /* We only support advise loops on the eval topic for text data */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1930 if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_eval)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1931 && (uFmt == CF_TEXT || uFmt == CF_UNICODETEXT))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1932 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1933 /* Only allocated items or Result, are allowed */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1934 if (!DdeCmpStringHandles (hszItem, mswindows_dde_item_result))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1935 return (HDDEDATA) TRUE;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1936
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1937 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1938 EXTERNAL_LIST_LOOP_2 (elt, Vdde_advise_items)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1939 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1940 Lisp_Object val;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1941 HSZ hsz;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1942 if (!SYMBOLP (elt))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1943 continue;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1944 val = Fget (elt, QHSZ, Qnil);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1945 if (!FLOATP (val))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1946 continue;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1947 hsz = (HSZ) (int) XFLOAT_DATA (val);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1948 if (!DdeCmpStringHandles (hszItem, hsz))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1949 return (HDDEDATA) TRUE;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1950 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1951 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1952 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1953 return (HDDEDATA) FALSE;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1954
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1955 /* Both advise requests and normal requests work the same */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1956 case XTYP_ADVREQ:
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1957 case XTYP_REQUEST:
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1958 if (!mswindows_dde_enable)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1959 return (HDDEDATA) NULL;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1960
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1961 if (DdeCmpStringHandles (hszTopic, mswindows_dde_topic_eval) != 0)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1962 return (HDDEDATA) NULL;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1963
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1964 /* If this is a normal request and we're in the middle of
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1965 * an Execute, block until the Execute completes.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1966 */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1967 if (dde_eval_pending && uType == XTYP_REQUEST)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1968 return (HDDEDATA) CBR_BLOCK;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1969
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1970 /* We can only support requests for ANSI or Unicode text */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1971 if (uFmt != CF_TEXT && uFmt != CF_UNICODETEXT)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1972 return (HDDEDATA) NULL;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1973
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1974 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1975 Lisp_Object args[2];
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1976 struct gcpro gcpro1;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1977 Lisp_Object res;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1978 Extbyte *result;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1979 DWORD bytes;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1980
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1981 args[0] = Qnil;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1982 args[1] = Qnil;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1983 GCPRO1 (args[0]);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1984 gcpro1.nvars = 2;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1985
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1986
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1987 if (!DdeCmpStringHandles (hszItem, mswindows_dde_item_result))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1988 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1989 if (NILP (dde_eval_error))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1990 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1991 args[0] = build_string ("OK: %s");
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1992 args[1] = dde_eval_result;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1993 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1994 else
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1995 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1996 args[0] = build_string ("ERR: %s");
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1997 args[1] = dde_eval_error;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1998 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
1999 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2000 else
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2001 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2002 EXTERNAL_LIST_LOOP_2 (elt, Vdde_advise_items)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2003 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2004 Lisp_Object val;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2005 HSZ hsz;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2006 if (!SYMBOLP (elt))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2007 continue;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2008 val = Fget (elt, QHSZ, Qnil);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2009 if (!FLOATP (val))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2010 continue;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2011 hsz = (HSZ) (int) XFLOAT_DATA (val);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2012 if (!DdeCmpStringHandles (hszItem, hsz))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2013 args[1] = Fsymbol_value (elt);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2014 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2015 args[0] = build_string ("%s");
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2016 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2017
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2018 res = Fformat (2, args);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2019 UNGCPRO;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2020
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2021 bytes = (uFmt == CF_TEXT ? 1 : 2) * (XSTRING_LENGTH (res) + 1);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2022 TO_EXTERNAL_FORMAT (LISP_STRING, res,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2023 C_STRING_ALLOCA, result,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2024 uFmt == CF_TEXT ? Qmswindows_multibyte
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2025 : Qmswindows_unicode);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2026
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2027 /* If we cannot create the data handle, this passes the null
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2028 * return back to the client, which signals an error as we wish.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2029 */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2030 return DdeCreateDataHandle (mswindows_dde_mlid, (LPBYTE)result,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2031 bytes, 0L, hszItem, uFmt, 0);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2032 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2033
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2034 case XTYP_EXECUTE:
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 656
diff changeset
2035 if (!mswindows_dde_enable)
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 656
diff changeset
2036 return (HDDEDATA) DDE_FBUSY;
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 656
diff changeset
2037
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2038 if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_eval))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2039 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2040 DWORD len;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2041 LPBYTE extcmd;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2042 Lisp_Object tmp;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2043
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2044 /* Grab a pointer to the raw data supplied */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2045 extcmd = DdeAccessData (hdata, &len);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2046
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2047 TO_INTERNAL_FORMAT (DATA, (extcmd, len),
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2048 LISP_STRING, tmp,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2049 Qmswindows_tstr);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2050
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2051 /* Release and free the data handle */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2052 DdeUnaccessData (hdata);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2053 DdeFreeDataHandle (hdata);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2054
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2055 /* Set a flag to say that the evaluation isn't yet complete,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2056 * enqueue the evaluation, send a dummy event to trigger the
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2057 * event loop (I've no idea why this is needed, but it works...)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2058 * and return success to the client.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2059 */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2060 dde_eval_pending = 1;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2061 enqueue_magic_eval_event (dde_eval, tmp);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2062 mswindows_enqueue_magic_event (NULL, XM_BUMPQUEUE);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2063 return (HDDEDATA) DDE_FACK;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2064 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
2065 else if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2066 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2067 DWORD len = DdeGetData (hdata, NULL, 0, 0);
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
2068 Extbyte *extcmd = alloca_extbytes (len + 1);
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 856
diff changeset
2069 Ibyte *cmd;
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 856
diff changeset
2070 Ibyte *end;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2071 struct gcpro gcpro1, gcpro2;
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 656
diff changeset
2072 Lisp_Object l_dndlist = Qnil;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2073 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2074 Lisp_Object frmcons, devcons, concons;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2075 Lisp_Event *event = XEVENT (emacs_event);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2076
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
2077 DdeGetData (hdata, (LPBYTE) extcmd, len, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2078 DdeFreeDataHandle (hdata);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2079
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2080 TO_INTERNAL_FORMAT (DATA, (extcmd, len),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2081 C_STRING_ALLOCA, cmd,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2082 Qmswindows_tstr);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2083
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2084 /* Check syntax & that it's an [Open("foo")] command, which we
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2085 * treat like a file drop */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2086 if (*cmd == '[')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2087 cmd++;
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
2088 if (qxestrncasecmp_ascii (cmd, MSWINDOWS_DDE_ITEM_OPEN,
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2089 strlen (MSWINDOWS_DDE_ITEM_OPEN)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2090 return DDE_FNOTPROCESSED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2091 cmd += strlen (MSWINDOWS_DDE_ITEM_OPEN);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2092 while (*cmd == ' ')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2093 cmd++;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2094 if (*cmd != '(' || *(cmd + 1) != '\"')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2095 return DDE_FNOTPROCESSED;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2096 end = (cmd += 2);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2097 while (*end && *end != '\"')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2098 end++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2099 if (!*end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2100 return DDE_FNOTPROCESSED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2101 *end = '\0';
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2102 if (*++end != ')')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2103 return DDE_FNOTPROCESSED;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2104 if (*++end == ']')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2105 end++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2106 if (*end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2107 return DDE_FNOTPROCESSED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2108
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2109 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2110 /* The drag-n-drop code in dragdrop.el expects pseudo-URL's,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2111 consisting of just file: followed by the filename. This
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2112 should maybe work, but both Netscape and IE complain
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2113 whenever they're not given the full file spec, like
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2114
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2115 file:///C|/foo/bar/ or equivalently
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2116 file:///C:/foo/bar/ (less portably)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2117
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2118 they don't allow relative paths at all! this is way bogus. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2119 cmd = urlify_filename (cmd);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2120 l_dndlist = build_intstring (cmd);
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1687
diff changeset
2121 xfree (cmd, Ibyte *);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2122 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2123 GCPRO2 (emacs_event, l_dndlist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2125 /* Find a mswindows frame */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2126 event->channel = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2127 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2128 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2129 Lisp_Object frame = XCAR (frmcons);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2130 if (FRAME_TYPE_P (XFRAME (frame), mswindows))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2131 event->channel = frame;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2132 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2133 assert (!NILP (event->channel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2134
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
2135 SET_EVENT_TIMESTAMP (event, GetTickCount());
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
2136 SET_EVENT_TYPE (event, misc_user_event);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2137 SET_EVENT_MISC_USER_BUTTON (event, 1);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2138 SET_EVENT_MISC_USER_MODIFIERS (event, 0);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2139 SET_EVENT_MISC_USER_X (event, -1);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2140 SET_EVENT_MISC_USER_Y (event, -1);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2141 SET_EVENT_MISC_USER_FUNCTION (event,
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
2142 Qdragdrop_drop_dispatch);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2143 SET_EVENT_MISC_USER_OBJECT (event,
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
2144 Fcons (Qdragdrop_URL,
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
2145 Fcons (l_dndlist, Qnil)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2146 mswindows_enqueue_dispatch_event (emacs_event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2147 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2148 return (HDDEDATA) DDE_FACK;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2149 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2150 DdeFreeDataHandle (hdata);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2151 return (HDDEDATA) DDE_FNOTPROCESSED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2153 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2154 return (HDDEDATA) NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2155 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2156 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2157 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2158
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2159 /*
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2160 * Helper to do repainting - repaints can happen both from the windows
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2161 * procedure and from magic events
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2162 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2163 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2164 mswindows_handle_paint (struct frame *frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2165 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2166 HWND hwnd = FRAME_MSWINDOWS_HANDLE (frame);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2167
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2168 /* According to the docs we need to check GetUpdateRect() before
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2169 actually doing a WM_PAINT */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2170 if (GetUpdateRect (hwnd, NULL, FALSE))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2171 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2172 PAINTSTRUCT paintStruct;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2173 int x, y, width, height;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2174
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2175 BeginPaint (hwnd, &paintStruct);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2176 x = paintStruct.rcPaint.left;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2177 y = paintStruct.rcPaint.top;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2178 width = paintStruct.rcPaint.right - paintStruct.rcPaint.left;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2179 height = paintStruct.rcPaint.bottom - paintStruct.rcPaint.top;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2180 /* Normally we want to ignore expose events when child
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2181 windows are unmapped, however once we are in the guts of
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2182 WM_PAINT we need to make sure that we don't register
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2183 unmaps then because they will not actually occur. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2184 /* #### commenting out the next line seems to fix some problems
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2185 but not all. only andy currently understands this stuff and
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2186 he needs to review it more carefully. --ben */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2187 if (!check_for_ignored_expose (frame, x, y, width, height))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2188 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2189 hold_ignored_expose_registration = 1;
1318
b531bf8658e9 [xemacs-hg @ 2003-02-21 06:56:46 by ben]
ben
parents: 1304
diff changeset
2190 redisplay_redraw_exposed_area (frame, x, y, width, height);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2191 hold_ignored_expose_registration = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2192 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2193 EndPaint (hwnd, &paintStruct);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2194 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2195 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2196
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2197 /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2198 * Returns 1 if a key is a real modifier or special key, which
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2199 * is better handled by DefWindowProc
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2200 */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2201 static int
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2202 key_needs_default_processing_p (UINT vkey)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2203 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2204 if (mswindows_alt_by_itself_activates_menu && vkey == VK_MENU
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2205 /* if we let ALT activate the menu like this, then sticky ALT-modified
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2206 keystrokes become impossible. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2207 && !modifier_keys_are_sticky)
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2208 return 1;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2209
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2210 return 0;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2211 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2212
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2213 /* key-handling code is always ugly. It just ends up working out
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2214 that way.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2215
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2216 #### Most of the sticky-modifier code below is copied from similar
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2217 code in event-Xt.c. They should somehow or other be merged.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2218
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2219 Here are some pointers:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2220
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2221 -- DOWN_MASK indicates which modifiers should be treated as "down"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2222 when the corresponding upstroke happens. It gets reset for
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2223 a particular modifier when that modifier goes up, and reset
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2224 for all modifiers when a non-modifier key is pressed. Example:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2225
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2226 I press Control-A-Shift and then release Control-A-Shift.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2227 I want the Shift key to be sticky but not the Control key.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2228
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2229 -- If a modifier key is sticky, I can unstick it by pressing
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2230 the modifier key again. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2231
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2232 static WPARAM last_downkey;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2233 static int need_to_add_mask, down_mask;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2234
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2235 #define XEMSW_LCONTROL (1<<0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2236 #define XEMSW_RCONTROL (1<<1)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2237 #define XEMSW_LSHIFT (1<<2)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2238 #define XEMSW_RSHIFT (1<<3)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2239 #define XEMSW_LMENU (1<<4)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2240 #define XEMSW_RMENU (1<<5)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2241
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2242 static int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2243 mswindows_handle_sticky_modifiers (WPARAM wParam, LPARAM lParam,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2244 int downp, int keyp)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2245 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2246 int mods = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2247
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2248 if (!modifier_keys_are_sticky) /* Optimize for non-sticky modifiers */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2249 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2250
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2251 if (! (keyp &&
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2252 (wParam == VK_CONTROL || wParam == VK_LCONTROL ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2253 wParam == VK_RCONTROL ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2254 wParam == VK_MENU || wParam == VK_LMENU ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2255 wParam == VK_RMENU ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2256 wParam == VK_SHIFT || wParam == VK_LSHIFT ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2257 wParam == VK_RSHIFT)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2258 { /* Not a modifier key */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2259 if (downp && keyp && !last_downkey)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2260 last_downkey = wParam;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2261 /* If I hold press-and-release the Control key and then press
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2262 and hold down the right arrow, I want it to auto-repeat
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2263 Control-Right. On the other hand, if I do the same but
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2264 manually press the Right arrow a bunch of times, I want
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2265 to see one Control-Right and then a bunch of Rights.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2266 This means that we need to distinguish between an
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2267 auto-repeated key and a key pressed and released a bunch
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2268 of times. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2269 else if ((downp && !keyp) ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2270 (downp && keyp && last_downkey &&
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2271 (wParam != last_downkey ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2272 /* the "previous key state" bit indicates autorepeat */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2273 ! (lParam & (1 << 30)))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2274 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2275 need_to_add_mask = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2276 last_downkey = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2277 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2278 if (downp)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2279 down_mask = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2280
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2281 mods = need_to_add_mask;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2282 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2283 else /* Modifier key pressed */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2284 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2285 /* If a non-modifier key was pressed in the middle of a bunch
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2286 of modifiers, then it unsticks all the modifiers that were
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2287 previously pressed. We cannot unstick the modifiers until
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2288 now because we want to check for auto-repeat of the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2289 non-modifier key. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2290
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2291 if (last_downkey)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2292 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2293 last_downkey = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2294 need_to_add_mask = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2295 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2296
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2297 #define FROB(mask) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2298 do { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2299 if (downp && keyp) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2300 { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2301 /* If modifier key is already sticky, \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2302 then unstick it. Note that we do \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2303 not test down_mask to deal with the \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2304 unlikely but possible case that the \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2305 modifier key auto-repeats. */ \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2306 if (need_to_add_mask & mask) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2307 { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2308 need_to_add_mask &= ~mask; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2309 down_mask &= ~mask; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2310 } \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2311 else \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2312 down_mask |= mask; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2313 } \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2314 else \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2315 { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2316 if (down_mask & mask) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2317 { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2318 down_mask &= ~mask; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2319 need_to_add_mask |= mask; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2320 } \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2321 } \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2322 } while (0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2323
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2324 if ((wParam == VK_CONTROL && (lParam & 0x1000000))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2325 || wParam == VK_RCONTROL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2326 FROB (XEMSW_RCONTROL);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2327 if ((wParam == VK_CONTROL && !(lParam & 0x1000000))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2328 || wParam == VK_LCONTROL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2329 FROB (XEMSW_LCONTROL);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2330
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2331 if ((wParam == VK_SHIFT && (lParam & 0x1000000))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2332 || wParam == VK_RSHIFT)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2333 FROB (XEMSW_RSHIFT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2334 if ((wParam == VK_SHIFT && !(lParam & 0x1000000))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2335 || wParam == VK_LSHIFT)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2336 FROB (XEMSW_LSHIFT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2337
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2338 if ((wParam == VK_MENU && (lParam & 0x1000000))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2339 || wParam == VK_RMENU)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2340 FROB (XEMSW_RMENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2341 if ((wParam == VK_MENU && !(lParam & 0x1000000))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2342 || wParam == VK_LMENU)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2343 FROB (XEMSW_LMENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2344 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2345 #undef FROB
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2346
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2347 if (mods && downp)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2348 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2349 BYTE keymap[256];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2350
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2351 GetKeyboardState (keymap);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2352
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2353 if (mods & XEMSW_LCONTROL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2354 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2355 keymap [VK_CONTROL] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2356 keymap [VK_LCONTROL] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2357 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2358 if (mods & XEMSW_RCONTROL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2359 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2360 keymap [VK_CONTROL] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2361 keymap [VK_RCONTROL] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2362 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2363
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2364 if (mods & XEMSW_LSHIFT)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2365 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2366 keymap [VK_SHIFT] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2367 keymap [VK_LSHIFT] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2368 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2369 if (mods & XEMSW_RSHIFT)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2370 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2371 keymap [VK_SHIFT] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2372 keymap [VK_RSHIFT] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2373 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2374
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2375 if (mods & XEMSW_LMENU)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2376 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2377 keymap [VK_MENU] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2378 keymap [VK_LMENU] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2379 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2380 if (mods & XEMSW_RMENU)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2381 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2382 keymap [VK_MENU] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2383 keymap [VK_RMENU] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2384 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2385
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2386 SetKeyboardState (keymap);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2387 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2388 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2389
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2390 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2391 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2392
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2393 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2394 clear_sticky_modifiers (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2395 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2396 need_to_add_mask = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2397 last_downkey = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2398 down_mask = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2399 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2400
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2401 #ifdef DEBUG_XEMACS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2402
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2403 #if 0
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2404
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2405 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2406 output_modifier_keyboard_state (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2407 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2408 BYTE keymap[256];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2409
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2410 GetKeyboardState (keymap);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2411
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2412 stderr_out ("GetKeyboardState VK_MENU %d %d VK_LMENU %d %d VK_RMENU %d %d\n",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2413 keymap[VK_MENU] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2414 keymap[VK_MENU] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2415 keymap[VK_LMENU] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2416 keymap[VK_LMENU] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2417 keymap[VK_RMENU] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2418 keymap[VK_RMENU] & 0x1 ? 1 : 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2419 stderr_out ("GetKeyboardState VK_CONTROL %d %d VK_LCONTROL %d %d VK_RCONTROL %d %d\n",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2420 keymap[VK_CONTROL] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2421 keymap[VK_CONTROL] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2422 keymap[VK_LCONTROL] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2423 keymap[VK_LCONTROL] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2424 keymap[VK_RCONTROL] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2425 keymap[VK_RCONTROL] & 0x1 ? 1 : 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2426 stderr_out ("GetKeyboardState VK_SHIFT %d %d VK_LSHIFT %d %d VK_RSHIFT %d %d\n",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2427 keymap[VK_SHIFT] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2428 keymap[VK_SHIFT] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2429 keymap[VK_LSHIFT] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2430 keymap[VK_LSHIFT] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2431 keymap[VK_RSHIFT] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2432 keymap[VK_RSHIFT] & 0x1 ? 1 : 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2433 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2434
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2435 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2436
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2437 /* try to debug the stuck-alt-key problem.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2438
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2439 #### this happens only inconsistently, and may only happen when using
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2440 StickyKeys in the Win2000 accessibility section of the control panel,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2441 which is extremely broken for other reasons. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2443 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2444 output_alt_keyboard_state (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2445 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2446 BYTE keymap[256];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2447 SHORT keystate[3];
1242
f0af455e89d9 [xemacs-hg @ 2003-01-31 12:02:30 by stephent]
stephent
parents: 1204
diff changeset
2448 /* SHORT asyncstate[3]; */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2449
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2450 GetKeyboardState (keymap);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2451 keystate[0] = GetKeyState (VK_MENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2452 keystate[1] = GetKeyState (VK_LMENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2453 keystate[2] = GetKeyState (VK_RMENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2454 /* Doing this interferes with key processing. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2455 /* asyncstate[0] = GetAsyncKeyState (VK_MENU); */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2456 /* asyncstate[1] = GetAsyncKeyState (VK_LMENU); */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2457 /* asyncstate[2] = GetAsyncKeyState (VK_RMENU); */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2458
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2459 stderr_out ("GetKeyboardState VK_MENU %d %d VK_LMENU %d %d VK_RMENU %d %d\n",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2460 keymap[VK_MENU] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2461 keymap[VK_MENU] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2462 keymap[VK_LMENU] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2463 keymap[VK_LMENU] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2464 keymap[VK_RMENU] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2465 keymap[VK_RMENU] & 0x1 ? 1 : 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2466 stderr_out ("GetKeyState VK_MENU %d %d VK_LMENU %d %d VK_RMENU %d %d\n",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2467 keystate[0] & 0x8000 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2468 keystate[0] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2469 keystate[1] & 0x8000 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2470 keystate[1] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2471 keystate[2] & 0x8000 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2472 keystate[2] & 0x1 ? 1 : 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2473 /* stderr_out ("GetAsyncKeyState VK_MENU %d %d VK_LMENU %d %d VK_RMENU %d %d\n", */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2474 /* asyncstate[0] & 0x8000 ? 1 : 0, */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2475 /* asyncstate[0] & 0x1 ? 1 : 0, */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2476 /* asyncstate[1] & 0x8000 ? 1 : 0, */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2477 /* asyncstate[1] & 0x1 ? 1 : 0, */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2478 /* asyncstate[2] & 0x8000 ? 1 : 0, */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2479 /* asyncstate[2] & 0x1 ? 1 : 0); */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2480 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2481
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2482 #endif /* DEBUG_XEMACS */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2483
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2484
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2485 /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2486 * The windows procedure for the window class XEMACS_CLASS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2487 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2488 LRESULT WINAPI
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2489 mswindows_wnd_proc (HWND hwnd, UINT message_, WPARAM wParam, LPARAM lParam)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2490 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2491 /* Note: Remember to initialize emacs_event and event before use. This
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2492 code calls code that can GC. You must GCPRO before calling such
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2493 code. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2494 Lisp_Object emacs_event = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2495 Lisp_Object fobj = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2496
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2497 Lisp_Event *event;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2498 struct frame *frame;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
2499 struct mswindows_frame *msframe;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2500
3092
141c2920ea48 [xemacs-hg @ 2005-11-25 01:41:31 by crestani]
crestani
parents: 3025
diff changeset
2501 #ifndef NEW_GC
611
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 604
diff changeset
2502 /* If you hit this, rewrite the offending API call to occur after GC,
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 604
diff changeset
2503 using register_post_gc_action(). */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 604
diff changeset
2504 assert (!gc_in_progress);
3263
d674024a8674 [xemacs-hg @ 2006-02-27 16:29:00 by crestani]
crestani
parents: 3092
diff changeset
2505 #endif /* not NEW_GC */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2506
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2507 #ifdef DEBUG_XEMACS
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2508 if (debug_mswindows_events)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2509 debug_output_mswin_message (hwnd, message_, wParam, lParam);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2510 #endif /* DEBUG_XEMACS */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2511
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2512 assert (!qxeGetWindowLong (hwnd, GWL_USERDATA));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2513 switch (message_)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2514 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2515 case WM_DESTROYCLIPBOARD:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2516 mswindows_handle_destroyclipboard ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2517 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2518
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2519 case WM_ERASEBKGND:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2520 /* Erase background only during non-dynamic sizing */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2521 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2522 if (msframe->sizing && !mswindows_dynamic_frame_resize)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2523 goto defproc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2524 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2525
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2526 case WM_CLOSE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2527 fobj = mswindows_find_frame (hwnd);
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
2528 mswindows_enqueue_misc_user_event (fobj, Qeval, list3 (Qdelete_frame, fobj,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
2529 Qt));
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2530 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2531
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2532 case WM_KEYUP:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2533 case WM_SYSKEYUP:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2534
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2535 /* See Win95 comment under WM_KEYDOWN */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2536 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2537 BYTE keymap[256];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2538 int should_set_keymap = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2539
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2540 #ifdef DEBUG_XEMACS
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2541 if (debug_mswindows_events > 2)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2542 output_alt_keyboard_state ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2543 #endif /* DEBUG_XEMACS */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2544
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2545 mswindows_handle_sticky_modifiers (wParam, lParam, 0, 1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2546 if (wParam == VK_CONTROL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2547 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2548 GetKeyboardState (keymap);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2549 keymap [(lParam & 0x1000000) ? VK_RCONTROL : VK_LCONTROL] &= ~0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2550 should_set_keymap = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2551 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2552 else if (wParam == VK_MENU)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2553 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2554 GetKeyboardState (keymap);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2555 keymap [(lParam & 0x1000000) ? VK_RMENU : VK_LMENU] &= ~0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2556 should_set_keymap = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2557 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2558
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2559 if (should_set_keymap)
1242
f0af455e89d9 [xemacs-hg @ 2003-01-31 12:02:30 by stephent]
stephent
parents: 1204
diff changeset
2560 /* && (message_ != WM_SYSKEYUP */
f0af455e89d9 [xemacs-hg @ 2003-01-31 12:02:30 by stephent]
stephent
parents: 1204
diff changeset
2561 /* || NILP (Vmenu_accelerator_enabled))) */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2562 SetKeyboardState (keymap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2563
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2564 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2565
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2566 if (key_needs_default_processing_p (wParam))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2567 goto defproc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2568 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2569 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2570
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2571 case WM_KEYDOWN:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2572 case WM_SYSKEYDOWN:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2573
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2574 /* In some locales the right-hand Alt key is labelled AltGr. This key
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2575 * should produce alternative characters when combined with another key.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2576 * eg on a German keyboard pressing AltGr+q should produce '@'.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2577 * AltGr generates exactly the same keystrokes as LCtrl+RAlt. But if
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2578 * TranslateMessage() is called with *any* combination of Ctrl+Alt down,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2579 * it translates as if AltGr were down.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2580 * We get round this by removing all modifiers from the keymap before
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2581 * calling TranslateMessage() unless AltGr is *really* down. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2582 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2583 BYTE keymap_trans[256];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2584 BYTE keymap_orig[256];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2585 BYTE keymap_sticky[256];
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2586 /* WARNING: XEmacs code paths are far more subtle than you
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2587 think. In particular, QUIT checking will query and remove
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2588 events, including keyboard events, from the queue. (QUIT is
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2589 definitely invoked from TO_INTERNAL_FORMAT().) If we do
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2590 this recursively anywhere in the following code, it will
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2591 mess certain things up -- in particular, the OS-provided
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2592 sticky modifier code available as part of the accessibility
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2593 package.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2594
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2595 (Academic question: If QUIT checking is supposed to be
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2596 triggered only every 1/4 second, why is it getting
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2597 consistently triggered here? I saw the problem
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2598 consistently. Answer: It appears that, currently,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2599 sometimes the code to pump messages is wrapped with
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2600 begin_dont_check_for_quit() and sometimes it isn't. (####
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2601 FIX THIS SHIT!) cmdloop.c, for example, has it, but not
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2602 everywhere. The current games with avoiding QUIT mean that
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2603 the 1/4-second timer consistently fires while
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2604 dont_check_for_quit is set [which causes the quit check to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2605 get deferred but the flag is still on], and so the next
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2606 time it's unset and we call QUIT is *right here*.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2607
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2608 In my stderr-proc ws I majorly cleaned up the whole shit by
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2609 just wrapping all the entry points in dont_check_for_quit.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2610 This fixed the remaining bugs with C-g getting interpreted
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2611 wrong.)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2612
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2613 #### We should probably wrap this whole function in
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2614 begin_dont_check_for_quit(); but then we should set this
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2615 back to 0 when handling a menu callback, which gets invoked
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2616 from within this function, specifically from
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2617 DefWindowProc(). (We already do the latter in my new
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2618 stderr-proc ws, because in that ws next_event_internal()
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2619 calls begin_dont_check_for_quit(). */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2620
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2621 int count = begin_dont_check_for_quit ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2622 int has_AltGr = mswindows_current_layout_has_AltGr ();
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
2623 int mods = 0, mods_with_shift = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2624 int extendedp = lParam & 0x1000000;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2625 Lisp_Object keysym;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2626 int sticky_changed;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2627
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2628 #ifdef DEBUG_XEMACS
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2629 if (debug_mswindows_events > 2)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2630 output_alt_keyboard_state ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2631 #endif /* DEBUG_XEMACS */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2632
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2633 GetKeyboardState (keymap_orig);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2634 frame = XFRAME (mswindows_find_frame (hwnd));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2635 if ((sticky_changed =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2636 mswindows_handle_sticky_modifiers (wParam, lParam, 1, 1)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2637 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2638 GetKeyboardState (keymap_sticky);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2639 if (keymap_sticky[VK_MENU] & 0x80)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2640 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2641 message_ = WM_SYSKEYDOWN;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2642 /* We have to set the "context bit" so that the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2643 TranslateMessage() call below that generates the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2644 SYSCHAR message does its thing; see the documentation
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2645 on WM_SYSKEYDOWN */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2646 lParam |= 1 << 29;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2647 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2648 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2649 else
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2650 memcpy (keymap_sticky, keymap_orig, 256);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2651
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2652 mods = mswindows_modifier_state (keymap_sticky, (DWORD) -1, has_AltGr);
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
2653 mods_with_shift = mods;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2654
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2655 /* Handle non-printables */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2656 if (!NILP (keysym = mswindows_key_to_emacs_keysym (wParam, mods,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2657 extendedp)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2658 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2659 mswindows_enqueue_keypress_event (hwnd, keysym, mods);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2660 if (sticky_changed)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2661 SetKeyboardState (keymap_orig);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2662 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2663 else /* Normal keys & modifiers */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2664 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2665 POINT pnt = { LOWORD (GetMessagePos()), HIWORD (GetMessagePos()) };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2666 MSG msg, tranmsg;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2667 #ifdef HAVE_MENUBARS
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2668 int potential_accelerator = 0;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2669 #endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2670 int got_accelerator = 0;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2671 /* No need to gcpro because the event is already on a
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2672 queue when we retrieve it. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2673 Lisp_Object lastev = Qnil;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2674
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2675 msg.hwnd = hwnd;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2676 msg.message = message_;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2677 msg.wParam = wParam;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2678 msg.lParam = lParam;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2679 msg.time = GetMessageTime();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2680 msg.pt = pnt;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2681
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2682 /* GetKeyboardState() does not work as documented on Win95. We have
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2683 * to loosely track Left and Right modifiers on behalf of the OS,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2684 * without screwing up Windows NT which tracks them properly. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2685 if (wParam == VK_CONTROL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2686 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2687 keymap_orig[extendedp ? VK_RCONTROL : VK_LCONTROL] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2688 keymap_sticky[extendedp ? VK_RCONTROL : VK_LCONTROL] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2689 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2690 else if (wParam == VK_MENU)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2691 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2692 keymap_orig[extendedp ? VK_RMENU : VK_LMENU] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2693 keymap_sticky[extendedp ? VK_RMENU : VK_LMENU] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2694 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2695
827
28426972f654 [xemacs-hg @ 2002-05-06 14:14:33 by jhar]
jhar
parents: 826
diff changeset
2696 #ifdef HAVE_MENUBARS
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2697 if (!NILP (Vmenu_accelerator_enabled) &&
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2698 !(mods & XEMACS_MOD_SHIFT) && message_ == WM_SYSKEYDOWN)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2699 potential_accelerator = 1;
827
28426972f654 [xemacs-hg @ 2002-05-06 14:14:33 by jhar]
jhar
parents: 826
diff changeset
2700 #endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2701
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2702 /* Remove shift modifier from an ascii character */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2703 mods &= ~XEMACS_MOD_SHIFT;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2704
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2705 memcpy (keymap_trans, keymap_sticky, 256);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2706
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2707 /* Clear control and alt modifiers unless AltGr is pressed */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2708 keymap_trans[VK_RCONTROL] = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2709 keymap_trans[VK_LMENU] = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2710 if (!has_AltGr || !(keymap_trans[VK_LCONTROL] & 0x80)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2711 || !(keymap_trans[VK_RMENU] & 0x80))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2712 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2713 keymap_trans[VK_LCONTROL] = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2714 keymap_trans[VK_CONTROL] = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2715 keymap_trans[VK_RMENU] = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2716 keymap_trans[VK_MENU] = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2717 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2718 SetKeyboardState (keymap_trans);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2719
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2720 /* Maybe generate some WM_[SYS]CHARs in the queue */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2721 TranslateMessage (&msg);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2722
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2723 while (qxePeekMessage (&tranmsg, hwnd, WM_CHAR, WM_CHAR, PM_REMOVE)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2724 || qxePeekMessage (&tranmsg, hwnd, WM_SYSCHAR, WM_SYSCHAR,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2725 PM_REMOVE))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2726 {
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
2727 int mods_with_quit = mods;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2728 int length;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2729 Extbyte extchar[4];
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 856
diff changeset
2730 Ibyte *intchar;
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 856
diff changeset
2731 Ichar ch;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2732
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2733 if (XEUNICODE_P)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2734 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2735 length = unicode_char_to_text (tranmsg.wParam, extchar);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2736 TO_INTERNAL_FORMAT (DATA, (extchar, length),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2737 C_STRING_ALLOCA, (intchar),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2738 Qmswindows_unicode);
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 856
diff changeset
2739 ch = itext_ichar (intchar);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2740 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2741 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2742 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2743 length = ansi_char_to_text (tranmsg.wParam, extchar);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2744 intchar = (convert_multibyte_to_internal_malloc
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2745 (extchar, length,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2746 mswindows_locale_to_code_page
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2747 /* See intl-win32.c for an explanation of
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2748 the following */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2749 ((LCID) GetKeyboardLayout (0) & 0xFFFF),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2750 NULL));
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 856
diff changeset
2751 ch = itext_ichar (intchar);
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1687
diff changeset
2752 xfree (intchar, Ibyte *);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2753 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2754
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2755 #ifdef DEBUG_XEMACS
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2756 if (debug_mswindows_events)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2757 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2758 stderr_out ("-> ");
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2759 debug_output_mswin_message (tranmsg.hwnd, tranmsg.message,
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2760 tranmsg.wParam,
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2761 tranmsg.lParam);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2762 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2763 #endif /* DEBUG_XEMACS */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2764
827
28426972f654 [xemacs-hg @ 2002-05-06 14:14:33 by jhar]
jhar
parents: 826
diff changeset
2765 #ifdef HAVE_MENUBARS
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2766 if (potential_accelerator && !got_accelerator &&
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2767 mswindows_char_is_accelerator (frame, ch))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2768 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2769 got_accelerator = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2770 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2771 }
827
28426972f654 [xemacs-hg @ 2002-05-06 14:14:33 by jhar]
jhar
parents: 826
diff changeset
2772 #endif /* HAVE_MENUBARS */
28426972f654 [xemacs-hg @ 2002-05-06 14:14:33 by jhar]
jhar
parents: 826
diff changeset
2773
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2774 lastev = mswindows_enqueue_keypress_event (hwnd,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2775 make_char (ch),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2776 mods_with_quit);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2777 } /* while */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2778
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2779 /* Also figure out what the character would be in other
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2780 possible keyboard layouts, in this order:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2781
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2782 -- current language environment
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2783 -- user default language environment
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2784 -- system default language environment
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2785 -- same three, but checking the underlying virtual key,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2786 and only paying attention if it's alphabetic
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2787 -- US ASCII
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2788
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2789 See events.h, struct key_data, for why we do this.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2790 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2791
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2792 if (!NILP (lastev))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2793 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2794 int i;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2795 int scan = (lParam >> 16) && 0xFF;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2796
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2797 for (i = 0; i < KEYCHAR_LAST; i++)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2798 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2799 int vk_only = 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2800 LCID lcid;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2801 int virtual_key;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2802
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2803 switch (i)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2804 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2805 case KEYCHAR_UNDERLYING_VIRTUAL_KEY_CURRENT_LANGENV:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2806 vk_only = 1;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2807 case KEYCHAR_CURRENT_LANGENV:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2808 lcid = mswindows_current_locale ();
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2809 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2810
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2811 case KEYCHAR_UNDERLYING_VIRTUAL_KEY_DEFAULT_USER:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2812 vk_only = 1;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2813 case KEYCHAR_DEFAULT_USER:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2814 lcid = GetUserDefaultLCID ();
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2815 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2816
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2817 case KEYCHAR_UNDERLYING_VIRTUAL_KEY_DEFAULT_SYSTEM:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2818 vk_only = 1;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2819 case KEYCHAR_DEFAULT_SYSTEM:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2820 lcid = GetSystemDefaultLCID ();
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2821 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2822
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2823 case KEYCHAR_QWERTY:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2824 lcid = MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH_US);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2825 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2826
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2421
diff changeset
2827 default: ABORT (); lcid = 0;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2828 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2829
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2830 /* VERY CONFUSING! See intl-win32.c. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2831 lcid = lcid & 0xFFFF;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2832
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
2833 virtual_key = qxeMapVirtualKeyEx (scan, 1, (HKL) lcid);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2834 if (!vk_only)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2835 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2836 if (XEUNICODE_P)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2837 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2838 Extbyte received_keys[32];
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2839 int tounret =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2840 ToUnicodeEx
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2841 (virtual_key, scan, keymap_trans,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2842 (LPWSTR) received_keys,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2843 sizeof (received_keys) / XETCHAR_SIZE,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2844 0, /* #### what about this flag? "if
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2845 bit 0 is set, a menu is
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2846 active???" */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2847 (HKL) lcid);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2848 if (tounret > 0)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2849 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 856
diff changeset
2850 Ibyte *intchar;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2851
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2852 TO_INTERNAL_FORMAT
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2853 (DATA,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2854 (received_keys + (tounret - 1) * 2, 2),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2855 C_STRING_ALLOCA, intchar,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2856 Qmswindows_unicode);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2857 XSET_EVENT_KEY_ALT_KEYCHARS
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2858 (lastev, i, itext_ichar (intchar));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2859 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2860 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2861 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2862 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2863 WORD received_keys[32];
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2864 int tounret =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2865 ToAsciiEx (virtual_key, scan, keymap_trans,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2866 received_keys,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2867 0, /* #### what about this
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2868 flag? "if bit 0 is set, a
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2869 menu is active???" */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2870 (HKL) lcid);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2871 if (tounret > 0)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2872 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2873 /* #### I cannot find proper
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2874 documentation on what format the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2875 return value is in. I'm assuming
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2876 it's like WM_IME_CHAR: DBCS chars
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2877 have the lead byte in bits 8-15 of
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2878 the short. */
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 856
diff changeset
2879 Ibyte *intchar;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2880 Extbyte mbstuff[2];
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2881 Bytecount mblength = 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2882 WORD thechar = received_keys[tounret - 1];
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2883
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2884 mbstuff[mblength++] =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2885 (Extbyte) (thechar & 0xFF);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2886 if (thechar > 0xFF)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2887 mbstuff[mblength++] =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2888 (Extbyte) ((thechar >> 8) & 0xFF);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2889
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2890 intchar = convert_multibyte_to_internal_malloc
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2891 (mbstuff, mblength,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2892 mswindows_locale_to_code_page (lcid),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2893 NULL);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2894
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2895 XSET_EVENT_KEY_ALT_KEYCHARS
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2896 (lastev, i, itext_ichar (intchar));
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1687
diff changeset
2897 xfree (intchar, Ibyte *);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2898 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2899 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2900 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2901 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2902 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 856
diff changeset
2903 Ichar altch;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2904
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2905 if (virtual_key >= 'A' && virtual_key <= 'Z')
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2906 altch =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2907 virtual_key + (mods_with_shift & XEMACS_MOD_SHIFT ?
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2908 'a' - 'A' : 0);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2909 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2910 altch = 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2911
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
2912 XSET_EVENT_KEY_ALT_KEYCHARS (lastev, i, altch);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2913 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2914 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2915 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2916
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2917 /* This generates WM_SYSCHAR messages, which are interpreted
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2918 by DefWindowProc as the menu selections. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2919 if (got_accelerator)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2920 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2921 SetKeyboardState (keymap_sticky);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2922 TranslateMessage (&msg);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2923 SetKeyboardState (keymap_orig);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2924 unbind_to (count);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2925 goto defproc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2926 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2927
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2928 SetKeyboardState (keymap_orig);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2929 } /* else */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2930
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2931 if (key_needs_default_processing_p (wParam))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2932 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2933 unbind_to (count);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2934 goto defproc;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2935 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2936 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2937 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2938 unbind_to (count);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2939 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2940 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2941 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2942
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2943 case WM_MBUTTONDOWN:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2944 case WM_MBUTTONUP:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2945 /* Real middle mouse button has nothing to do with emulated one:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2946 if one wants to exercise fingers playing chords on the mouse,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2947 he is allowed to do that! */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2948 mswindows_enqueue_mouse_button_event (hwnd, message_,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
2949 XE_MAKEPOINTS (lParam),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2950 wParam &~ MK_MBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2951 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2952 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2953
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2954 case WM_LBUTTONUP:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2955 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2956 msframe->last_click_time = GetMessageTime();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2957
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2958 KillTimer (hwnd, BUTTON_2_TIMER_ID);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2959 msframe->button2_need_lbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2960 if (msframe->ignore_next_lbutton_up)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2961 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2962 msframe->ignore_next_lbutton_up = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2963 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2964 else if (msframe->button2_is_down)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2965 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2966 msframe->button2_is_down = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2967 msframe->ignore_next_rbutton_up = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2968 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONUP,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
2969 XE_MAKEPOINTS (lParam),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2970 wParam
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2971 &~ (MK_LBUTTON | MK_MBUTTON
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2972 | MK_RBUTTON),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2973 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2974 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2975 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2976 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2977 if (msframe->button2_need_rbutton)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2978 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2979 msframe->button2_need_rbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2980 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
2981 XE_MAKEPOINTS (lParam),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2982 wParam &~ MK_LBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2983 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2984 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2985 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONUP,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
2986 XE_MAKEPOINTS (lParam),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2987 wParam &~ MK_LBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2988 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2989 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2990 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2991
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2992 case WM_RBUTTONUP:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2993 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2994 msframe->last_click_time = GetMessageTime();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2995
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2996 KillTimer (hwnd, BUTTON_2_TIMER_ID);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2997 msframe->button2_need_rbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2998 if (msframe->ignore_next_rbutton_up)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2999 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3000 msframe->ignore_next_rbutton_up = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3001 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3002 else if (msframe->button2_is_down)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3003 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3004 msframe->button2_is_down = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3005 msframe->ignore_next_lbutton_up = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3006 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONUP,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3007 XE_MAKEPOINTS (lParam),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3008 wParam
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3009 &~ (MK_LBUTTON | MK_MBUTTON
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3010 | MK_RBUTTON),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3011 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3012 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3013 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3014 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3015 if (msframe->button2_need_lbutton)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3016 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3017 msframe->button2_need_lbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3018 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3019 XE_MAKEPOINTS (lParam),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3020 wParam &~ MK_RBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3021 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3022 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3023 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONUP,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3024 XE_MAKEPOINTS (lParam),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3025 wParam &~ MK_RBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3026 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3027 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3028 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3029
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3030 case WM_LBUTTONDOWN:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3031 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3032
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3033 if (msframe->button2_need_lbutton)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3034 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3035 KillTimer (hwnd, BUTTON_2_TIMER_ID);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3036 msframe->button2_need_lbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3037 msframe->button2_need_rbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3038 if (mswindows_button2_near_enough (msframe->last_click_point,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3039 XE_MAKEPOINTS (lParam)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3040 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3041 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONDOWN,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3042 XE_MAKEPOINTS (lParam),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3043 wParam
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3044 &~ (MK_LBUTTON | MK_MBUTTON
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3045 | MK_RBUTTON),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3046 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3047 msframe->button2_is_down = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3048 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3049 else
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3050 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3051 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3052 msframe->last_click_point,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3053 msframe->last_click_mods
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3054 &~ MK_RBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3055 msframe->last_click_time);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3056 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3057 XE_MAKEPOINTS (lParam),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3058 wParam &~ MK_LBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3059 GetMessageTime());
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3060 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3061 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3062 else
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3063 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3064 mswindows_set_chord_timer (hwnd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3065 msframe->button2_need_rbutton = 1;
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3066 msframe->last_click_point = XE_MAKEPOINTS (lParam);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3067 msframe->last_click_mods = wParam;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3068 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3069 msframe->last_click_time = GetMessageTime();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3070 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3071
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3072 case WM_RBUTTONDOWN:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3073 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3074
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3075 if (msframe->button2_need_rbutton)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3076 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3077 KillTimer (hwnd, BUTTON_2_TIMER_ID);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3078 msframe->button2_need_lbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3079 msframe->button2_need_rbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3080 if (mswindows_button2_near_enough (msframe->last_click_point,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3081 XE_MAKEPOINTS (lParam)))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3082 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3083 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONDOWN,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3084 XE_MAKEPOINTS (lParam),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3085 wParam
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3086 &~ (MK_LBUTTON | MK_MBUTTON
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3087 | MK_RBUTTON),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3088 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3089 msframe->button2_is_down = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3090 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3091 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3092 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3093 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3094 msframe->last_click_point,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3095 msframe->last_click_mods
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3096 &~ MK_LBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3097 msframe->last_click_time);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3098 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3099 XE_MAKEPOINTS (lParam),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3100 wParam &~ MK_RBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3101 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3102 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3103 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3104 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3105 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3106 mswindows_set_chord_timer (hwnd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3107 msframe->button2_need_lbutton = 1;
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3108 msframe->last_click_point = XE_MAKEPOINTS (lParam);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3109 msframe->last_click_mods = wParam;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3110 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3111 msframe->last_click_time = GetMessageTime();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3112 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3113
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3114 case WM_TIMER:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3115 if (wParam == BUTTON_2_TIMER_ID)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3116 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3117 msframe =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3118 FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3119 KillTimer (hwnd, BUTTON_2_TIMER_ID);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3120
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3121 if (msframe->button2_need_lbutton)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3122 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3123 msframe->button2_need_lbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3124 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3125 msframe->last_click_point,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3126 msframe->last_click_mods
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3127 &~ MK_RBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3128 msframe->last_click_time);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3129 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3130 else if (msframe->button2_need_rbutton)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3131 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3132 msframe->button2_need_rbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3133 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3134 msframe->last_click_point,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3135 msframe->last_click_mods
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3136 &~ MK_LBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3137 msframe->last_click_time);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3138 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3139 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3140 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3141 assert ("Spurious timer fired" == 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3142 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3143
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3144 case WM_MOUSEMOVE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3145 /* Optimization: don't report mouse movement while size is changing */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3146 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3147 if (!msframe->sizing)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3148 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3149 /* When waiting for the second mouse button to finish
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3150 button2 emulation, and have moved too far, just pretend
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3151 as if timer has expired. This improves drag-select feedback */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3152 if ((msframe->button2_need_lbutton || msframe->button2_need_rbutton)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3153 && !mswindows_button2_near_enough (msframe->last_click_point,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3154 XE_MAKEPOINTS (lParam)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3155 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3156 KillTimer (hwnd, BUTTON_2_TIMER_ID);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3157 qxeSendMessage (hwnd, WM_TIMER, BUTTON_2_TIMER_ID, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3158 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3159
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3160 emacs_event = Fmake_event (Qnil, Qnil);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3161 event = XEVENT(emacs_event);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3162
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
3163 XSET_EVENT_CHANNEL (emacs_event, mswindows_find_frame(hwnd));
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
3164 XSET_EVENT_TIMESTAMP (emacs_event, GetMessageTime());
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
3165 XSET_EVENT_TYPE (emacs_event, pointer_motion_event);
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3166 XSET_EVENT_MOTION_X (emacs_event, XE_MAKEPOINTS (lParam).x);
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3167 XSET_EVENT_MOTION_Y (emacs_event, XE_MAKEPOINTS (lParam).y);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
3168 XSET_EVENT_MOTION_MODIFIERS (emacs_event,
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
3169 mswindows_modifier_state (NULL, wParam, 0));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3170
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3171 mswindows_enqueue_dispatch_event (emacs_event);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3172 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3173 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3174
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3175 case WM_CANCELMODE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3176 ReleaseCapture ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3177 /* Queue a `cancel-mode-internal' misc user event, so mouse
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3178 selection would be canceled if any */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3179 mswindows_enqueue_misc_user_event (mswindows_find_frame (hwnd),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3180 Qcancel_mode_internal, Qnil);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3181 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3182
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3183 case WM_NOTIFY:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3184 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
3185 LPNMHDR nmhdr = (LPNMHDR) lParam;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
3186
1111
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 986
diff changeset
3187 if (nmhdr->code == TTN_NEEDTEXT)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3188 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3189 #ifdef HAVE_TOOLBARS
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3190 LPTOOLTIPTEXTW tttextw = (LPTOOLTIPTEXTW) lParam;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3191 Lisp_Object btext;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3192 Extbyte *btextext = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3193
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3194 /* find out which toolbar */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3195 frame = XFRAME (mswindows_find_frame (hwnd));
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
3196 btext = mswindows_get_toolbar_button_text (frame, nmhdr->idFrom);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3197
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3198 tttextw->hinst = NULL;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3199
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3200 if (!NILP (btext))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3201 LISP_STRING_TO_TSTR (btext, btextext);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3202
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3203 if (btextext)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3204 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3205 /* WARNING: We can't just write a '\0' into the 79th
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3206 "character" because tttextw->szText is in WCHAR's but we
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3207 may be copying an ANSI string into it. Easiest to just
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3208 zero the whole thing. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3209 xzero (*tttextw->szText);
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2367
diff changeset
3210 qxetcsncpy ((Extbyte *) tttextw->szText, btextext, 79);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3211 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3212 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3213 tttextw->lpszText = NULL;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3214 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3215 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3216 /* handle tree view callbacks */
1111
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 986
diff changeset
3217 else if (nmhdr->code == TVN_SELCHANGED)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3218 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
3219 NM_TREEVIEW *ptree = (NM_TREEVIEW *) lParam;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3220 frame = XFRAME (mswindows_find_frame (hwnd));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3221 mswindows_handle_gui_wm_command (frame, 0, ptree->itemNew.lParam);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3222 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3223 /* handle tab control callbacks */
1111
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 986
diff changeset
3224 else if (nmhdr->code == TCN_SELCHANGE)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3225 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3226 TC_ITEM item;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3227 int idx = qxeSendMessage (nmhdr->hwndFrom, TCM_GETCURSEL, 0, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3228 frame = XFRAME (mswindows_find_frame (hwnd));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3229
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3230 item.mask = TCIF_PARAM;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3231 qxeSendMessage (nmhdr->hwndFrom, TCM_GETITEM, (WPARAM) idx,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3232 (LPARAM) &item);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3233
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3234 mswindows_handle_gui_wm_command (frame, 0, item.lParam);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3235 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3236 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3237 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3238
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3239 case WM_PAINT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3240 /* hdc will be NULL unless this is a subwindow - in which case we
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3241 shouldn't have received a paint message for it here. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3242 assert (wParam == 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3243
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3244 /* Can't queue a magic event because windows goes modal and sends paint
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3245 messages directly to the windows procedure when doing solid drags
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3246 and the message queue doesn't get processed. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3247 mswindows_handle_paint (XFRAME (mswindows_find_frame (hwnd)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3248 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3249
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3250 case WM_ACTIVATE:
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3251 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3252 /*
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3253 * If we receive a WM_ACTIVATE message that indicates that our frame
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3254 * is being activated, make sure that the frame is marked visible
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3255 * if the window itself is visible. This seems to fix the problem
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3256 * where XEmacs appears to lock-up after switching desktops with
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3257 * some virtual window managers.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3258 */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3259 int state = (int)(short) LOWORD(wParam);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3260 #ifdef DEBUG_XEMACS
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3261 if (debug_mswindows_events)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3262 stderr_out("state = %d\n", state);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3263 #endif /* DEBUG_XEMACS */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3264 if (state == WA_ACTIVE || state == WA_CLICKACTIVE)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3265 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3266 #ifdef DEBUG_XEMACS
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3267 if (debug_mswindows_events)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3268 stderr_out(" activating\n");
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3269 #endif /* DEBUG_XEMACS */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3270
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3271 fobj = mswindows_find_frame (hwnd);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3272 frame = XFRAME (fobj);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3273 if (IsWindowVisible (hwnd))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3274 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3275 #ifdef DEBUG_XEMACS
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3276 if (debug_mswindows_events)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3277 stderr_out(" window is visible\n");
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3278 #endif /* DEBUG_XEMACS */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3279 if (!FRAME_VISIBLE_P (frame))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3280 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3281 #ifdef DEBUG_XEMACS
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3282 if (debug_mswindows_events)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3283 stderr_out(" frame is not visible\n");
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3284 #endif /* DEBUG_XEMACS */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3285 /*
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3286 * It seems that we have to enqueue the XM_MAPFRAME event
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3287 * prior to setting the frame visible so that
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3288 * suspend-or-iconify-emacs works properly.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3289 */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3290 mswindows_enqueue_magic_event (hwnd, XM_MAPFRAME);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3291 FRAME_VISIBLE_P (frame) = 1;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3292 FRAME_ICONIFIED_P (frame) = 0;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3293 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3294 #ifdef DEBUG_XEMACS
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3295 else
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3296 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3297 if (debug_mswindows_events)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3298 stderr_out(" frame is visible\n");
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3299 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3300 #endif /* DEBUG_XEMACS */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3301 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3302 #ifdef DEBUG_XEMACS
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3303 else
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3304 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3305 if (debug_mswindows_events)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3306 stderr_out(" window is not visible\n");
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3307 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3308 #endif /* DEBUG_XEMACS */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3309 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3310 return qxeDefWindowProc (hwnd, message_, wParam, lParam);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3311 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3312 break;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3313
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3314 case WM_WINDOWPOSCHANGED:
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3315 /* This is sent before WM_SIZE; in fact, the processing of this
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3316 by DefWindowProc() sends WM_SIZE. But WM_SIZE is not sent when
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3317 a window is hidden (make-frame-invisible), so we need to process
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3318 this and update the state flags. */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3319 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3320 fobj = mswindows_find_frame (hwnd);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3321 frame = XFRAME (fobj);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3322 if (IsIconic (hwnd))
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3323 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3324 FRAME_VISIBLE_P (frame) = 0;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3325 FRAME_ICONIFIED_P (frame) = 1;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3326 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3327 else if (IsWindowVisible (hwnd))
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3328 {
707
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
3329 /* APA: It's too early here to set the frame visible.
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
3330 * Let's do this later, in WM_SIZE processing, after the
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
3331 * magic XM_MAPFRAME event has been sent (just like 21.1
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
3332 * did). */
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
3333 /* FRAME_VISIBLE_P (frame) = 1; */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3334 FRAME_ICONIFIED_P (frame) = 0;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3335 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3336 else
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3337 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3338 FRAME_VISIBLE_P (frame) = 0;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3339 FRAME_ICONIFIED_P (frame) = 0;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3340 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3341
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3342 goto defproc;
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3343 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
3344
731
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3345 case WM_SHOWWINDOW:
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3346 /*
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3347 The WM_SHOWWINDOW message is sent to a window when the window
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3348 is about to be hidden or shown.
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3349 APA: This message is also sent when switching to a virtual
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3350 desktop under the virtuawin virtual window manager.
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3351
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3352 */
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3353 {
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3354 fobj = mswindows_find_frame (hwnd);
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3355 frame = XFRAME (fobj);
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3356 if (wParam == TRUE)
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3357 {
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3358 mswindows_enqueue_magic_event (hwnd, XM_MAPFRAME);
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3359 FRAME_VISIBLE_P (frame) = 1;
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3360 }
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3361 else
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3362 {
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3363 mswindows_enqueue_magic_event (hwnd, XM_UNMAPFRAME);
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3364 FRAME_VISIBLE_P (frame) = 0;
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3365 }
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3366 }
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3367 break;
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
3368
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3369 case WM_SIZE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3370 /* We only care about this message if our size has really changed */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3371 if (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED ||
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3372 wParam == SIZE_MINIMIZED)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3373 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3374 RECT rect;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3375 int columns, rows;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3376
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3377 fobj = mswindows_find_frame (hwnd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3378 frame = XFRAME (fobj);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3379 msframe = FRAME_MSWINDOWS_DATA (frame);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3380
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3381 /* We cannot handle frame map and unmap hooks right in
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3382 this routine, because these may throw. We queue
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3383 magic events to run these hooks instead - kkm */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3384
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3385 if (wParam == SIZE_MINIMIZED)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3386 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3387 /* Iconified */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3388 mswindows_enqueue_magic_event (hwnd, XM_UNMAPFRAME);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3389 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3390 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3391 {
1279
cd0abfdb9e9d [xemacs-hg @ 2003-02-09 09:33:42 by ben]
ben
parents: 1268
diff changeset
3392 GetClientRect (hwnd, &rect);
cd0abfdb9e9d [xemacs-hg @ 2003-02-09 09:33:42 by ben]
ben
parents: 1268
diff changeset
3393 FRAME_PIXWIDTH (frame) = rect.right;
cd0abfdb9e9d [xemacs-hg @ 2003-02-09 09:33:42 by ben]
ben
parents: 1268
diff changeset
3394 FRAME_PIXHEIGHT (frame) = rect.bottom;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3395
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3396 pixel_to_real_char_size (frame, rect.right, rect.bottom,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3397 &FRAME_MSWINDOWS_CHARWIDTH (frame),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3398 &FRAME_MSWINDOWS_CHARHEIGHT (frame));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3399
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3400 pixel_to_char_size (frame, rect.right, rect.bottom, &columns,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3401 &rows);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3402 change_frame_size (frame, rows, columns, 1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3403
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3404 /* If we are inside frame creation, we have to apply geometric
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3405 properties now. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3406 if (FRAME_MSWINDOWS_TARGET_RECT (frame))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3407 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3408 /* Yes, we have to size again */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3409 mswindows_size_frame_internal (frame,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3410 FRAME_MSWINDOWS_TARGET_RECT
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3411 (frame));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3412 /* Reset so we do not get here again. The SetWindowPos
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3413 * call in mswindows_size_frame_internal can cause
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3414 * recursion here. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3415 if (FRAME_MSWINDOWS_TARGET_RECT (frame))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3416 {
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1687
diff changeset
3417 xfree (FRAME_MSWINDOWS_TARGET_RECT (frame),
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1687
diff changeset
3418 XEMACS_RECT_WH *);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3419 FRAME_MSWINDOWS_TARGET_RECT (frame) = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3420 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3421 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3422 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3423 {
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3424 if (!msframe->sizing && !FRAME_VISIBLE_P (frame))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3425 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3426 mswindows_enqueue_magic_event (hwnd, XM_MAPFRAME);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3427 /* APA: Now that the magic XM_MAPFRAME event has
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3428 * been sent we can mark the frame as visible (just
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3429 * like 21.1 did). */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3430 FRAME_VISIBLE_P (frame) = 1;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
3431 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3432
1279
cd0abfdb9e9d [xemacs-hg @ 2003-02-09 09:33:42 by ben]
ben
parents: 1268
diff changeset
3433 if (frame->init_finished &&
cd0abfdb9e9d [xemacs-hg @ 2003-02-09 09:33:42 by ben]
ben
parents: 1268
diff changeset
3434 (!msframe->sizing || mswindows_dynamic_frame_resize))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3435 redisplay ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3436 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3437 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3438 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3439 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3440
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3441 case WM_DISPLAYCHANGE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3442 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3443 struct device *d;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3444 DWORD message_tick = GetMessageTime ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3445
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3446 fobj = mswindows_find_frame (hwnd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3447 frame = XFRAME (fobj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3448 d = XDEVICE (FRAME_DEVICE (frame));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3449
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3450 /* Do this only once per message. XEmacs can receive this message
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3451 through as many frames as it currently has open. Message time
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3452 will be the same for all these messages. Despite extreme
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3453 efficiency, the code below has about one in 4 billion
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3454 probability that the HDC is not recreated, provided that
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3455 XEmacs is running sufficiently longer than 52 days. */
1279
cd0abfdb9e9d [xemacs-hg @ 2003-02-09 09:33:42 by ben]
ben
parents: 1268
diff changeset
3456 if (DEVICE_MSWINDOWS_UPDATE_TICK (d) != message_tick)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3457 {
1279
cd0abfdb9e9d [xemacs-hg @ 2003-02-09 09:33:42 by ben]
ben
parents: 1268
diff changeset
3458 DEVICE_MSWINDOWS_UPDATE_TICK (d) = message_tick;
cd0abfdb9e9d [xemacs-hg @ 2003-02-09 09:33:42 by ben]
ben
parents: 1268
diff changeset
3459 DeleteDC (DEVICE_MSWINDOWS_HCDC (d));
cd0abfdb9e9d [xemacs-hg @ 2003-02-09 09:33:42 by ben]
ben
parents: 1268
diff changeset
3460 DEVICE_MSWINDOWS_HCDC (d) = CreateCompatibleDC (NULL);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3461 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3462 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3463 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3464
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3465 /* Misc magic events which only require that the frame be identified */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3466 case WM_SETFOCUS:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3467 case WM_KILLFOCUS:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3468 mswindows_enqueue_magic_event (hwnd, message_);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3469 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3470
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3471 case WM_WINDOWPOSCHANGING:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3472 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3473 WINDOWPOS *wp = (LPWINDOWPOS) lParam;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3474 WINDOWPLACEMENT wpl = { sizeof(WINDOWPLACEMENT) };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3475 GetWindowPlacement(hwnd, &wpl);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3476
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3477 /* Only interested if size is changing and we're not being iconified */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3478 if (wpl.showCmd != SW_SHOWMINIMIZED
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3479 && wpl.showCmd != SW_SHOWMAXIMIZED
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3480 && !(wp->flags & SWP_NOSIZE))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3481 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3482 RECT ncsize = { 0, 0, 0, 0 };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3483 int pixwidth, pixheight;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3484 AdjustWindowRectEx (&ncsize, qxeGetWindowLong (hwnd, GWL_STYLE),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3485 GetMenu(hwnd) != NULL,
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3486 qxeGetWindowLong (hwnd, GWL_EXSTYLE));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3487
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3488 round_size_to_real_char (XFRAME (mswindows_find_frame (hwnd)),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3489 wp->cx - (ncsize.right - ncsize.left),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3490 wp->cy - (ncsize.bottom - ncsize.top),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3491 &pixwidth, &pixheight);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3492
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3493 /* Convert client sizes to window sizes */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3494 pixwidth += (ncsize.right - ncsize.left);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3495 pixheight += (ncsize.bottom - ncsize.top);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3496
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3497 if (wpl.showCmd != SW_SHOWMAXIMIZED)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3498 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3499 /* Adjust so that the bottom or right doesn't move if it's
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3500 * the top or left that's being changed */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3501 RECT rect;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3502 GetWindowRect (hwnd, &rect);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3503
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3504 if (rect.left != wp->x)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3505 wp->x += wp->cx - pixwidth;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3506 if (rect.top != wp->y)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3507 wp->y += wp->cy - pixheight;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3508 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3509
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3510 wp->cx = pixwidth;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3511 wp->cy = pixheight;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3512 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3513 /* DefWindowProc sends useful WM_GETMINMAXINFO message, and adjusts
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3514 window position if the user tries to track window too small */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3515 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3516 goto defproc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3517
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3518 case WM_ENTERSIZEMOVE:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3519 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3520 msframe->sizing = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3521 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3522
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3523 case WM_EXITSIZEMOVE:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3524 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3525 msframe->sizing = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3526 /* Queue noop event */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3527 mswindows_enqueue_magic_event (NULL, XM_BUMPQUEUE);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3528 return 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3529
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3530 #ifdef HAVE_SCROLLBARS
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3531 case WM_VSCROLL:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3532 case WM_HSCROLL:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3533 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3534 /* Direction of scroll is determined by scrollbar instance. */
1279
cd0abfdb9e9d [xemacs-hg @ 2003-02-09 09:33:42 by ben]
ben
parents: 1268
diff changeset
3535 int code = (int) LOWORD (wParam);
cd0abfdb9e9d [xemacs-hg @ 2003-02-09 09:33:42 by ben]
ben
parents: 1268
diff changeset
3536 int pos = (short int) HIWORD (wParam);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3537 HWND hwndScrollBar = (HWND) lParam;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3538 struct gcpro gcpro1, gcpro2;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3539
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3540 mswindows_handle_scrollbar_event (hwndScrollBar, code, pos);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3541 GCPRO2 (emacs_event, fobj);
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
3542 if (UNBOUNDP (mswindows_pump_outstanding_events ())) /* Can GC */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3543 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3544 /* Error during event pumping - cancel scroll */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3545 qxeSendMessage (hwndScrollBar, WM_CANCELMODE, 0, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3546 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3547 UNGCPRO;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3548 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3549 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3550
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3551 case WM_MOUSEWHEEL:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3552 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3553 int keys = LOWORD (wParam); /* Modifier key flags */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3554 int delta = (short) HIWORD (wParam); /* Wheel rotation amount */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3555
1622
bf2a986fcb17 [xemacs-hg @ 2003-08-13 11:27:47 by stephent]
stephent
parents: 1346
diff changeset
3556 /* enqueue button4/5 events if mswindows_handle_mousewheel_event
bf2a986fcb17 [xemacs-hg @ 2003-08-13 11:27:47 by stephent]
stephent
parents: 1346
diff changeset
3557 doesn't handle the event, such as when the scrollbars are not
bf2a986fcb17 [xemacs-hg @ 2003-08-13 11:27:47 by stephent]
stephent
parents: 1346
diff changeset
3558 displayed */
bf2a986fcb17 [xemacs-hg @ 2003-08-13 11:27:47 by stephent]
stephent
parents: 1346
diff changeset
3559 if (!mswindows_handle_mousewheel_event (mswindows_find_frame (hwnd),
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
3560 keys, delta,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3561 XE_MAKEPOINTS (lParam)))
1622
bf2a986fcb17 [xemacs-hg @ 2003-08-13 11:27:47 by stephent]
stephent
parents: 1346
diff changeset
3562 mswindows_enqueue_mouse_button_event (hwnd, message_,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3563 XE_MAKEPOINTS (lParam),
1622
bf2a986fcb17 [xemacs-hg @ 2003-08-13 11:27:47 by stephent]
stephent
parents: 1346
diff changeset
3564 wParam,
bf2a986fcb17 [xemacs-hg @ 2003-08-13 11:27:47 by stephent]
stephent
parents: 1346
diff changeset
3565 GetMessageTime());
bf2a986fcb17 [xemacs-hg @ 2003-08-13 11:27:47 by stephent]
stephent
parents: 1346
diff changeset
3566 /* We are not in a modal loop so no pumping is necessary. */
bf2a986fcb17 [xemacs-hg @ 2003-08-13 11:27:47 by stephent]
stephent
parents: 1346
diff changeset
3567 break;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3568 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3569 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3570
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3571 #ifdef HAVE_MENUBARS
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3572 case WM_INITMENU:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3573 if (UNBOUNDP (mswindows_handle_wm_initmenu
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3574 ((HMENU) wParam,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3575 XFRAME (mswindows_find_frame (hwnd)))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3576 qxeSendMessage (hwnd, WM_CANCELMODE, 0, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3577 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3578
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3579 case WM_INITMENUPOPUP:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3580 if (!HIWORD(lParam))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3581 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3582 if (UNBOUNDP (mswindows_handle_wm_initmenupopup
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3583 ((HMENU) wParam,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3584 XFRAME (mswindows_find_frame (hwnd)))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3585 qxeSendMessage (hwnd, WM_CANCELMODE, 0, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3586 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3587 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3588
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3589 #endif /* HAVE_MENUBARS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3590
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3591 case WM_COMMAND:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3592 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3593 WORD id = LOWORD (wParam);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3594 WORD nid = HIWORD (wParam);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3595 HWND cid = (HWND)lParam;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3596 frame = XFRAME (mswindows_find_frame (hwnd));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3597
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3598 #ifdef HAVE_TOOLBARS
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3599 if (!NILP (mswindows_handle_toolbar_wm_command (frame, cid, id)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3600 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3601 #endif
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3602 /* widgets in a buffer only eval a callback for suitable events. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3603 switch (nid)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3604 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3605 case BN_CLICKED:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3606 case EN_CHANGE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3607 case CBN_EDITCHANGE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3608 case CBN_SELCHANGE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3609 if (!NILP (mswindows_handle_gui_wm_command (frame, cid, id)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3610 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3611 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3612 /* menubars always must come last since the hashtables do not
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3613 always exist */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3614 #ifdef HAVE_MENUBARS
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3615 if (!NILP (mswindows_handle_wm_command (frame, id)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3616 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3617 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3618
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3619 goto defproc;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3620 /* Bite me - a spurious command. This used to not be able to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3621 happen but with the introduction of widgets it's now
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3622 possible. #### Andy, fix the god-damn widget code! It has
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3623 more bugs than a termite's nest! */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3624 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3625 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3626
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3627 case WM_CTLCOLORBTN:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3628 case WM_CTLCOLORLISTBOX:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3629 case WM_CTLCOLOREDIT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3630 case WM_CTLCOLORSTATIC:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3631 case WM_CTLCOLORSCROLLBAR:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3632 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3633 /* if we get an opportunity to paint a widget then do so if
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3634 there is an appropriate face */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3635 HWND crtlwnd = (HWND) lParam;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3636 LONG ii = qxeGetWindowLong (crtlwnd, GWL_USERDATA);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3637 if (ii)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3638 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3639 Lisp_Object image_instance;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 819
diff changeset
3640 image_instance = VOID_TO_LISP ((void *) ii);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3641 if (IMAGE_INSTANCEP (image_instance)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3642 &&
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3643 IMAGE_INSTANCE_TYPE_P (image_instance, IMAGE_WIDGET))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3644 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3645 /* set colors for the buttons */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3646 HDC hdc = (HDC) wParam;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3647 if (last_widget_brushed != ii)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3648 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3649 if (widget_brush)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3650 DeleteObject (widget_brush);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3651 widget_brush = CreateSolidBrush
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3652 (COLOR_INSTANCE_MSWINDOWS_COLOR
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3653 (XCOLOR_INSTANCE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3654 (FACE_BACKGROUND
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3655 (XIMAGE_INSTANCE_WIDGET_FACE (image_instance),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3656 XIMAGE_INSTANCE_FRAME (image_instance)))));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3657 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3658 last_widget_brushed = ii;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3659 SetTextColor
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3660 (hdc,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3661 COLOR_INSTANCE_MSWINDOWS_COLOR
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3662 (XCOLOR_INSTANCE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3663 (FACE_FOREGROUND
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3664 (XIMAGE_INSTANCE_WIDGET_FACE (image_instance),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3665 XIMAGE_INSTANCE_FRAME (image_instance)))));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3666 SetBkMode (hdc, OPAQUE);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3667 SetBkColor
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3668 (hdc,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3669 COLOR_INSTANCE_MSWINDOWS_COLOR
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3670 (XCOLOR_INSTANCE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3671 (FACE_BACKGROUND
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3672 (XIMAGE_INSTANCE_WIDGET_FACE (image_instance),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3673 XIMAGE_INSTANCE_FRAME (image_instance)))));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3674 return (LRESULT)widget_brush;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3675 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3676 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3677 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3678 goto defproc;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3679
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3680 #ifdef HAVE_DRAGNDROP
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
3681 case WM_DROPFILES: /* implementation ripped-off from event-Xt.c */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3682 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3683 UINT filecount, i;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3684 POINT point;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3685
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3686 Lisp_Object l_dndlist = Qnil, l_item = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3687 struct gcpro gcpro1, gcpro2, gcpro3;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3688
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3689 emacs_event = Fmake_event (Qnil, Qnil);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3690 event = XEVENT (emacs_event);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3691
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3692 GCPRO3 (emacs_event, l_dndlist, l_item);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3693
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3694 if (!DragQueryPoint ((HDROP) wParam, &point))
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
3695 point.x = point.y = -1; /* outside client area */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3696
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
3697 XSET_EVENT_TYPE (emacs_event, misc_user_event);
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
3698 XSET_EVENT_CHANNEL (emacs_event, mswindows_find_frame(hwnd));
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
3699 XSET_EVENT_TIMESTAMP (emacs_event, GetMessageTime());
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
3700 XSET_EVENT_MISC_USER_BUTTON (emacs_event, 1);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
3701 XSET_EVENT_MISC_USER_MODIFIERS (emacs_event,
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
3702 mswindows_modifier_state (NULL, (DWORD) -1, 0));
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
3703 XSET_EVENT_MISC_USER_X (emacs_event, point.x);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
3704 XSET_EVENT_MISC_USER_Y (emacs_event, point.y);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
3705 XSET_EVENT_MISC_USER_FUNCTION (emacs_event,
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
3706 Qdragdrop_drop_dispatch);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3707
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3708 filecount = qxeDragQueryFile ((HDROP) wParam, 0xffffffff, NULL, 0);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3709 for (i = 0; i < filecount; i++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3710 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 856
diff changeset
3711 Ibyte *fname;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3712 Extbyte *fname_ext;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3713 Bytecount fnamelen;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3714 Charcount len = qxeDragQueryFile ((HDROP) wParam, i, NULL, 0);
2526
902d5bd9b75c [xemacs-hg @ 2005-01-28 02:36:11 by ben]
ben
parents: 2500
diff changeset
3715 int freeme = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3716 /* The URLs that we make here aren't correct according to section
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3717 * 3.10 of rfc1738 because they're missing the //<host>/ part and
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3718 * because they may contain reserved characters. But that's OK -
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3719 * they just need to be good enough to keep dragdrop.el happy. */
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3720 fname_ext = alloca_extbytes ((len + 1) * XETCHAR_SIZE);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3721 qxeDragQueryFile ((HDROP) wParam, i, fname_ext, len + 1);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3722
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3723 TO_INTERNAL_FORMAT (DATA, (fname_ext, len * XETCHAR_SIZE),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3724 ALLOCA, (fname, fnamelen),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3725 Qmswindows_tstr);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3726
2526
902d5bd9b75c [xemacs-hg @ 2005-01-28 02:36:11 by ben]
ben
parents: 2500
diff changeset
3727
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3728 /* May be a shell link aka "shortcut" - replace fname if so */
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3729 if (!qxestrcasecmp_ascii (fname + fnamelen - 4, ".LNK"))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3730 {
2526
902d5bd9b75c [xemacs-hg @ 2005-01-28 02:36:11 by ben]
ben
parents: 2500
diff changeset
3731 fname = mswindows_read_link (fname);
902d5bd9b75c [xemacs-hg @ 2005-01-28 02:36:11 by ben]
ben
parents: 2500
diff changeset
3732 freeme = 1;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3733 }
2526
902d5bd9b75c [xemacs-hg @ 2005-01-28 02:36:11 by ben]
ben
parents: 2500
diff changeset
3734
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3735 {
2526
902d5bd9b75c [xemacs-hg @ 2005-01-28 02:36:11 by ben]
ben
parents: 2500
diff changeset
3736 Ibyte *fname2 = urlify_filename (fname);
902d5bd9b75c [xemacs-hg @ 2005-01-28 02:36:11 by ben]
ben
parents: 2500
diff changeset
3737 l_item = build_intstring (fname2);
902d5bd9b75c [xemacs-hg @ 2005-01-28 02:36:11 by ben]
ben
parents: 2500
diff changeset
3738 xfree (fname2, Ibyte *);
902d5bd9b75c [xemacs-hg @ 2005-01-28 02:36:11 by ben]
ben
parents: 2500
diff changeset
3739 if (freeme)
902d5bd9b75c [xemacs-hg @ 2005-01-28 02:36:11 by ben]
ben
parents: 2500
diff changeset
3740 xfree (fname, Ibyte *);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3741 l_dndlist = Fcons (l_item, l_dndlist);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3742 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3743 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3744
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3745 DragFinish ((HDROP) wParam);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3746
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
3747 SET_EVENT_MISC_USER_OBJECT (event,
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
3748 Fcons (Qdragdrop_URL, l_dndlist));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3749 mswindows_enqueue_dispatch_event (emacs_event);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3750 UNGCPRO;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3751 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3752 break;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3753 #endif /* HAVE_DRAGNDROP */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3754
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3755 #ifdef MULE
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3756 case WM_IME_CHAR:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3757
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3758 case WM_IME_STARTCOMPOSITION:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3759 mswindows_start_ime_composition (XFRAME (mswindows_find_frame (hwnd)));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3760 goto defproc;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3761
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3762 case WM_IME_COMPOSITION:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3763 if (lParam & GCS_RESULTSTR)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3764 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3765 HIMC imc = ImmGetContext (hwnd);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3766 Extbyte *result;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3767 Bytecount len;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 856
diff changeset
3768 Ibyte *resultint, *endptr;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3769 Bytecount lenint;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3770 int speccount;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3772 if (!imc)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3773 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3774
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3775 /* See WM_KEYDOWN above. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3776 speccount = begin_dont_check_for_quit ();
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3777
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3778 /* Sizes always in bytes, even for unicode.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3779 ImmGetCompositionStringW is supported even on Windows 9x, and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3780 allows us to handle multiple languages. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3781 len = ImmGetCompositionStringW (imc, GCS_RESULTSTR, NULL, 0);
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
3782 result = alloca_extbytes (len);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3783 ImmGetCompositionStringW (imc, GCS_RESULTSTR, (WCHAR *) result, len);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3784 ImmReleaseContext (hwnd, imc);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3785
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3786 TO_INTERNAL_FORMAT (DATA, (result, len),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3787 ALLOCA, (resultint, lenint),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3788 Qmswindows_tstr);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3789
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3790 endptr = resultint + lenint;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3791
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3792 while (resultint < endptr)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3793 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 856
diff changeset
3794 Ichar ch = itext_ichar (resultint);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3795 if (ch == ' ')
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3796 mswindows_enqueue_keypress_event (hwnd, QKspace, 0);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3797 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3798 mswindows_enqueue_keypress_event (hwnd, make_char (ch), 0);
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 856
diff changeset
3799 INC_IBYTEPTR (resultint);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3800 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3801
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3802 unbind_to (speccount);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3803 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3804 goto defproc;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3805 #endif /* MULE */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3806
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3807 defproc:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3808 default:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3809 return qxeDefWindowProc (hwnd, message_, wParam, lParam);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3810 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3811 return (0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3812 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3813
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3814
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3815 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3816 /* keyboard, mouse & other helpers for the windows procedure */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3817 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3818 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3819 mswindows_set_chord_timer (HWND hwnd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3820 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3821 int interval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3822
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3823 /* We get one third half system double click threshold */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3824 if (mswindows_mouse_button_tolerance <= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3825 interval = GetDoubleClickTime () / 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3826 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3827 interval = mswindows_mouse_button_tolerance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3828
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3829 SetTimer (hwnd, BUTTON_2_TIMER_ID, interval, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3830 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3831
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3832 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3833 mswindows_button2_near_enough (POINTS p1, POINTS p2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3834 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3835 int dx, dy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3836 if (mswindows_mouse_button_max_skew_x <= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3837 dx = GetSystemMetrics (SM_CXDOUBLECLK) / 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3838 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3839 dx = mswindows_mouse_button_max_skew_x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3840
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3841 if (mswindows_mouse_button_max_skew_y <= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3842 dy = GetSystemMetrics (SM_CYDOUBLECLK) / 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3843 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3844 dy = mswindows_mouse_button_max_skew_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3845
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3846 return abs (p1.x - p2.x) < dx && abs (p1.y- p2.y)< dy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3847 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3848
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3849 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3850 mswindows_current_layout_has_AltGr (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3851 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3852 /* This simple caching mechanism saves 10% of CPU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3853 time when a key typed at autorepeat rate of 30 cps! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3854 static HKL last_hkl = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3855 static int last_hkl_has_AltGr;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3856 HKL current_hkl = GetKeyboardLayout (0);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3857
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3858 if (current_hkl != last_hkl)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3859 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
3860 int c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3861 last_hkl_has_AltGr = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3862 /* In this loop, we query whether a character requires
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3863 AltGr to be down to generate it. If at least such one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3864 found, this means that the layout does regard AltGr */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
3865 for (c = ' '; c <= 255 && !last_hkl_has_AltGr; ++c)
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
3866 /* #### This is not really such a good check. What about under
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
3867 CJK locales? It may not matter there, though. We always
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
3868 call VkKeyScanA so that we check the locale-specific characters
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
3869 in non-Latin-1 locales, instead of just the Latin-1 characters. */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
3870 if (HIBYTE (VkKeyScanA ((char) c)) == 6)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3871 last_hkl_has_AltGr = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3872 last_hkl = current_hkl;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3873 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3874 return last_hkl_has_AltGr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3875 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3876
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3877
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3878 /* Returns the state of the modifier keys in the format expected by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3879 * Lisp_Event key_data, button_data and motion_data modifiers member */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3880 static int
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3881 mswindows_modifier_state (BYTE *keymap, DWORD fwKeys, int has_AltGr)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3882 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3883 int mods = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3884 int keys_is_real = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3885 BYTE keymap2[256];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3886
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3887 if (fwKeys == (DWORD) -1)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3888 fwKeys = mswindows_last_mouse_button_state;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3889 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3890 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3891 keys_is_real = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3892 mswindows_last_mouse_button_state = fwKeys;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3893 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3894
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3895 if (keymap == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3896 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3897 keymap = keymap2;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3898 GetKeyboardState (keymap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3899 has_AltGr = mswindows_current_layout_has_AltGr ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3900 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3901
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3902 /* #### should look at fwKeys for MK_CONTROL. I don't understand how
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3903 AltGr works. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3904 if (has_AltGr && (keymap [VK_LCONTROL] & 0x80) && (keymap [VK_RMENU] & 0x80))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3905 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3906 mods |= (keymap [VK_LMENU] & 0x80) ? XEMACS_MOD_META : 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3907 mods |= (keymap [VK_RCONTROL] & 0x80) ? XEMACS_MOD_CONTROL : 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3908 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3909 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3910 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3911 mods |= (keymap [VK_MENU] & 0x80) ? XEMACS_MOD_META : 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3912 mods |= (keymap [VK_CONTROL] & 0x80) ? XEMACS_MOD_CONTROL : 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3913 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3914
1111
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 986
diff changeset
3915 mods |= (keys_is_real ? (int) (fwKeys & MK_SHIFT) :
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 986
diff changeset
3916 (keymap [VK_SHIFT] & 0x80)) ? XEMACS_MOD_SHIFT : 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3917 mods |= fwKeys & MK_LBUTTON ? XEMACS_MOD_BUTTON1 : 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3918 mods |= fwKeys & MK_MBUTTON ? XEMACS_MOD_BUTTON2 : 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3919 mods |= fwKeys & MK_RBUTTON ? XEMACS_MOD_BUTTON3 : 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3920
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3921 return mods;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3922 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3923
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3924 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3925 * Translate a mswindows virtual key to a keysym.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3926 * Only returns non-Qnil for keys that don't generate WM_CHAR messages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3927 * or whose ASCII codes (like space) xemacs doesn't like.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3928 */
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
3929 Lisp_Object mswindows_key_to_emacs_keysym (int mswindows_key,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
3930 int UNUSED (mods), int extendedp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3931 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3932 if (extendedp) /* Keys not present on a 82 key keyboard */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3933 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3934 switch (mswindows_key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3935 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3936 case VK_CANCEL: return KEYSYM ("pause");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3937 case VK_RETURN: return KEYSYM ("kp-enter");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3938 case VK_PRIOR: return KEYSYM ("prior");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3939 case VK_NEXT: return KEYSYM ("next");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3940 case VK_END: return KEYSYM ("end");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3941 case VK_HOME: return KEYSYM ("home");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3942 case VK_LEFT: return KEYSYM ("left");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3943 case VK_UP: return KEYSYM ("up");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3944 case VK_RIGHT: return KEYSYM ("right");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3945 case VK_DOWN: return KEYSYM ("down");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3946 case VK_INSERT: return KEYSYM ("insert");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3947 case VK_DELETE: return QKdelete;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3948 #if 0 /* FSF Emacs allows these to return configurable syms/mods */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3949 case VK_LWIN return KEYSYM ("");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3950 case VK_RWIN return KEYSYM ("");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3951 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3952 case VK_APPS: return KEYSYM ("menu");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3953 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3954 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3955 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3956 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3957 switch (mswindows_key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3958 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3959
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3960 #if 0
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3961 VK_LBUTTON:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3962 VK_RBUTTON:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3963 VK_CANCEL:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3964 VK_MBUTTON:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3965 VK_XBUTTON1:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3966 VK_XBUTTON2:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3967 #endif /* 0 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3968
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3969 case VK_BACK: return QKbackspace;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3970 case VK_TAB: return QKtab;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3971 /* #### Officially 0A (and 0B too) are "reserved". */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3972 case '\n': return QKlinefeed;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3973 case VK_CLEAR: return KEYSYM ("clear");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3974 case VK_RETURN: return QKreturn;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3975
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3976 #if 0
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3977 VK_SHIFT: "shift"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3978 VK_CONTROL: "control"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3979 VK_MENU: "alt"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3980 #endif /* 0 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3981
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3982 case VK_PAUSE: return KEYSYM ("pause");
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3983
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3984 #if 0
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3985 VK_CAPITAL: "caps-lock"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3986 VK_KANA: IME Kana mode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3987 VK_HANGUEL: IME Hanguel mode (maintained for compatibility; use VK_HANGUL)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3988 VK_HANGUL: IME Hangul mode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3989 VK_JUNJA: IME Junja mode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3990 VK_FINAL: IME final mode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3991 VK_HANJA: IME Hanja mode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3992 VK_KANJI: IME Kanji mode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3993 #endif /* 0 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3994
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3995 case VK_ESCAPE: return QKescape;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3996
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3997 #if 0
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3998 VK_CONVERT: IME convert
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3999 VK_NONCONVERT: IME nonconvert
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4000 VK_ACCEPT: IME accept
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4001 VK_MODECHANGE: IME mode change request
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4002 #endif /* 0 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4003
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4004 case VK_SPACE: return QKspace;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4005 case VK_PRIOR: return KEYSYM ("kp-prior");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4006 case VK_NEXT: return KEYSYM ("kp-next");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4007 case VK_END: return KEYSYM ("kp-end");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4008 case VK_HOME: return KEYSYM ("kp-home");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4009 case VK_LEFT: return KEYSYM ("kp-left");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4010 case VK_UP: return KEYSYM ("kp-up");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4011 case VK_RIGHT: return KEYSYM ("kp-right");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4012 case VK_DOWN: return KEYSYM ("kp-down");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4013 case VK_SELECT: return KEYSYM ("select");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4014 case VK_PRINT: return KEYSYM ("print");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4015 case VK_EXECUTE: return KEYSYM ("execute");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4016 case VK_SNAPSHOT: return KEYSYM ("print");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4017 case VK_INSERT: return KEYSYM ("kp-insert");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4018 case VK_DELETE: return KEYSYM ("kp-delete");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4019 case VK_HELP: return KEYSYM ("help");
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4020 #if 0
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4021 '0' through '9': numeric keys
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4022 'A' through 'Z': alphabetic keys
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4023 VK_LWIN: "lwin"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4024 VK_RWIN: "rwin"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4025 VK_APPS: "apps"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4026 VK_SLEEP: "sleep"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4027 #endif /* 0 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4028 case VK_NUMPAD0: return KEYSYM ("kp-0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4029 case VK_NUMPAD1: return KEYSYM ("kp-1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4030 case VK_NUMPAD2: return KEYSYM ("kp-2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4031 case VK_NUMPAD3: return KEYSYM ("kp-3");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4032 case VK_NUMPAD4: return KEYSYM ("kp-4");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4033 case VK_NUMPAD5: return KEYSYM ("kp-5");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4034 case VK_NUMPAD6: return KEYSYM ("kp-6");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4035 case VK_NUMPAD7: return KEYSYM ("kp-7");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4036 case VK_NUMPAD8: return KEYSYM ("kp-8");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4037 case VK_NUMPAD9: return KEYSYM ("kp-9");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4038 case VK_MULTIPLY: return KEYSYM ("kp-multiply");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4039 case VK_ADD: return KEYSYM ("kp-add");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4040 case VK_SEPARATOR: return KEYSYM ("kp-separator");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4041 case VK_SUBTRACT: return KEYSYM ("kp-subtract");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4042 case VK_DECIMAL: return KEYSYM ("kp-decimal");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4043 case VK_DIVIDE: return KEYSYM ("kp-divide");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4044 case VK_F1: return KEYSYM ("f1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4045 case VK_F2: return KEYSYM ("f2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4046 case VK_F3: return KEYSYM ("f3");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4047 case VK_F4: return KEYSYM ("f4");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4048 case VK_F5: return KEYSYM ("f5");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4049 case VK_F6: return KEYSYM ("f6");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4050 case VK_F7: return KEYSYM ("f7");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4051 case VK_F8: return KEYSYM ("f8");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4052 case VK_F9: return KEYSYM ("f9");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4053 case VK_F10: return KEYSYM ("f10");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4054 case VK_F11: return KEYSYM ("f11");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4055 case VK_F12: return KEYSYM ("f12");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4056 case VK_F13: return KEYSYM ("f13");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4057 case VK_F14: return KEYSYM ("f14");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4058 case VK_F15: return KEYSYM ("f15");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4059 case VK_F16: return KEYSYM ("f16");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4060 case VK_F17: return KEYSYM ("f17");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4061 case VK_F18: return KEYSYM ("f18");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4062 case VK_F19: return KEYSYM ("f19");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4063 case VK_F20: return KEYSYM ("f20");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4064 case VK_F21: return KEYSYM ("f21");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4065 case VK_F22: return KEYSYM ("f22");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4066 case VK_F23: return KEYSYM ("f23");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4067 case VK_F24: return KEYSYM ("f24");
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4068
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4069 #if 0
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4070 VK_NUMLOCK: 90 NUM LOCK key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4071 VK_SCROLL: 91 SCROLL LOCK key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4072 92~96 OEM specific;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4073 VK_LSHIFT:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4074 VK_RSHIFT:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4075 VK_LCONTROL:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4076 VK_RCONTROL:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4077 VK_LMENU:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4078 VK_RMENU:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4079
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4080 #ifdef VK_BROWSER_BACK /* Windows 2000 only */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4081 VK_BROWSER_BACK: Browser Back key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4082 VK_BROWSER_FORWARD: Browser Forward key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4083 VK_BROWSER_REFRESH: Browser Refresh key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4084 VK_BROWSER_STOP: Browser Stop key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4085 VK_BROWSER_SEARCH: Browser Search key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4086 VK_BROWSER_FAVORITES: Browser Favorites key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4087 VK_BROWSER_HOME: Browser Start and Home key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4088 VK_VOLUME_MUTE: Volume Mute key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4089 VK_VOLUME_DOWN: Volume Down key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4090 VK_VOLUME_UP: Volume Up key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4091 VK_MEDIA_NEXT_TRACK: Next Track key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4092 VK_MEDIA_PREV_TRACK: Previous Track key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4093 VK_MEDIA_STOP: Stop Media key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4094 VK_MEDIA_PLAY_PAUSE: Play/Pause Media key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4095 VK_LAUNCH_MAIL: Start Mail key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4096 VK_LAUNCH_MEDIA_SELECT: Select Media key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4097 VK_LAUNCH_APP1: Start Application 1 key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4098 VK_LAUNCH_APP2: Start Application 2 key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4099 B8-B9 Reserved;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4100 VK_OEM_1: For the US standard keyboard, the ';:' key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4101 VK_OEM_PLUS: For any country/region, the '+' key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4102 VK_OEM_COMMA: For any country/region, the ',' key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4103 VK_OEM_MINUS: For any country/region, the '-' key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4104 VK_OEM_PERIOD: For any country/region, the '.' key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4105 VK_OEM_2: For the US standard keyboard, the '/?' key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4106 VK_OEM_3: For the US standard keyboard, the '`~' key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4107 C1~D7 Reserved;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4108 D8~DA Unassigned;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4109 VK_OEM_4: For the US standard keyboard, the '[{' key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4110 VK_OEM_5: For the US standard keyboard, the '\|' key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4111 VK_OEM_6: For the US standard keyboard, the ']}' key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4112 VK_OEM_7: For the US standard keyboard, the 'single-quote/double-quote' key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4113 VK_OEM_8:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4114 E0 Reserved;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4115 E1 OEM specific;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4116 VK_OEM_102: Either the angle bracket key or the backslash key on the RT 102-key keyboard
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4117 E3~E4 OEM specific;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4118 #endif /* VK_BROWSER_BACK */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4119 VK_PROCESSKEY: E5 Windows 95/98, Windows NT 4.0, Windows 2000: IME PROCESS key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4120 E6 OEM specific;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4121 VK_PACKET: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4122 E8 Unassigned;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4123 E9~F5 OEM specific;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4124 VK_ATTN: Attn key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4125 VK_CRSEL: CrSel key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4126 VK_EXSEL: ExSel key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4127 VK_EREOF: Erase EOF key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4128 VK_PLAY: Play key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4129 VK_ZOOM: Zoom key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4130 VK_NONAME: Reserved for future use
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4131 VK_PA1: PA1 key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4132 VK_OEM_CLEAR: Clear key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4133 #endif /* 0 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4134
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4135 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4136 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4137 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4138 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4140 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4141 * Find the console that matches the supplied mswindows window handle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4142 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4143 Lisp_Object
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
4144 mswindows_find_console (HWND UNUSED (hwnd))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4145 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4146 /* We only support one console */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4147 return XCAR (Vconsole_list);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4148 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4149
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4150 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4151 * Find the frame that matches the supplied mswindows window handle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4152 */
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 535
diff changeset
4153 Lisp_Object
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4154 mswindows_find_frame (HWND hwnd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4155 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4156 LONG l = qxeGetWindowLong (hwnd, XWL_FRAMEOBJ);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4157 Lisp_Object f;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4158 if (l == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4159 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4160 /* We are in progress of frame creation. Return the frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4161 being created, as it still not remembered in the window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4162 extra storage. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4163 assert (!NILP (Vmswindows_frame_being_created));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4164 return Vmswindows_frame_being_created;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4165 }
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 819
diff changeset
4166 f = VOID_TO_LISP ((void *) l);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4167 return f;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4168 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4169
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4170
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4171 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4172 /* methods */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4173 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4174
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4175 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4176 emacs_mswindows_add_timeout (EMACS_TIME thyme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4177 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4178 int milliseconds;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4179 EMACS_TIME current_time;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4180 EMACS_GET_TIME (current_time);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4181 EMACS_SUB_TIME (thyme, thyme, current_time);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4182 milliseconds = EMACS_SECS (thyme) * 1000 +
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4183 (EMACS_USECS (thyme) + 500) / 1000;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4184 if (milliseconds < 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4185 milliseconds = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4186 ++mswindows_pending_timers_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4187 return SetTimer (NULL, 0, milliseconds,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4188 (TIMERPROC) mswindows_wm_timer_callback);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4189 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4190
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4191 static int
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4192 remove_timeout_mapper (Lisp_Object ev, void *data)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4193 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4194 if (XEVENT_TYPE (ev) == timeout_event)
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4195 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4196 if ((int) data == XEVENT_TIMEOUT_INTERVAL_ID (ev))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4197 return 1;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4198 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4199
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4200 return 0;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4201 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4202
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4203 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4204 emacs_mswindows_remove_timeout (int id)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4205 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4206 if (KillTimer (NULL, id))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4207 --mswindows_pending_timers_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4209 /* If there is a dispatch event generated by this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4210 timeout in the queue, we have to remove it too. */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4211 map_event_chain_remove (remove_timeout_mapper,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4212 &mswindows_s_dispatch_event_queue,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4213 &mswindows_s_dispatch_event_queue_tail,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4214 (void *) id, MECR_DEALLOCATE_EVENT);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4215 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4216
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4217 /* If `user_p' is false, then return whether there are any win32, timeout,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4218 * or subprocess events pending (that is, whether
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4219 * emacs_mswindows_next_event() would return immediately without blocking).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4220 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4221 * if `user_p' is true, then return whether there are any *user generated*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4222 * events available (that is, whether there are keyboard or mouse-click
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4223 * events ready to be read). This also implies that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4224 * emacs_mswindows_next_event() would not block.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4225 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4226 static int
1268
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4227 emacs_mswindows_event_pending_p (int how_many)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4228 {
1318
b531bf8658e9 [xemacs-hg @ 2003-02-21 06:56:46 by ben]
ben
parents: 1304
diff changeset
4229 /* This can call Lisp */
1268
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4230 if (!how_many)
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4231 {
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4232 mswindows_need_event (0);
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4233 return (!NILP (dispatch_event_queue)
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4234 || !NILP (mswindows_s_dispatch_event_queue));
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4235 }
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4236 else
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4237 {
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4238 Lisp_Object event;
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4239 int count = 0;
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4240
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4241 EVENT_CHAIN_LOOP (event, dispatch_event_queue)
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4242 count++;
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4243
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4244 if (count >= how_many)
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4245 return 1;
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4246
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4247 emacs_mswindows_drain_queue ();
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4248
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4249 EVENT_CHAIN_LOOP (event, dispatch_event_queue)
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4250 count++;
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4251
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4252 return count >= how_many;
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1242
diff changeset
4253 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4254 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4255
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4256 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4257 * Return the next event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4258 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4259 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4260 emacs_mswindows_next_event (Lisp_Event *emacs_event)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4261 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4262 Lisp_Object event, event2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4263
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4264 mswindows_need_event (1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4265
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4266 event = mswindows_dequeue_dispatch_event ();
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
4267 event2 = wrap_event (emacs_event);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4268 Fcopy_event (event, event2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4269 Fdeallocate_event (event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4270 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4271
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4272 static void
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4273 emacs_mswindows_format_magic_event (Lisp_Event *emacs_event,
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4274 Lisp_Object pstream)
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4275 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 819
diff changeset
4276 #define FROB(msg) case msg: write_c_string (pstream, "type=" #msg); break
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4277
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4278 switch (EVENT_MAGIC_MSWINDOWS_EVENT (emacs_event))
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4279 {
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4280 FROB (XM_BUMPQUEUE);
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4281 FROB (WM_PAINT);
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4282 FROB (WM_SETFOCUS);
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4283 FROB (WM_KILLFOCUS);
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4284 FROB (XM_MAPFRAME);
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4285 FROB (XM_UNMAPFRAME);
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4286
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2421
diff changeset
4287 default: ABORT ();
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4288 }
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4289 #undef FROB
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4290
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4291 if (!NILP (EVENT_CHANNEL (emacs_event)))
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4292 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 819
diff changeset
4293 write_c_string (pstream, " ");
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4294 print_internal (EVENT_CHANNEL (emacs_event), pstream, 1);
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4295 }
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4296 }
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4297
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4298 static int
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4299 emacs_mswindows_compare_magic_event (Lisp_Event *e1, Lisp_Event *e2)
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4300 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4301 return (EVENT_MAGIC_MSWINDOWS_EVENT (e1) ==
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4302 EVENT_MAGIC_MSWINDOWS_EVENT (e2));
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4303 }
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4304
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4305 static Hashcode
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4306 emacs_mswindows_hash_magic_event (Lisp_Event *e)
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4307 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4308 return (EVENT_MAGIC_MSWINDOWS_EVENT (e));
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4309 }
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4310
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4311 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4312 * Handle a magic event off the dispatch queue.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4313 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4314 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4315 emacs_mswindows_handle_magic_event (Lisp_Event *emacs_event)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4316 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4317 switch (EVENT_MAGIC_MSWINDOWS_EVENT (emacs_event))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4318 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4319 case XM_BUMPQUEUE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4320 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4321
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4322 case WM_PAINT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4323 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4324 struct frame *f = XFRAME (EVENT_CHANNEL (emacs_event));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4325 mswindows_handle_paint (f);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4326 (FRAME_MSWINDOWS_DATA (f))->paint_pending = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4327 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4328 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4329
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4330 case WM_SETFOCUS:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4331 case WM_KILLFOCUS:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4332 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4333 Lisp_Object frame = EVENT_CHANNEL (emacs_event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4334 struct frame *f = XFRAME (frame);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4335 int in_p = (EVENT_MAGIC_MSWINDOWS_EVENT (emacs_event)
964
8d610ea37af8 [xemacs-hg @ 2002-08-16 08:15:18 by michaels]
michaels
parents: 923
diff changeset
4336 == WM_SETFOCUS);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4337 Lisp_Object conser;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4338 struct gcpro gcpro1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4339
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4340 /* On focus change, clear all memory of sticky modifiers
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4341 to avoid non-intuitive behavior. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4342 clear_sticky_modifiers ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4343
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4344 conser = Fcons (frame, Fcons (FRAME_DEVICE (f), in_p ? Qt : Qnil));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4345 GCPRO1 (conser);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4346 emacs_handle_focus_change_preliminary (conser);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4347 /* Under X the stuff up to here is done in the X event handler.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4348 I Don't know why */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4349 emacs_handle_focus_change_final (conser);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4350 UNGCPRO;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4351
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4352 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4353 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4354
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4355 case XM_MAPFRAME:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4356 case XM_UNMAPFRAME:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4357 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4358 Lisp_Object frame = EVENT_CHANNEL (emacs_event);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4359 va_run_hook_with_args (EVENT_MAGIC_MSWINDOWS_EVENT (emacs_event)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4360 == XM_MAPFRAME ?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4361 Qmap_frame_hook : Qunmap_frame_hook,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4362 1, frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4363 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4364 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4365
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4366 /* #### What about Enter & Leave */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4367 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4368 va_run_hook_with_args (in_p ? Qmouse_enter_frame_hook :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4369 Qmouse_leave_frame_hook, 1, frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4370 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4371
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4372 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4373 assert(0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4374 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4375 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4376
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4377 #ifndef CYGWIN
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4378
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4379 static HANDLE
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4380 get_process_input_waitable (Lisp_Process *process)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4381 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4382 Lisp_Object instr, outstr, errstr, p;
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
4383 p = wrap_process (process);
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4384 get_process_streams (process, &instr, &outstr, &errstr);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4385 assert (!NILP (instr));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4386 return (network_connection_p (p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4387 ? get_winsock_stream_waitable (XLSTREAM (instr))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4388 : get_ntpipe_input_stream_waitable (XLSTREAM (instr)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4389 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4390
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4391 static HANDLE
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4392 get_process_stderr_waitable (Lisp_Process *process)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4393 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4394 Lisp_Object instr, outstr, errstr;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4395 get_process_streams (process, &instr, &outstr, &errstr);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4396 if (NILP (errstr))
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4397 return INVALID_HANDLE_VALUE;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4398 return get_ntpipe_input_stream_waitable (XLSTREAM (errstr));
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4399 }
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4400
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4401 #endif /* not CYGWIN */
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4402
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4403 static void
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4404 emacs_mswindows_select_process (Lisp_Process *process, int doin, int doerr)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4405 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4406 #ifdef CYGWIN
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4407 int infd, errfd;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4408
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4409 event_stream_unixoid_select_process (process, doin, doerr, &infd, &errfd);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4410 #else
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4411 HANDLE hev = INVALID_HANDLE_VALUE;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4412 HANDLE herr = INVALID_HANDLE_VALUE;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4413
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4414 if (doin)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4415 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4416 hev = get_process_input_waitable (process);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4417 if (!add_waitable_handle (hev))
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4418 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4419 hev = INVALID_HANDLE_VALUE;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4420 goto err;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4421 }
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4422 }
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4423
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4424 if (doerr)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4425 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4426 herr = get_process_stderr_waitable (process);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4427 if (herr != INVALID_HANDLE_VALUE && !add_waitable_handle (herr))
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4428 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4429 herr = INVALID_HANDLE_VALUE;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4430 goto err;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4431 }
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4432 }
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4433
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4434 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4435 /* Also select on the process handle itself, so we can receive
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4436 exit notifications. Only do this once, not each time this
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4437 function is called (which can happen many times, e.g. if
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4438 (set-process-filter proc t) is called and then a process filter
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4439 is set again). It will be unselected in mswindows_need_event(). */
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
4440 Lisp_Object p = wrap_process (process);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
4441
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4442 if (!network_connection_p (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4443 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4444 HANDLE hprocess = get_nt_process_handle_only_first_time (process);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4445 if (hprocess != INVALID_HANDLE_VALUE
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4446 && !add_waitable_handle (hprocess))
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4447 goto err;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4448 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4449 }
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4450
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4451 return;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4452
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4453 err:
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4454 if (hev != INVALID_HANDLE_VALUE)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4455 remove_waitable_handle (hev);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4456 if (herr != INVALID_HANDLE_VALUE)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4457 remove_waitable_handle (herr);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4458 invalid_operation ("Too many active processes", wrap_process (process));
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4459 #endif /* CYGWIN */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4460 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4461
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4462 static void
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4463 emacs_mswindows_unselect_process (Lisp_Process *process, int doin, int doerr)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4464 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4465 #ifdef CYGWIN
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4466 int infd, errfd;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4467
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4468 event_stream_unixoid_unselect_process (process, doin, doerr, &infd, &errfd);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4469 #else
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4470 if (doin)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4471 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4472 /* Process handle is removed in the event loop as soon
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4473 as it is signaled, so don't bother here about it */
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4474 HANDLE hev = get_process_input_waitable (process);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4475 remove_waitable_handle (hev);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4476 }
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4477 if (doerr)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4478 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4479 /* Process handle is removed in the event loop as soon
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4480 as it is signaled, so don't bother here about it */
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4481 HANDLE herr = get_process_stderr_waitable (process);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4482 if (herr != INVALID_HANDLE_VALUE)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4483 remove_waitable_handle (herr);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4484 }
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4485 #endif /* CYGWIN */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4486 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4487
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4488 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
4489 emacs_mswindows_select_console (struct console *USED_IF_CYGWIN (con))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4490 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4491 #ifdef CYGWIN
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4492 if (CONSOLE_MSWINDOWS_P (con))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4493 return; /* mswindows consoles are automatically selected */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4494
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4495 event_stream_unixoid_select_console (con);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4496 #else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4497 #if 0
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4498 /* This is an attempt to get `xemacs -batch -l dunnet' to work.
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4499 Doesn't currently work and fucks other things up. */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4500 if (CONSOLE_STREAM_P (con) &&
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4501 !UNBOUNDP (CONSOLE_STREAM_DATA (con)->instream))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4502 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4503 HANDLE h =
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4504 (HANDLE) _get_osfhandle (fileno (CONSOLE_STREAM_DATA (con)->in));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4505 if (PeekNamedPipe (h, 0, 0, 0, 0, 0))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4506 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4507 Lisp_Object lstr = make_ntpipe_input_stream (h, 0);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4508 HANDLE hwait = get_ntpipe_input_stream_waitable (XLSTREAM (lstr));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4509
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4510 if (!add_waitable_handle (hwait))
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4511 invalid_operation ("Too many active processes",
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4512 wrap_console (con));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4513 CONSOLE_STREAM_DATA (con)->instream = lstr;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4514 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4515 else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4516 /* Unable to select on this stream */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4517 CONSOLE_STREAM_DATA (con)->instream = Qunbound;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4518 }
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4519 #endif /* 0 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4520 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4521 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4522
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4523 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
4524 emacs_mswindows_unselect_console (struct console *USED_IF_CYGWIN (con))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4525 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4526 #ifdef CYGWIN
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4527 if (CONSOLE_MSWINDOWS_P (con))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4528 return; /* mswindows consoles are automatically selected */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4529
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4530 event_stream_unixoid_unselect_console (con);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4531 #else
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4532 #if 0 /* see above */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4533 if (CONSOLE_STREAM_P (con) &&
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4534 !UNBOUNDP (CONSOLE_STREAM_DATA (con)->instream))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4535 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4536 Lisp_Object instr = CONSOLE_STREAM_DATA (con)->instream;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4537 HANDLE hwait;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4538
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4539 assert (!NILP (instr));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4540 hwait = get_ntpipe_input_stream_waitable (XLSTREAM (instr));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4541
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4542 remove_waitable_handle (hwait);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4543 }
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4544 #endif /* 0 */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
4545 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4546 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4547
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4548 static void
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4549 emacs_mswindows_create_io_streams (void *inhandle, void *outhandle,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4550 void *errhandle, Lisp_Object *instream,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4551 Lisp_Object *outstream,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4552 Lisp_Object *errstream,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4553 USID *in_usid,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4554 USID *err_usid,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4555 int flags)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4556 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4557 #ifdef CYGWIN
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4558 event_stream_unixoid_create_io_streams (inhandle, outhandle,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4559 errhandle, instream,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4560 outstream, errstream,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4561 in_usid, err_usid, flags);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4562 #else
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4563 /* Handles for streams */
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4564 HANDLE hin, hout, herr;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4565 /* fds. These just stored along with the streams, and are closed in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4566 delete stream pair method, because we need to handle fake unices
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4567 here. */
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4568 int fdi, fdo, fde;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4569
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4570 /* Decode inhandle, outhandle, errhandle. Their meaning depends on
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4571 the process implementation being used. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4572 hin = (HANDLE) inhandle;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4573 hout = (HANDLE) outhandle;
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4574 if (errhandle == (void *) -1)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4575 herr = INVALID_HANDLE_VALUE;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4576 else
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4577 herr = (HANDLE) errhandle;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4578 fdi = fdo = fde = -1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4579
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4580 *instream = (hin == INVALID_HANDLE_VALUE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4581 ? Qnil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4582 : flags & STREAM_NETWORK_CONNECTION
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4583 ? make_winsock_input_stream ((SOCKET) hin, fdi)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4584 : make_ntpipe_input_stream (hin, fdi));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4585
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4586 *errstream = (herr == INVALID_HANDLE_VALUE
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4587 ? Qnil
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4588 : make_ntpipe_input_stream (herr, fde));
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4589
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4590 *outstream = (hout == INVALID_HANDLE_VALUE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4591 ? Qnil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4592 : flags & STREAM_NETWORK_CONNECTION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4593 ? make_winsock_output_stream ((SOCKET)hout, fdo)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4594 : make_ntpipe_output_stream (hout, fdo));
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4595
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4596 *in_usid =
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4597 (NILP (*instream)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4598 ? USID_ERROR
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4599 : flags & STREAM_NETWORK_CONNECTION
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4600 ? HANDLE_TO_USID (get_winsock_stream_waitable (XLSTREAM (*instream)))
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4601 : HANDLE_TO_USID (get_ntpipe_input_stream_waitable (XLSTREAM
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4602 (*instream))));
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4603
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4604 *err_usid =
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4605 (NILP (*errstream)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4606 ? USID_DONTHASH
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4607 : HANDLE_TO_USID (get_ntpipe_input_stream_waitable (XLSTREAM
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4608 (*errstream))));
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4609 #endif /* CYGWIN */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4610 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4611
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4612 static void
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4613 emacs_mswindows_delete_io_streams (Lisp_Object instream,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
4614 Lisp_Object USED_IF_CYGWIN (outstream),
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4615 Lisp_Object errstream,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4616 USID *in_usid,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4617 USID *err_usid)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4618 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4619 #ifdef CYGWIN
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4620 event_stream_unixoid_delete_io_streams (instream, outstream, errstream,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4621 in_usid, err_usid);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4622 #else
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4623 *in_usid =
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4624 (NILP (instream)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4625 ? USID_DONTHASH
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4626 : LSTREAM_TYPE_P (XLSTREAM (instream), winsock)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4627 ? HANDLE_TO_USID (get_winsock_stream_waitable (XLSTREAM (instream)))
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4628 : HANDLE_TO_USID (get_ntpipe_input_stream_waitable (XLSTREAM
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4629 (instream))));
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4630
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4631 *err_usid =
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4632 (NILP (errstream)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4633 ? USID_DONTHASH
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4634 : HANDLE_TO_USID (get_ntpipe_input_stream_waitable (XLSTREAM
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4635 (errstream))));
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4636 #endif /* CYGWIN */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4637 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4638
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4639 static int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
4640 emacs_mswindows_current_event_timestamp (struct console *UNUSED (c))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4641 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4642 return GetTickCount ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4643 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4644
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4645 #ifndef HAVE_X_WINDOWS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4646 /* This is called from GC when a process object is about to be freed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4647 If we've still got pointers to it in this file, we're gonna lose hard.
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4648 */
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4649 void debug_process_finalization (Lisp_Process *p);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4650 void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
4651 debug_process_finalization (Lisp_Process *UNUSED (p))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4652 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4653 #if 0 /* #### */
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4654 Lisp_Object instr, outstr, errstr;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4655
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4656 get_process_streams (p, &instr, &outstr, &errstr);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4657 /* if it still has fds, then it hasn't been killed yet. */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4658 assert (NILP (instr));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4659 assert (NILP (outstr));
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
4660 assert (NILP (errstr));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4661
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4662 /* #### More checks here */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4663 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4664 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4665 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4666
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4667 #ifdef DEBUG_XEMACS
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4668
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4669 struct mswin_message_debug
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4670 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4671 int mess;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4672 char *string;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4673 };
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4674
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4675 #define FROB(val) { val, #val, },
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4676
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4677 struct mswin_message_debug debug_mswin_messages[] =
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4678 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4679 FROB (WM_NULL)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4680 FROB (WM_CREATE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4681 FROB (WM_DESTROY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4682 FROB (WM_MOVE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4683 FROB (WM_SIZE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4684
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4685 FROB (WM_ACTIVATE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4686
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4687 FROB (WM_SETFOCUS)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4688 FROB (WM_KILLFOCUS)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4689 FROB (WM_ENABLE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4690 FROB (WM_SETREDRAW)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4691 FROB (WM_SETTEXT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4692 FROB (WM_GETTEXT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4693 FROB (WM_GETTEXTLENGTH)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4694 FROB (WM_PAINT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4695 FROB (WM_CLOSE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4696 FROB (WM_QUERYENDSESSION)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4697 FROB (WM_QUIT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4698 FROB (WM_QUERYOPEN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4699 FROB (WM_ERASEBKGND)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4700 FROB (WM_SYSCOLORCHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4701 FROB (WM_ENDSESSION)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4702 FROB (WM_SHOWWINDOW)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4703 FROB (WM_WININICHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4704 #if(WINVER >= 0x0400)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4705 FROB (WM_SETTINGCHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4706 #endif /* WINVER >= 0x0400 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4707
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4708 FROB (WM_DEVMODECHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4709 FROB (WM_ACTIVATEAPP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4710 FROB (WM_FONTCHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4711 FROB (WM_TIMECHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4712 FROB (WM_CANCELMODE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4713 FROB (WM_SETCURSOR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4714 FROB (WM_MOUSEACTIVATE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4715 FROB (WM_CHILDACTIVATE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4716 FROB (WM_QUEUESYNC)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4717
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4718 FROB (WM_GETMINMAXINFO)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4719
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4720 FROB (WM_PAINTICON)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4721 FROB (WM_ICONERASEBKGND)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4722 FROB (WM_NEXTDLGCTL)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4723 FROB (WM_SPOOLERSTATUS)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4724 FROB (WM_DRAWITEM)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4725 FROB (WM_MEASUREITEM)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4726 FROB (WM_DELETEITEM)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4727 FROB (WM_VKEYTOITEM)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4728 FROB (WM_CHARTOITEM)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4729 FROB (WM_SETFONT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4730 FROB (WM_GETFONT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4731 FROB (WM_SETHOTKEY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4732 FROB (WM_GETHOTKEY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4733 FROB (WM_QUERYDRAGICON)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4734 FROB (WM_COMPAREITEM)
1687
a4b5e2effaff [xemacs-hg @ 2003-09-15 22:04:08 by james]
james
parents: 1685
diff changeset
4735 #if(WINVER >= 0x0500) && defined(WM_GETOBJECT)
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4736 FROB (WM_GETOBJECT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4737 #endif /* WINVER >= 0x0500 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4738 FROB (WM_COMPACTING)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4739 FROB (WM_COMMNOTIFY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4740 FROB (WM_WINDOWPOSCHANGING)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4741 FROB (WM_WINDOWPOSCHANGED)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4742
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4743 FROB (WM_POWER)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4744
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4745 FROB (WM_COPYDATA)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4746 FROB (WM_CANCELJOURNAL)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4747
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4748 #if(WINVER >= 0x0400)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4749 FROB (WM_NOTIFY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4750 FROB (WM_INPUTLANGCHANGEREQUEST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4751 FROB (WM_INPUTLANGCHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4752 FROB (WM_TCARD)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4753 FROB (WM_HELP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4754 FROB (WM_USERCHANGED)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4755 FROB (WM_NOTIFYFORMAT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4756
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4757 FROB (WM_CONTEXTMENU)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4758 FROB (WM_STYLECHANGING)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4759 FROB (WM_STYLECHANGED)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4760 FROB (WM_DISPLAYCHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4761 FROB (WM_GETICON)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4762 FROB (WM_SETICON)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4763 #endif /* WINVER >= 0x0400 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4764
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4765 FROB (WM_NCCREATE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4766 FROB (WM_NCDESTROY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4767 FROB (WM_NCCALCSIZE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4768 FROB (WM_NCHITTEST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4769 FROB (WM_NCPAINT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4770 FROB (WM_NCACTIVATE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4771 FROB (WM_GETDLGCODE)
604
fa3b8eb89cb2 [xemacs-hg @ 2001-06-02 05:40:49 by ben]
ben
parents: 593
diff changeset
4772 #ifdef WM_SYNCPAINT /* not in VC 5 */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4773 FROB (WM_SYNCPAINT)
604
fa3b8eb89cb2 [xemacs-hg @ 2001-06-02 05:40:49 by ben]
ben
parents: 593
diff changeset
4774 #endif /* WM_SYNCPAINT */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4775 FROB (WM_NCMOUSEMOVE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4776 FROB (WM_NCLBUTTONDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4777 FROB (WM_NCLBUTTONUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4778 FROB (WM_NCLBUTTONDBLCLK)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4779 FROB (WM_NCRBUTTONDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4780 FROB (WM_NCRBUTTONUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4781 FROB (WM_NCRBUTTONDBLCLK)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4782 FROB (WM_NCMBUTTONDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4783 FROB (WM_NCMBUTTONUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4784 FROB (WM_NCMBUTTONDBLCLK)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4785
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4786 /* FROB (WM_KEYFIRST) */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4787 FROB (WM_KEYDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4788 FROB (WM_KEYUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4789 FROB (WM_CHAR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4790 FROB (WM_DEADCHAR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4791 FROB (WM_SYSKEYDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4792 FROB (WM_SYSKEYUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4793 FROB (WM_SYSCHAR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4794 FROB (WM_SYSDEADCHAR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4795 FROB (WM_KEYLAST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4796
604
fa3b8eb89cb2 [xemacs-hg @ 2001-06-02 05:40:49 by ben]
ben
parents: 593
diff changeset
4797 #if(WINVER >= 0x0400) && defined (WM_IME_STARTCOMPOSITION)
fa3b8eb89cb2 [xemacs-hg @ 2001-06-02 05:40:49 by ben]
ben
parents: 593
diff changeset
4798 /* not in Cygwin? */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4799 FROB (WM_IME_STARTCOMPOSITION)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4800 FROB (WM_IME_ENDCOMPOSITION)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4801 FROB (WM_IME_COMPOSITION)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4802 FROB (WM_IME_KEYLAST)
604
fa3b8eb89cb2 [xemacs-hg @ 2001-06-02 05:40:49 by ben]
ben
parents: 593
diff changeset
4803 #endif /* WINVER >= 0x0400 && defined (WM_IME_STARTCOMPOSITION) */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4804
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4805 FROB (WM_INITDIALOG)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4806 FROB (WM_COMMAND)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4807 FROB (WM_SYSCOMMAND)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4808 FROB (WM_TIMER)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4809 FROB (WM_HSCROLL)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4810 FROB (WM_VSCROLL)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4811 FROB (WM_INITMENU)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4812 FROB (WM_INITMENUPOPUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4813 FROB (WM_MENUSELECT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4814 FROB (WM_MENUCHAR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4815 FROB (WM_ENTERIDLE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4816 #if(WINVER >= 0x0500)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4817 FROB (WM_MENURBUTTONUP)
1687
a4b5e2effaff [xemacs-hg @ 2003-09-15 22:04:08 by james]
james
parents: 1685
diff changeset
4818 #ifdef WM_MENUDRAG
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4819 FROB (WM_MENUDRAG)
1687
a4b5e2effaff [xemacs-hg @ 2003-09-15 22:04:08 by james]
james
parents: 1685
diff changeset
4820 #endif
a4b5e2effaff [xemacs-hg @ 2003-09-15 22:04:08 by james]
james
parents: 1685
diff changeset
4821 #ifdef WM_MENUGETOBJECT
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4822 FROB (WM_MENUGETOBJECT)
1687
a4b5e2effaff [xemacs-hg @ 2003-09-15 22:04:08 by james]
james
parents: 1685
diff changeset
4823 #endif
a4b5e2effaff [xemacs-hg @ 2003-09-15 22:04:08 by james]
james
parents: 1685
diff changeset
4824 #ifdef WM_UNINITMENUPOPUP
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4825 FROB (WM_UNINITMENUPOPUP)
1687
a4b5e2effaff [xemacs-hg @ 2003-09-15 22:04:08 by james]
james
parents: 1685
diff changeset
4826 #endif
a4b5e2effaff [xemacs-hg @ 2003-09-15 22:04:08 by james]
james
parents: 1685
diff changeset
4827 #ifdef WM_MENUCOMMAND
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4828 FROB (WM_MENUCOMMAND)
1687
a4b5e2effaff [xemacs-hg @ 2003-09-15 22:04:08 by james]
james
parents: 1685
diff changeset
4829 #endif
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4830 #endif /* WINVER >= 0x0500 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4831
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4832
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4833 FROB (WM_CTLCOLORMSGBOX)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4834 FROB (WM_CTLCOLOREDIT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4835 FROB (WM_CTLCOLORLISTBOX)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4836 FROB (WM_CTLCOLORBTN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4837 FROB (WM_CTLCOLORDLG)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4838 FROB (WM_CTLCOLORSCROLLBAR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4839 FROB (WM_CTLCOLORSTATIC)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4840
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4841
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4842 /* FROB (WM_MOUSEFIRST) */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4843 FROB (WM_MOUSEMOVE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4844 FROB (WM_LBUTTONDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4845 FROB (WM_LBUTTONUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4846 FROB (WM_LBUTTONDBLCLK)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4847 FROB (WM_RBUTTONDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4848 FROB (WM_RBUTTONUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4849 FROB (WM_RBUTTONDBLCLK)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4850 FROB (WM_MBUTTONDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4851 FROB (WM_MBUTTONUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4852 FROB (WM_MBUTTONDBLCLK)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4853
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4854 #if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4855 FROB (WM_MOUSEWHEEL)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4856 FROB (WM_MOUSELAST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4857 #else
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4858 FROB (WM_MOUSELAST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4859 #endif /* if (_WIN32_WINNT < 0x0400) */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4860
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4861 FROB (WM_PARENTNOTIFY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4862 FROB (WM_ENTERMENULOOP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4863 FROB (WM_EXITMENULOOP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4864
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4865 #if(WINVER >= 0x0400)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4866 FROB (WM_NEXTMENU)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4867
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4868 FROB (WM_SIZING)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4869 FROB (WM_CAPTURECHANGED)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4870 FROB (WM_MOVING)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4871 FROB (WM_POWERBROADCAST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4872
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4873 FROB (WM_DEVICECHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4874
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4875 #endif /* WINVER >= 0x0400 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4876
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4877 FROB (WM_MDICREATE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4878 FROB (WM_MDIDESTROY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4879 FROB (WM_MDIACTIVATE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4880 FROB (WM_MDIRESTORE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4881 FROB (WM_MDINEXT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4882 FROB (WM_MDIMAXIMIZE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4883 FROB (WM_MDITILE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4884 FROB (WM_MDICASCADE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4885 FROB (WM_MDIICONARRANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4886 FROB (WM_MDIGETACTIVE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4887
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4888
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4889 FROB (WM_MDISETMENU)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4890 FROB (WM_ENTERSIZEMOVE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4891 FROB (WM_EXITSIZEMOVE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4892 FROB (WM_DROPFILES)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4893 FROB (WM_MDIREFRESHMENU)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4894
604
fa3b8eb89cb2 [xemacs-hg @ 2001-06-02 05:40:49 by ben]
ben
parents: 593
diff changeset
4895 #ifdef WM_IME_SETCONTEXT /* not in Cygwin? */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4896
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4897 #if(WINVER >= 0x0400)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4898 FROB (WM_IME_SETCONTEXT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4899 FROB (WM_IME_NOTIFY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4900 FROB (WM_IME_CONTROL)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4901 FROB (WM_IME_COMPOSITIONFULL)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4902 FROB (WM_IME_SELECT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4903 FROB (WM_IME_CHAR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4904 #endif /* WINVER >= 0x0400 */
1687
a4b5e2effaff [xemacs-hg @ 2003-09-15 22:04:08 by james]
james
parents: 1685
diff changeset
4905 #if(WINVER >= 0x0500) && defined(WM_IME_REQUEST)
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4906 FROB (WM_IME_REQUEST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4907 #endif /* WINVER >= 0x0500 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4908 #if(WINVER >= 0x0400)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4909 FROB (WM_IME_KEYDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4910 FROB (WM_IME_KEYUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4911 #endif /* WINVER >= 0x0400 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4912
604
fa3b8eb89cb2 [xemacs-hg @ 2001-06-02 05:40:49 by ben]
ben
parents: 593
diff changeset
4913 #endif /* WM_IME_SETCONTEXT */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4914
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4915 #if(_WIN32_WINNT >= 0x0400)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4916 FROB (WM_MOUSEHOVER)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4917 FROB (WM_MOUSELEAVE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4918 #endif /* _WIN32_WINNT >= 0x0400 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4919
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4920 FROB (WM_CUT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4921 FROB (WM_COPY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4922 FROB (WM_PASTE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4923 FROB (WM_CLEAR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4924 FROB (WM_UNDO)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4925 FROB (WM_RENDERFORMAT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4926 FROB (WM_RENDERALLFORMATS)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4927 FROB (WM_DESTROYCLIPBOARD)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4928 FROB (WM_DRAWCLIPBOARD)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4929 FROB (WM_PAINTCLIPBOARD)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4930 FROB (WM_VSCROLLCLIPBOARD)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4931 FROB (WM_SIZECLIPBOARD)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4932 FROB (WM_ASKCBFORMATNAME)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4933 FROB (WM_CHANGECBCHAIN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4934 FROB (WM_HSCROLLCLIPBOARD)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4935 FROB (WM_QUERYNEWPALETTE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4936 FROB (WM_PALETTEISCHANGING)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4937 FROB (WM_PALETTECHANGED)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4938 FROB (WM_HOTKEY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4939
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4940 #if(WINVER >= 0x0400)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4941 FROB (WM_PRINT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4942 FROB (WM_PRINTCLIENT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4943
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4944 FROB (WM_HANDHELDFIRST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4945 FROB (WM_HANDHELDLAST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4946
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4947 FROB (WM_AFXFIRST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4948 FROB (WM_AFXLAST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4949 #endif /* WINVER >= 0x0400 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4950
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4951 FROB (WM_PENWINFIRST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4952 FROB (WM_PENWINLAST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4953 };
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4954
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4955 #undef FROB
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4956
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4957 static void
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4958 debug_output_mswin_message (HWND hwnd, UINT message_, WPARAM wParam,
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4959 LPARAM lParam)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4960 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4961 Lisp_Object frame = mswindows_find_frame (hwnd);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4962 int i;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4963 char *str = 0;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4964 /* struct mswin_message_debug *i_hate_cranking_out_code_like_this; */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4965
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4966 for (i = 0; i < countof (debug_mswin_messages); i++)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4967 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
4968 if (debug_mswin_messages[i].mess == (int) message_)
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4969 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4970 str = debug_mswin_messages[i].string;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4971 break;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4972 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4973 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4974
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4975 if (str)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4976 stderr_out ("%s", str);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4977 else
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4978 stderr_out ("%x", message_);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4979
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4980 if (debug_mswindows_events > 1)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4981 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4982 stderr_out (" wparam=%d lparam=%d hwnd=%x frame: ",
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4983 wParam, (int) lParam, (unsigned int) hwnd);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4984 debug_print (frame);
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
4985 if (message_ == WM_WINDOWPOSCHANGED ||
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
4986 message_ == WM_WINDOWPOSCHANGING)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
4987 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
4988 WINDOWPOS *wp = (WINDOWPOS *) lParam;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
4989 stderr_out(" WINDOWPOS: x=%d, y=%d, h=%d, w=%d\n",
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
4990 wp->x, wp->y, wp->cx, wp->cy);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
4991 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
4992 else if (message_ == WM_MOVE)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
4993 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
4994 int x = (int)(short) LOWORD(lParam); /* horizontal position */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
4995 int y = (int)(short) HIWORD(lParam); /* vertical position */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
4996 stderr_out(" MOVE: x=%d, y=%d\n", x, y);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
4997 }
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
4998 else if (message_ == WM_SIZE)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
4999 {
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5000 int w = (int)(short) LOWORD(lParam); /* width */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5001 int h = (int)(short) HIWORD(lParam); /* height */
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5002 stderr_out(" SIZE: w=%d, h=%d\n", w, h);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5003 }
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
5004 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
5005 else
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
5006 stderr_out ("\n");
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
5007 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
5008
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
5009 #endif /* DEBUG_XEMACS */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
5010
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5011 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5012 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5013 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5014
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5015 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5016 reinit_vars_of_event_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5017 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5018 mswindows_pending_timers_count = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5019
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
5020 mswindows_event_stream = xnew_and_zero (struct event_stream);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5021
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5022 mswindows_event_stream->event_pending_p = emacs_mswindows_event_pending_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5023 mswindows_event_stream->next_event_cb = emacs_mswindows_next_event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5024 mswindows_event_stream->handle_magic_event_cb = emacs_mswindows_handle_magic_event;
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
5025 mswindows_event_stream->format_magic_event_cb = emacs_mswindows_format_magic_event;
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
5026 mswindows_event_stream->compare_magic_event_cb= emacs_mswindows_compare_magic_event;
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
5027 mswindows_event_stream->hash_magic_event_cb = emacs_mswindows_hash_magic_event;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5028 mswindows_event_stream->add_timeout_cb = emacs_mswindows_add_timeout;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5029 mswindows_event_stream->remove_timeout_cb = emacs_mswindows_remove_timeout;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
5030 mswindows_event_stream->drain_queue_cb = emacs_mswindows_drain_queue;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5031 mswindows_event_stream->select_console_cb = emacs_mswindows_select_console;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5032 mswindows_event_stream->unselect_console_cb = emacs_mswindows_unselect_console;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5033 mswindows_event_stream->select_process_cb = emacs_mswindows_select_process;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5034 mswindows_event_stream->unselect_process_cb = emacs_mswindows_unselect_process;
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
5035 mswindows_event_stream->create_io_streams_cb = emacs_mswindows_create_io_streams;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
5036 mswindows_event_stream->delete_io_streams_cb = emacs_mswindows_delete_io_streams;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5037 mswindows_event_stream->current_event_timestamp_cb =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5038 emacs_mswindows_current_event_timestamp;
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5039
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5040 dde_eval_pending = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5041 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5042
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5043 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5044 vars_of_event_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5045 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5046 mswindows_s_dispatch_event_queue = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5047 staticpro (&mswindows_s_dispatch_event_queue);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5048 mswindows_s_dispatch_event_queue_tail = Qnil;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 1111
diff changeset
5049 dump_add_root_lisp_object (&mswindows_s_dispatch_event_queue_tail);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5050
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
5051 mswindows_error_caught_in_modal_loop = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5052
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5053 #ifdef HAVE_DRAGNDROP
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5054 Fprovide (Qdde);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5055
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5056 DEFVAR_LISP ("dde-advise-items", &Vdde_advise_items /*
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5057 A list of allocated DDE advise items.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5058 Each item is an uninterned symbol, created using dde-alloc-advise-item.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5059
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5060 The symbol's value is the data which is returned to the DDE client when
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5061 a request for the item is made (or a dde-advise call is made).
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5062
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2828
diff changeset
5063 The symbol also has a `HSZ' property, which holds the DDE string handle
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5064 for the item, as a float. This is for internal use only, and should not
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5065 be modified.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5066 */ );
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5067 Vdde_advise_items = Qnil;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5068
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5069 dde_eval_result = Qnil;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5070 staticpro (&dde_eval_result);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5071 dde_eval_error = Qnil;
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5072 staticpro (&dde_eval_error);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5073 #endif
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5074
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5075 #ifdef DEBUG_XEMACS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5076 DEFVAR_INT ("debug-mswindows-events", &debug_mswindows_events /*
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
5077 If non-zero, display debug information about Windows messages that XEmacs sees.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5078 Information is displayed in a console window. Currently defined values are:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5079
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
5080 1 == non-verbose output (just the message name)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
5081 2 == verbose output (all parameters)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
5082 3 == even more verbose output (extra debugging info)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5083 */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5084 debug_mswindows_events = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5085 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5086
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5087 DEFVAR_BOOL ("mswindows-alt-by-itself-activates-menu",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5088 &mswindows_alt_by_itself_activates_menu /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5089 *Controls whether pressing and releasing the Alt key activates the menubar.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5090 This applies only if no intervening key was pressed. See also
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5091 `menu-accelerator-enabled', which is probably the behavior you actually want.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5092 Default is t.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5093 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5094
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5095 DEFVAR_BOOL ("mswindows-dynamic-frame-resize",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5096 &mswindows_dynamic_frame_resize /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5097 *Controls redrawing frame contents during mouse-drag or keyboard resize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5098 operation. When non-nil, the frame is redrawn while being resized. When
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5099 nil, frame is not redrawn, and exposed areas are filled with default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5100 MDI application background color. Note that this option only has effect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5101 if "Show window contents while dragging" is on in system Display/Plus!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5102 settings.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5103 Default is t on fast machines, nil on slow.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5104 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5105
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5106 DEFVAR_INT ("mswindows-mouse-button-tolerance",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5107 &mswindows_mouse_button_tolerance /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5108 *Analogue of double click interval for faking middle mouse events.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5109 The value is the minimum time in milliseconds that must elapse between
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5110 left/right button down events before they are considered distinct events.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5111 If both mouse buttons are depressed within this interval, a middle mouse
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5112 button down event is generated instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5113 If negative or zero, currently set system default is used instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5114 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5116 DEFVAR_INT ("mswindows-num-mouse-buttons", &mswindows_num_mouse_buttons /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5117 Number of physical mouse buttons.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5118 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5119
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5120 DEFVAR_INT ("mswindows-mouse-button-max-skew-x",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5121 &mswindows_mouse_button_max_skew_x /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5122 *Maximum horizontal distance in pixels between points in which left and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5123 right button clicks occurred for them to be translated into single
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5124 middle button event. Clicks must occur in time not longer than defined
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5125 by the variable `mswindows-mouse-button-tolerance'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5126 If negative or zero, currently set system default is used instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5127 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5128
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5129 DEFVAR_INT ("mswindows-mouse-button-max-skew-y",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5130 &mswindows_mouse_button_max_skew_y /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5131 *Maximum vertical distance in pixels between points in which left and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5132 right button clicks occurred for them to be translated into single
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5133 middle button event. Clicks must occur in time not longer than defined
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5134 by the variable `mswindows-mouse-button-tolerance'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5135 If negative or zero, currently set system default is used instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5136 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5138 mswindows_mouse_button_max_skew_x = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5139 mswindows_mouse_button_max_skew_y = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5140 mswindows_mouse_button_tolerance = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
5141 mswindows_alt_by_itself_activates_menu = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5142 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5144 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5145 syms_of_event_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5146 {
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5147 #ifdef HAVE_DRAGNDROP
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5148 DEFSYMBOL(QHSZ);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5149 DEFSUBR(Fdde_alloc_advise_item);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5150 DEFSUBR(Fdde_free_advise_item);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5151 DEFSUBR(Fdde_advise);
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 872
diff changeset
5152 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5153 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5155 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5156 lstream_type_create_mswindows_selectable (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5157 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
5158 #ifndef CYGWIN
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5159 init_slurp_stream ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5160 init_shove_stream ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5161 init_winsock_stream ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5162 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5163 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5165 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5166 init_event_mswindows_late (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5167 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 851
diff changeset
5168 #ifdef CYGWIN
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
5169 windows_fd = retry_open ("/dev/windows", O_RDONLY | O_NONBLOCK, 0);
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
5170 assert (windows_fd >= 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5171 FD_SET (windows_fd, &input_wait_mask);
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 800
diff changeset
5172 FD_ZERO (&zero_mask);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5173 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5174
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5175 event_stream = mswindows_event_stream;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5177 mswindows_dynamic_frame_resize = !GetSystemMetrics (SM_SLOWMACHINE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5178 mswindows_num_mouse_buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5179 }