annotate src/event-msw.c @ 800:a5954632b187

[xemacs-hg @ 2002-03-31 08:27:14 by ben] more fixes, first crack at finishing behavior implementation TODO.ben-mule-21-5: Update. configure.in: Fix for new error-checking types. make-mswin-unicode.pl: Don't be fucked up by CRLF. Output code to force errors when nonintercepted Windows calls issued. behavior.el, dumped-lisp.el, menubar-items.el: Add support for saving using custom. Load into a dumped XEmacs. Correct :title to :short-doc in accordance with behavior-defs.el. Add a submenu under Options for turning on/off behaviors. cl-macs.el: Properly document `loop'. Fix a minor bug in keymap iteration and add support for bit-vector iteration. lisp-mode.el: Rearrange and add items for macro expanding. menubar-items.el: Document connection between these two functions. window.el: Port stuff from GNU 21.1. config.inc.samp, xemacs.mak: Separate out and add new variable for controlling error-checking. s/windowsnt.h: Use new ERROR_CHECK_ALL; not related to DEBUG_XEMACS. alloc.c, backtrace.h, buffer.c, buffer.h, bytecode.c, callproc.c, casetab.c, charset.h, chartab.c, cmdloop.c, config.h.in, console-msw.c, console-stream.c, console-tty.c, console.c, console.h, data.c, device-msw.c, device.c, device.h, dired-msw.c, dired.c, dumper.c, editfns.c, eldap.c, elhash.c, emacs.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, events.c, extents.c, faces.c, file-coding.c, file-coding.h, fileio.c, frame-msw.c, frame.c, frame.h, glyphs-gtk.c, glyphs-msw.c, glyphs-shared.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, insdel.c, intl-auto-encap-win32.c, intl-auto-encap-win32.h, intl-encap-win32.c, intl-win32.c, keymap.c, lisp-union.h, lisp.h, lread.c, lrecord.h, lstream.c, lstream.h, macros.c, marker.c, md5.c, menubar-x.c, menubar.c, mule-coding.c, ntproc.c, objects-gtk.c, objects-msw.c, objects-x.c, objects.c, opaque.c, print.c, process-nt.c, process-unix.c, process.c, rangetab.c, redisplay-msw.c, redisplay-output.c, redisplay.c, regex.c, scrollbar-msw.c, select-msw.c, signal.c, specifier.c, specifier.h, symbols.c, sysdep.c, syswindows.h, text.c, text.h, toolbar-msw.c, tooltalk.c, ui-gtk.c, unicode.c, window.c: Redo error-checking macros: ERROR_CHECK_TYPECHECK -> ERROR_CHECK_TYPES, ERROR_CHECK_CHARBPOS -> ERROR_CHECK_TEXT, add ERROR_CHECK_DISPLAY, ERROR_CHECK_STRUCTURES. Document these in config.h.in. Fix code to follow docs. Fix *_checking_assert() in accordance with new names. Attempt to fix periodic redisplay crash freeing display line structures. Add first implementation of sledgehammer redisplay check. Redo print_*() to use write_fmt_string(), write_fmt_string_lisp(). Fix bug in md5 handling. Rename character-to-unicode to char-to-unicode; same for unicode-to-char{acter}. Move chartab documentation to `make-char-table'. Some header cleanup. Clean up remaining places where nonintercepted Windows calls are being used. automated/mule-tests.el: Fix for new Unicode support.
author ben
date Sun, 31 Mar 2002 08:30:17 +0000
parents e38acbeb1cae
children a634e3b7acc8
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.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4 Copyright (C) 1996, 2000, 2001, 2002 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
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
42 #include "buffer.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
43 #include "device.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
44 #include "events.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
45 #include "faces.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
46 #include "frame.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
47 #include "glyphs.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
48 #include "lstream.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
49 #include "process.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
50 #include "redisplay.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
51 #include "sysdep.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
52 #include "window.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
53
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 #include "console-msw.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
55 #include "objects-msw.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 #ifdef HAVE_SCROLLBARS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 # include "scrollbar-msw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 #ifdef HAVE_MENUBARS
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
62 # include "menubar.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 # include "menubar-msw.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 #ifdef HAVE_DRAGNDROP
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 # include "dragdrop.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
70 #include "sysfile.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 #include "sysproc.h"
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
72 #include "systime.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 #include "syswait.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 #ifdef HAVE_MSG_SELECT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 #include "console-tty.h"
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
77 #elif defined (CYGWIN)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 typedef unsigned int SOCKET;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 #ifdef HAVE_MENUBARS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 #define ADJR_MENUFLAG TRUE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 #define ADJR_MENUFLAG FALSE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 /* Fake key modifier which is attached to a quit char event.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 Removed upon dequeueing an event */
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
89 #define FAKE_MOD_QUIT (1 << 20)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
90 #define FAKE_MOD_QUIT_CRITICAL (1 << 21)
428
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 /* Timer ID used for button2 emulation */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 #define BUTTON_2_TIMER_ID 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 static Lisp_Object mswindows_find_console (HWND hwnd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 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
97 int extendedp);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
98 static int mswindows_modifier_state (BYTE *keymap, DWORD fwKeys,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
99 int has_AltGr);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 static void mswindows_set_chord_timer (HWND hwnd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 static int mswindows_button2_near_enough (POINTS p1, POINTS p2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 static int mswindows_current_layout_has_AltGr (void);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
103 static int mswindows_handle_sticky_modifiers (WPARAM wParam, LPARAM lParam,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
104 int downp, int keyp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 static struct event_stream *mswindows_event_stream;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 #ifdef HAVE_MSG_SELECT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 extern SELECT_TYPE input_wait_mask, non_fake_input_wait_mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 extern SELECT_TYPE process_only_mask, tty_only_mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 SELECT_TYPE zero_mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 extern int signal_event_pipe_initialized;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 int windows_fd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 * Two separate queues, for efficiency, one (_u_) for user events, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 * another (_s_) for non-user ones. We always return events out of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 * first one until it is empty and only then proceed with the second
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 * one.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 static Lisp_Object mswindows_u_dispatch_event_queue, mswindows_u_dispatch_event_queue_tail;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 static Lisp_Object mswindows_s_dispatch_event_queue, mswindows_s_dispatch_event_queue_tail;
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 /* The number of things we can wait on */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 #define MAX_WAITABLE (MAXIMUM_WAIT_OBJECTS - 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 #ifndef HAVE_MSG_SELECT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 /* List of mswindows waitable handles. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 static HANDLE mswindows_waitable_handles[MAX_WAITABLE];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 /* Number of wait handles */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 static int mswindows_waitable_count=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 #endif /* HAVE_MSG_SELECT */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
135
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 /* Brush for painting widgets */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 static HBRUSH widget_brush = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 static LONG last_widget_brushed = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 /* Count of quit chars currently in the queue */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 /* Incremented in WM_[SYS]KEYDOWN handler in the mswindows_wnd_proc()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 Decremented in mswindows_dequeue_dispatch_event() */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 int mswindows_quit_chars_count = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 /* These are Lisp integers; see DEFVARS in this file for description. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 int mswindows_dynamic_frame_resize;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
147 int mswindows_alt_by_itself_activates_menu;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
148 Fixnum mswindows_num_mouse_buttons;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
149 Fixnum mswindows_mouse_button_max_skew_x;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
150 Fixnum mswindows_mouse_button_max_skew_y;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
151 Fixnum mswindows_mouse_button_tolerance;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
153 #ifdef DEBUG_XEMACS
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
154 Fixnum debug_mswindows_events;
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
155
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
156 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
157 WPARAM wParam, LPARAM lParam);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
158 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
159
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 /* This is the event signaled by the event pump.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 See mswindows_pump_outstanding_events for comments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 static Lisp_Object mswindows_error_caught_in_modal_loop;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 static int mswindows_in_modal_loop;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 /* Count of wound timers */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 static int mswindows_pending_timers_count;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
167
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
168 static DWORD mswindows_last_mouse_button_state;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 /* Pipe instream - reads process output */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 #define PIPE_READ_DELAY 20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 #define HANDLE_TO_USID(h) ((USID)(h))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 #define NTPIPE_SLURP_STREAM_DATA(stream) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 LSTREAM_TYPE_DATA (stream, ntpipe_slurp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 /* This structure is allocated by the main thread, and is deallocated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 in the thread upon exit. There are situations when a thread
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 remains blocked for a long time, much longer than the lstream
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 exists. For example, "start notepad" command is issued from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 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
186 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
187 notepad process exits also, because it inherits the pipe from the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 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
189 all such processes exit. While struct ntpipe_slurp_stream is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 deallocated in this case, ntpipe_slurp_stream_shared_data are not. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 struct ntpipe_slurp_stream_shared_data
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 HANDLE hev_thread; /* Our thread blocks on this, signaled by caller */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
195 /* This is a manual-reset object. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 HANDLE hev_caller; /* Caller blocks on this, and we signal it */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
197 /* This is a manual-reset object. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 HANDLE hev_unsleep; /* Pipe read delay is canceled if this is set */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
199 /* This is a manual-reset object. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 HANDLE hpipe; /* Pipe read end handle. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 LONG die_p; /* Thread must exit ASAP if non-zero */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 BOOL eof_p : 1; /* Set when thread saw EOF */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 BOOL error_p : 1; /* Read error other than EOF/broken pipe */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 BOOL inuse_p : 1; /* this structure is in use */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 LONG lock_count; /* Client count of this struct, 0=safe to free */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 BYTE onebyte; /* One byte buffer read by thread */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 #define MAX_SLURP_STREAMS 32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 struct ntpipe_slurp_stream_shared_data
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 shared_data_block[MAX_SLURP_STREAMS]={{0}};
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 struct ntpipe_slurp_stream
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 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
216 struct ntpipe_slurp_stream_shared_data *thread_data;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
219 DEFINE_LSTREAM_IMPLEMENTATION ("ntpipe-input", ntpipe_slurp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 /* This function is thread-safe, and is called from either thread
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 context. It serializes freeing shared data structure */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 static void
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
224 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
225 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 if (InterlockedDecrement (&s->lock_count) == 0)
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 /* Destroy events */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 CloseHandle (s->hev_thread);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 CloseHandle (s->hev_caller);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 CloseHandle (s->hev_unsleep);
673
685b588e92d8 [xemacs-hg @ 2001-10-30 05:13:26 by andyp]
andyp
parents: 665
diff changeset
232 CloseHandle (s->hpipe);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 s->inuse_p = 0;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
237 static struct ntpipe_slurp_stream_shared_data *
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
238 slurper_allocate_shared_data (void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 int i=0;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
241 for (i = 0; i < MAX_SLURP_STREAMS; i++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 if (!shared_data_block[i].inuse_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
245 shared_data_block[i].inuse_p = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 return &shared_data_block[i];
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 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
249 return (struct ntpipe_slurp_stream_shared_data *)0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 static DWORD WINAPI
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 slurp_thread (LPVOID vparam)
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 struct ntpipe_slurp_stream_shared_data *s =
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
256 (struct ntpipe_slurp_stream_shared_data *)vparam;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 for (;;)
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 /* Read one byte from the pipe */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 DWORD actually_read;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 if (!ReadFile (s->hpipe, &s->onebyte, 1, &actually_read, NULL))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 DWORD err = GetLastError ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 if (err == ERROR_BROKEN_PIPE || err == ERROR_NO_DATA)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 s->eof_p = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 s->error_p = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 else if (actually_read == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 s->eof_p = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 /* We must terminate on an error or eof */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 if (s->eof_p || s->error_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 InterlockedIncrement (&s->die_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 /* Before we notify caller, we unsignal our event. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 ResetEvent (s->hev_thread);
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 /* Now we got something to notify caller, either a byte or an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 error/eof indication. Before we do, allow internal pipe
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 buffer to accumulate little bit more data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 Reader function pulses this event before waiting for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 a character, to avoid pipe delay, and to get the byte
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 immediately. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 if (!s->die_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 WaitForSingleObject (s->hev_unsleep, PIPE_READ_DELAY);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 /* Either make event loop generate a process event, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 inblock reader */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 SetEvent (s->hev_caller);
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 /* Cleanup and exit if we're shot off */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 if (s->die_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 break;
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 /* Block until the client finishes with retrieving the rest of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 pipe data */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 WaitForSingleObject (s->hev_thread, INFINITE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 slurper_free_shared_data_maybe (s);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 make_ntpipe_input_stream (HANDLE hpipe, LPARAM param)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 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
311 struct ntpipe_slurp_stream *s = NTPIPE_SLURP_STREAM_DATA (lstr);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 DWORD thread_id_unused;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 HANDLE hthread;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 /* We deal only with pipes, for we're using PeekNamedPipe api */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 assert (GetFileType (hpipe) == FILE_TYPE_PIPE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 s->thread_data = slurper_allocate_shared_data();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 /* Create reader thread. This could fail, so do not create events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 until thread is created */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 hthread = CreateThread (NULL, 0, slurp_thread, (LPVOID)s->thread_data,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 CREATE_SUSPENDED, &thread_id_unused);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 if (hthread == NULL)
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 Lstream_delete (lstr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 s->thread_data->inuse_p=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 return Qnil;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 /* Shared data are initially owned by both main and slurper
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 threads. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 s->thread_data->lock_count = 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 s->thread_data->die_p = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 s->thread_data->eof_p = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 s->thread_data->error_p = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 s->thread_data->hpipe = hpipe;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 s->user_data = param;
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 /* 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
341 s->thread_data->hev_thread = qxeCreateEvent (NULL, TRUE, TRUE, NULL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 /* 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
343 s->thread_data->hev_caller = qxeCreateEvent (NULL, TRUE, FALSE, NULL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 /* 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
345 s->thread_data->hev_unsleep = qxeCreateEvent (NULL, TRUE, FALSE, NULL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 /* Now let it go */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 ResumeThread (hthread);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 CloseHandle (hthread);
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 lstr->flags |= LSTREAM_FL_CLOSE_AT_DISKSAVE;
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
352 return wrap_lstream (lstr);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 static LPARAM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 get_ntpipe_input_stream_param (Lstream *stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
358 struct ntpipe_slurp_stream *s = NTPIPE_SLURP_STREAM_DATA(stream);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 return s->user_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 static HANDLE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 get_ntpipe_input_stream_waitable (Lstream *stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
365 struct ntpipe_slurp_stream *s = NTPIPE_SLURP_STREAM_DATA(stream);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 return s->thread_data->hev_caller;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
369 static Bytecount
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 458
diff changeset
370 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
371 Bytecount size)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 /* 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
374 struct ntpipe_slurp_stream_shared_data *s =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 NTPIPE_SLURP_STREAM_DATA(stream)->thread_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 if (!s->die_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 DWORD wait_result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 /* Disallow pipe read delay for the thread: we need a character
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 ASAP */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 SetEvent (s->hev_unsleep);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 /* 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
385 for the thread to awake from pipe delay, just ion case */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 wait_result = WaitForSingleObject (s->hev_caller, 2);
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 /* Revert to the normal sleep behavior. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 ResetEvent (s->hev_unsleep);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 /* If there's no byte buffered yet, give up */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 if (wait_result == WAIT_TIMEOUT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 errno = EAGAIN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 return -1;
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 }
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 /* Reset caller unlock event now, as we've handled the pending
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 process output event */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 ResetEvent (s->hev_caller);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 /* 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
404 changing s->die_p, which still should be interlocked */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 if (s->eof_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 if (s->error_p || s->die_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 return -1;
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 /* 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
412 pipe */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 *(data++) = s->onebyte;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 --size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415
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 DWORD bytes_read = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 if (size > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 DWORD bytes_available;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 /* If the api call fails, return at least one byte already
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 read. ReadFile in thread will return error */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 if (PeekNamedPipe (s->hpipe, NULL, 0, NULL, &bytes_available, NULL))
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 /* Fetch available bytes. The same consideration applies,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 so do not check for errors. ReadFile in the thread will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 fail if the next call fails. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 if (bytes_available)
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
431 ReadFile (s->hpipe, data, min (bytes_available, (DWORD) size),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 &bytes_read, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 /* Now we can unblock thread, so it attempts to read more */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 SetEvent (s->hev_thread);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 return bytes_read + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 }
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 return 0;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 ntpipe_slurp_closer (Lstream *stream)
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 /* 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
447 struct ntpipe_slurp_stream_shared_data *s =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 NTPIPE_SLURP_STREAM_DATA(stream)->thread_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 /* Force thread to stop */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 InterlockedIncrement (&s->die_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 /* Set events which could possibly block slurper. Let it finish soon
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 or later. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 SetEvent (s->hev_unsleep);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 /* Unlock and maybe free shared data */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 slurper_free_shared_data_maybe (s);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 return 0;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 init_slurp_stream (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 LSTREAM_HAS_METHOD (ntpipe_slurp, reader);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 LSTREAM_HAS_METHOD (ntpipe_slurp, closer);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 /* Pipe outstream - writes process input */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 #define NTPIPE_SHOVE_STREAM_DATA(stream) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 LSTREAM_TYPE_DATA (stream, ntpipe_shove)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
478 #define MAX_SHOVE_BUFFER_SIZE 512
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 struct ntpipe_shove_stream
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 LPARAM user_data; /* Any user data stored in the stream object */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 HANDLE hev_thread; /* Our thread blocks on this, signaled by caller */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
484 /* This is an auto-reset object. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 HANDLE hpipe; /* Pipe write end handle. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 HANDLE hthread; /* Reader thread handle. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 char buffer[MAX_SHOVE_BUFFER_SIZE]; /* Buffer being written */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 DWORD size; /* Number of bytes to write */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 LONG die_p; /* Thread must exit ASAP if non-zero */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 LONG idle_p; /* Non-zero if thread is waiting for job */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 BOOL error_p : 1; /* Read error other than EOF/broken pipe */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 BOOL blocking_p : 1;/* Last write attempt would cause blocking */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
495 DEFINE_LSTREAM_IMPLEMENTATION ("ntpipe-output", ntpipe_shove);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 #ifndef HAVE_MSG_SELECT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 static DWORD WINAPI
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 shove_thread (LPVOID vparam)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
501 struct ntpipe_shove_stream *s = (struct ntpipe_shove_stream *) vparam;
428
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 for (;;)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 DWORD bytes_written;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 /* Block on event and wait for a job */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 InterlockedIncrement (&s->idle_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 WaitForSingleObject (s->hev_thread, INFINITE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
511 if (s->die_p)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
512 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
513
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
514 /* Write passed buffer if any */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
515 if (s->size > 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
517 if (!WriteFile (s->hpipe, s->buffer, s->size, &bytes_written, NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
518 || bytes_written != s->size)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
519 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
520 s->error_p = TRUE;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
521 InterlockedIncrement (&s->die_p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
522 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
523 /* 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
524 die_p and kicks us */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
525 s->size = 0;
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 if (s->die_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 make_ntpipe_output_stream (HANDLE hpipe, LPARAM param)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 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
539 struct ntpipe_shove_stream *s = NTPIPE_SHOVE_STREAM_DATA (lstr);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 DWORD thread_id_unused;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 s->die_p = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 s->error_p = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 s->hpipe = hpipe;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 s->user_data = param;
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 /* Create reader thread. This could fail, so do not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 create the event until thread is created */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 s->hthread = CreateThread (NULL, 0, shove_thread, (LPVOID)s,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 CREATE_SUSPENDED, &thread_id_unused);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 if (s->hthread == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 Lstream_delete (lstr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
557 /* 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
558 on it to send things. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
559 if (!SetThreadPriority (s->hthread, THREAD_PRIORITY_HIGHEST))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
560 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
561 CloseHandle (s->hthread);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
562 Lstream_delete (lstr);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
563 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
564 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
565
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 /* 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
567 s->hev_thread = qxeCreateEvent (NULL, FALSE, FALSE, NULL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 /* Now let it go */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 ResumeThread (s->hthread);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 lstr->flags |= LSTREAM_FL_CLOSE_AT_DISKSAVE;
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
573 return wrap_lstream (lstr);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 }
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 static LPARAM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 get_ntpipe_output_stream_param (Lstream *stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
579 struct ntpipe_shove_stream *s = NTPIPE_SHOVE_STREAM_DATA(stream);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 return s->user_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
584 static Bytecount
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 458
diff changeset
585 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
586 Bytecount size)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
588 struct ntpipe_shove_stream *s = NTPIPE_SHOVE_STREAM_DATA(stream);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 if (s->error_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 s->blocking_p = !s->idle_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 if (s->blocking_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 if (size>MAX_SHOVE_BUFFER_SIZE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 memcpy (s->buffer, data, size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 s->size = size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 /* Start output */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 InterlockedDecrement (&s->idle_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 SetEvent (s->hev_thread);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
606 /* Give it a chance to run -- this dramatically improves performance
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
607 of things like crypt. */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
608 if (xSwitchToThread) /* not in Win9x */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
609 (void) xSwitchToThread ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 return size;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 ntpipe_shove_was_blocked_p (Lstream *stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
616 struct ntpipe_shove_stream *s = NTPIPE_SHOVE_STREAM_DATA(stream);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 return s->blocking_p;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 ntpipe_shove_closer (Lstream *stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
623 struct ntpipe_shove_stream *s = NTPIPE_SHOVE_STREAM_DATA(stream);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 /* Force thread stop */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 InterlockedIncrement (&s->die_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
628 /* Close pipe handle, possibly breaking it */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
629 CloseHandle (s->hpipe);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
630
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
631 /* 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
632 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
633 pending output. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 SetEvent (s->hev_thread);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 /* Wait while thread terminates */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 WaitForSingleObject (s->hthread, INFINITE);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
638
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
639 /* Close the thread handle */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 CloseHandle (s->hthread);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 /* Destroy the event */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 CloseHandle (s->hev_thread);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 init_shove_stream (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 LSTREAM_HAS_METHOD (ntpipe_shove, writer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 LSTREAM_HAS_METHOD (ntpipe_shove, was_blocked_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 LSTREAM_HAS_METHOD (ntpipe_shove, closer);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 /* Winsock I/O stream */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 #if defined (HAVE_SOCKETS) && !defined(HAVE_MSG_SELECT)
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 #define WINSOCK_READ_BUFFER_SIZE 1024
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 struct winsock_stream
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 LPARAM user_data; /* Any user data stored in the stream object */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 SOCKET s; /* Socket handle (which is a Win32 handle) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 OVERLAPPED ov; /* Overlapped I/O structure */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
668 void *buffer; /* Buffer. */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
669 DWORD bufsize; /* Number of bytes last read */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
670 DWORD charbpos; /* Position in buffer for next fetch */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 unsigned int error_p :1; /* I/O Error seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 unsigned int eof_p :1; /* EOF Error seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 unsigned int pending_p :1; /* There is a pending I/O operation */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 unsigned int blocking_p :1; /* Last write attempt would block */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 #define WINSOCK_STREAM_DATA(stream) LSTREAM_TYPE_DATA (stream, winsock)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
679 DEFINE_LSTREAM_IMPLEMENTATION ("winsock", winsock);
428
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 winsock_initiate_read (struct winsock_stream *str)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 ResetEvent (str->ov.hEvent);
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
685 str->charbpos = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 if (!ReadFile ((HANDLE)str->s, str->buffer, WINSOCK_READ_BUFFER_SIZE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 &str->bufsize, &str->ov))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 if (GetLastError () == ERROR_IO_PENDING)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 str->pending_p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 else if (GetLastError () == ERROR_HANDLE_EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 str->eof_p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 str->error_p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 else if (str->bufsize == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 str->eof_p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
701 static Bytecount
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
702 winsock_reader (Lstream *stream, unsigned char *data, Bytecount size)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 struct winsock_stream *str = WINSOCK_STREAM_DATA (stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 /* If the current operation is not yet complete, there's nothing to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 give back */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 if (str->pending_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 if (WaitForSingleObject (str->ov.hEvent, 0) == WAIT_TIMEOUT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 errno = EAGAIN;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 return -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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 if (!GetOverlappedResult ((HANDLE)str->s, &str->ov, &str->bufsize, TRUE))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 if (GetLastError() == ERROR_HANDLE_EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 str->bufsize = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 str->error_p = 1;
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 (str->bufsize == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 str->eof_p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 str->pending_p = 0;
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 }
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 if (str->eof_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 if (str->error_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 /* 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
736 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
737 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
738 str->charbpos += size;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 /* Read more if buffer is exhausted */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
741 if (str->bufsize == str->charbpos)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 winsock_initiate_read (str);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 return size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
747 static Bytecount
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 458
diff changeset
748 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
749 Bytecount size)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 struct winsock_stream *str = WINSOCK_STREAM_DATA (stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 if (str->pending_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 if (WaitForSingleObject (str->ov.hEvent, 0) == WAIT_TIMEOUT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 str->blocking_p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 DWORD dw_unused;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 if (!GetOverlappedResult ((HANDLE)str->s, &str->ov, &dw_unused, TRUE))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 str->error_p = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 str->pending_p = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 str->blocking_p = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 if (str->error_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 return -1;
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 (size == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
777 ResetEvent (str->ov.hEvent);
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
778
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
779 /* 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
780 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
781 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
782 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
783 str->buffer = xrealloc (str->buffer, size);
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
784 memcpy (str->buffer, data, size);
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
785
560
b202fbfc7dea [xemacs-hg @ 2001-05-23 11:29:58 by ben]
ben
parents: 558
diff changeset
786 /* 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
787 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
788 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
789 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
790 &str->ov)
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
791 || GetLastError() == ERROR_IO_PENDING)
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
792 str->pending_p = 1;
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
793 else
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
794 str->error_p = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 return str->error_p ? -1 : size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 winsock_closer (Lstream *lstr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 struct winsock_stream *str = WINSOCK_STREAM_DATA (lstr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 if (lstr->flags & LSTREAM_FL_READ)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 shutdown (str->s, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 shutdown (str->s, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 CloseHandle ((HANDLE)str->s);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 if (str->pending_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 WaitForSingleObject (str->ov.hEvent, INFINITE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
813 if (str->buffer)
560
b202fbfc7dea [xemacs-hg @ 2001-05-23 11:29:58 by ben]
ben
parents: 558
diff changeset
814 {
b202fbfc7dea [xemacs-hg @ 2001-05-23 11:29:58 by ben]
ben
parents: 558
diff changeset
815 xfree (str->buffer);
b202fbfc7dea [xemacs-hg @ 2001-05-23 11:29:58 by ben]
ben
parents: 558
diff changeset
816 str->buffer = 0;
b202fbfc7dea [xemacs-hg @ 2001-05-23 11:29:58 by ben]
ben
parents: 558
diff changeset
817 }
428
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 CloseHandle (str->ov.hEvent);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 return 0;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 winsock_was_blocked_p (Lstream *stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 struct winsock_stream *str = WINSOCK_STREAM_DATA (stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 return str->blocking_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 static Lisp_Object
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
831 make_winsock_stream_1 (SOCKET s, LPARAM param, const char *mode)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 Lstream *lstr = Lstream_new (lstream_winsock, mode);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 struct winsock_stream *str = WINSOCK_STREAM_DATA (lstr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835
558
ed498ef2108b [xemacs-hg @ 2001-05-23 09:59:33 by ben]
ben
parents: 546
diff changeset
836 xzero (*str);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 str->s = s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 str->user_data = param;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
840 str->ov.hEvent = qxeCreateEvent (NULL, TRUE, FALSE, NULL);
428
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 if (lstr->flags & LSTREAM_FL_READ)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 str->buffer = xmalloc (WINSOCK_READ_BUFFER_SIZE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 winsock_initiate_read (str);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 lstr->flags |= LSTREAM_FL_CLOSE_AT_DISKSAVE;
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
849 return wrap_lstream (lstr);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 make_winsock_input_stream (SOCKET s, LPARAM param)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 return make_winsock_stream_1 (s, param, "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 make_winsock_output_stream (SOCKET s, LPARAM param)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 return make_winsock_stream_1 (s, param, "w");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 }
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 static HANDLE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 get_winsock_stream_waitable (Lstream *lstr)
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 struct winsock_stream *str = WINSOCK_STREAM_DATA (lstr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 return str->ov.hEvent;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 }
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 static LPARAM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 get_winsock_stream_param (Lstream *lstr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 struct winsock_stream *str = WINSOCK_STREAM_DATA (lstr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 return str->user_data;
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 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 init_winsock_stream (void)
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 LSTREAM_HAS_METHOD (winsock, reader);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 LSTREAM_HAS_METHOD (winsock, writer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 LSTREAM_HAS_METHOD (winsock, closer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 LSTREAM_HAS_METHOD (winsock, was_blocked_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 #endif /* defined (HAVE_SOCKETS) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 /* Dispatch queue management */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 static int
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
893 mswindows_user_event_p (Lisp_Event *sevt)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 return (sevt->event_type == key_press_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 || sevt->event_type == button_press_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 || sevt->event_type == button_release_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 || sevt->event_type == misc_user_event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 }
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 * Add an emacs event to the proper dispatch queue
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
904 void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 mswindows_enqueue_dispatch_event (Lisp_Object event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 int user_p = mswindows_user_event_p (XEVENT(event));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 enqueue_event (event,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 user_p ? &mswindows_u_dispatch_event_queue :
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
910 &mswindows_s_dispatch_event_queue,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 user_p ? &mswindows_u_dispatch_event_queue_tail :
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
912 &mswindows_s_dispatch_event_queue_tail);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 /* Avoid blocking on WaitMessage */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
915 qxePostMessage (NULL, XM_BUMPQUEUE, 0, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 * Add a misc-user event to the dispatch queue.
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 * Stuff it into our own dispatch queue, so we have something
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 * to return from next_event callback.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 mswindows_enqueue_misc_user_event (Lisp_Object channel, Lisp_Object function,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 Lisp_Object object)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 Lisp_Object event = Fmake_event (Qnil, Qnil);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
929 Lisp_Event *e = XEVENT (event);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 e->event_type = misc_user_event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 e->channel = channel;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
933 e->timestamp = GetTickCount ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 e->event.misc.function = function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 e->event.misc.object = object;
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 mswindows_enqueue_dispatch_event (event);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
941 mswindows_enqueue_magic_event (HWND hwnd, UINT msg)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 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
944 Lisp_Event *event = XEVENT (emacs_event);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 event->channel = hwnd ? mswindows_find_frame (hwnd) : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 event->timestamp = GetMessageTime();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 event->event_type = magic_event;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
949 EVENT_MSWINDOWS_MAGIC_TYPE (event) = msg;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 mswindows_enqueue_dispatch_event (emacs_event);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 static void
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
955 mswindows_enqueue_process_event (Lisp_Process *p)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 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
958 Lisp_Event *event = XEVENT (emacs_event);
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
959 Lisp_Object process = wrap_process (p);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
960
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 event->event_type = process_event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 event->timestamp = GetTickCount ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 event->event.process.process = process;
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
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
970 mswindows_enqueue_mouse_button_event (HWND hwnd, UINT msg, POINTS where,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
971 int mods, DWORD when)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
973 int downp = (msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
974 msg == WM_RBUTTONDOWN);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 /* We always use last message time, because mouse button
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 events may get delayed, and XEmacs double click
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 recognition will fail */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 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
981 Lisp_Event *event = XEVENT (emacs_event);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
982
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
983 mswindows_handle_sticky_modifiers (0, 0, downp, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
984 event->channel = mswindows_find_frame (hwnd);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 event->timestamp = when;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 event->event.button.button =
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
987 (msg==WM_LBUTTONDOWN || msg==WM_LBUTTONUP) ? 1 :
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
988 ((msg==WM_RBUTTONDOWN || msg==WM_RBUTTONUP) ? 3 : 2);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 event->event.button.x = where.x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 event->event.button.y = where.y;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
991 event->event.button.modifiers = mswindows_modifier_state (NULL, mods, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
992
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
993 if (downp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 event->event_type = button_press_event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 SetCapture (hwnd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 /* we need this to make sure the main window regains the focus
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 from control subwindows */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 if (GetFocus() != hwnd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 SetFocus (hwnd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 mswindows_enqueue_magic_event (hwnd, WM_SETFOCUS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 event->event_type = button_release_event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 ReleaseCapture ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 mswindows_enqueue_dispatch_event (emacs_event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1014 static Lisp_Object
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 mswindows_enqueue_keypress_event (HWND hwnd, Lisp_Object keysym, int mods)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 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
1018 Lisp_Event *event = XEVENT(emacs_event);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 event->channel = mswindows_find_console(hwnd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 event->timestamp = GetMessageTime();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 event->event_type = key_press_event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 event->event.key.keysym = keysym;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 event->event.key.modifiers = mods;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 mswindows_enqueue_dispatch_event (emacs_event);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1026 return emacs_event;
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 * Remove and return the first emacs event on the dispatch queue.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 * Give a preference to user events over non-user ones.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 static Lisp_Object
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1034 mswindows_dequeue_dispatch_event (void)
428
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 Lisp_Object event;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1037 Lisp_Event *sevt;
428
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 assert (!NILP(mswindows_u_dispatch_event_queue) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 !NILP(mswindows_s_dispatch_event_queue));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 event = dequeue_event (
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1043 NILP(mswindows_u_dispatch_event_queue) ?
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 &mswindows_s_dispatch_event_queue :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 &mswindows_u_dispatch_event_queue,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1046 NILP(mswindows_u_dispatch_event_queue) ?
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 &mswindows_s_dispatch_event_queue_tail :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 &mswindows_u_dispatch_event_queue_tail);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
1050 sevt = XEVENT (event);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 if (sevt->event_type == key_press_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 && (sevt->event.key.modifiers & FAKE_MOD_QUIT))
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
1053 sevt->event.key.modifiers &=
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
1054 ~(FAKE_MOD_QUIT | FAKE_MOD_QUIT_CRITICAL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 return event;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 * Remove and return the first emacs event on the dispatch queue that matches
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 * the supplied event.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 * Timeout event matches if interval_id is equal to that of the given event.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 * Keypress event matches if logical AND between modifiers bitmask of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 * event in the queue and that of the given event is non-zero.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 * For all other event types, this function aborts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 Lisp_Object
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1069 mswindows_cancel_dispatch_event (Lisp_Event *match)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 Lisp_Object event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 Lisp_Object previous_event = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 int user_p = mswindows_user_event_p (match);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1074 Lisp_Object *head = user_p ? &mswindows_u_dispatch_event_queue :
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1075 &mswindows_s_dispatch_event_queue;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1076 Lisp_Object *tail = user_p ? &mswindows_u_dispatch_event_queue_tail :
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1077 &mswindows_s_dispatch_event_queue_tail;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 assert (match->event_type == timeout_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 || match->event_type == key_press_event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 EVENT_CHAIN_LOOP (event, *head)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1084 Lisp_Event *e = XEVENT (event);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 if ((e->event_type == match->event_type) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 ((e->event_type == timeout_event) ?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 (e->event.timeout.interval_id == match->event.timeout.interval_id) :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 /* Must be key_press_event */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 ((e->event.key.modifiers & match->event.key.modifiers) != 0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 if (NILP (previous_event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 dequeue_event (head, tail);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 XSET_EVENT_NEXT (previous_event, XEVENT_NEXT (event));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 if (EQ (*tail, event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 *tail = previous_event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 }
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 return event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 previous_event = event;
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 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 #ifndef HAVE_MSG_SELECT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 /* Waitable handles manipulation */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 find_waitable_handle (HANDLE h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 for (i = 0; i < mswindows_waitable_count; ++i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 if (mswindows_waitable_handles[i] == h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 return i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 static BOOL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 add_waitable_handle (HANDLE h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 assert (find_waitable_handle (h) < 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 if (mswindows_waitable_count == MAX_WAITABLE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 return FALSE;
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 mswindows_waitable_handles [mswindows_waitable_count++] = h;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 remove_waitable_handle (HANDLE h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 int ix = find_waitable_handle (h);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 if (ix < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 mswindows_waitable_handles [ix] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 mswindows_waitable_handles [--mswindows_waitable_count];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 #endif /* HAVE_MSG_SELECT */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144
791
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1145 /*
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1146 * 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
1147 * 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
1148 * 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
1149 * 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
1150 * 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
1151 */
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1152 void
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1153 mswindows_unwait_process (Lisp_Process *p)
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1154 {
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1155 #ifndef HAVE_MSG_SELECT
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1156 remove_waitable_handle (get_nt_process_handle (p));
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1157 #endif /* HAVE_MSG_SELECT */
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1158 }
7b1f30330a19 [xemacs-hg @ 2002-03-21 18:55:01 by adrian]
adrian
parents: 788
diff changeset
1159
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 /* Event pump */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1165 int
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1166 mswindows_window_is_xemacs (HWND hwnd)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1167 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1168 /* 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
1169 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
1170 if the name is longer than XEMACS_CLASS */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1171 Extbyte class_name_buf[sizeof (XEMACS_CLASS) + 2];
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1172
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1173 /* 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
1174 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
1175 return 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1176
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1177 return !ascii_strcasecmp (class_name_buf, XEMACS_CLASS);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1178 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1179
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 mswindows_modal_loop_error_handler (Lisp_Object cons_sig_data,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 Lisp_Object u_n_u_s_e_d)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 mswindows_error_caught_in_modal_loop = cons_sig_data;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 return Qunbound;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 mswindows_protect_modal_loop (Lisp_Object (*bfun) (Lisp_Object barg),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 Lisp_Object barg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 Lisp_Object tmp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 ++mswindows_in_modal_loop;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 tmp = condition_case_1 (Qt,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 bfun, barg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 mswindows_modal_loop_error_handler, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 --mswindows_in_modal_loop;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 return tmp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 mswindows_unmodalize_signal_maybe (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 if (!NILP (mswindows_error_caught_in_modal_loop))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 /* Got an error while messages were pumped while
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 in window procedure - have to resignal */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 Lisp_Object sym = XCAR (mswindows_error_caught_in_modal_loop);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 Lisp_Object data = XCDR (mswindows_error_caught_in_modal_loop);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 mswindows_error_caught_in_modal_loop = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 Fsignal (sym, data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 }
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
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 * This is an unsafe part of event pump, guarded by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 * condition_case. See mswindows_pump_outstanding_events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 mswindows_unsafe_pump_events (Lisp_Object u_n_u_s_e_d)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 Lisp_Object event = Fmake_event (Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 int do_redisplay = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 GCPRO1 (event);
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 while (detect_input_pending ())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 Fnext_event (event, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 Fdispatch_event (event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234 do_redisplay = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 if (do_redisplay)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 redisplay ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 Fdeallocate_event (event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243 /* Qt becomes return value of mswindows_pump_outstanding_events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 once we get here */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 return Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246 }
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 * This function pumps emacs events, while available, by using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 * next_message/dispatch_message loop. Errors are trapped around
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 * the loop so the function always returns.
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 * Windows message queue is not looked into during the call,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 * neither are waitable handles checked. The function pumps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 * thus only dispatch events already queued, as well as those
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 * resulted in dispatching thereof. This is done by setting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257 * module local variable mswindows_in_modal_loop to nonzero.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 * Return value is Qt if no errors was trapped, or Qunbound if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260 * there was an error.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262 * In case of error, a cons representing the error, in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263 * form (SIGNAL . DATA), is stored in the module local variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 * mswindows_error_caught_in_modal_loop. This error is signaled
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265 * again when DispatchMessage returns. Thus, Windows internal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 * modal loops are protected against throws, which are proven
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267 * to corrupt internal Windows structures.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269 * In case of success, mswindows_error_caught_in_modal_loop is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 * assigned Qnil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272 * If the value of mswindows_error_caught_in_modal_loop is not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 * nil already upon entry, the function just returns non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 * This situation means that a new event has been queued while
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 * in cancel mode. The event will be dequeued on the next regular
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 * call of next-event; the pump is off since error is caught.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 * The caller must *unconditionally* cancel modal loop if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 * value returned by this function is nil. Otherwise, everything
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 * will become frozen until the modal loop exits under normal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 * condition (scrollbar drag is released, menu closed etc.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 mswindows_pump_outstanding_events (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 /* This function can call lisp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 Lisp_Object result = Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 GCPRO1 (result);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 if (NILP(mswindows_error_caught_in_modal_loop))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1292 result = mswindows_protect_modal_loop (mswindows_unsafe_pump_events, Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1297 /*
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1298 * KEYBOARD_ONLY_P is set to non-zero when we are called from
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1299 * QUITP, and are interesting in keyboard messages only.
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1300 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1302 mswindows_drain_windows_queue (void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 MSG msg;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1305
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1306 /* should call mswindows_need_event_in_modal_loop() if in modal loop */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1307 assert (!mswindows_in_modal_loop);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1308
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1309 while (qxePeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1311 #ifdef HAVE_DIALOGS
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1312 /* Don't translate messages destined for a dialog box, this
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1313 makes keyboard traversal work. I think?? */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1314 if (mswindows_is_dialog_msg (&msg))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1315 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1316 mswindows_unmodalize_signal_maybe ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1317 continue;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1318 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1319 #endif /* HAVE_DIALOGS */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1320
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1321 /* We have to translate messages that are not sent to an XEmacs
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1322 frame. This is so that key presses work ok in things like
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1323 edit fields. However, we *musn't* translate message for XEmacs
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1324 frames as this is handled in the wnd proc.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1325 We also have to avoid generating paint magic events for windows
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1326 that aren't XEmacs frames */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1327
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1328 if (!mswindows_window_is_xemacs (msg.hwnd))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1329 TranslateMessage (&msg);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1330 else if (msg.message == WM_PAINT)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1331 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1332 struct mswindows_frame *msframe;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1333
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1334 /* 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
1335 shouldn't have received a paint message for it here. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1336 assert (msg.wParam == 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1337
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1338 /* Queue a magic event for handling when safe */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1339 msframe =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1340 FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (msg.hwnd)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1341 if (!msframe->paint_pending)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1342 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1343 msframe->paint_pending = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1344 mswindows_enqueue_magic_event (msg.hwnd, WM_PAINT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1345 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1346 /* Don't dispatch. WM_PAINT is always the last message in the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1347 queue so it's OK to just return. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1348 return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1349 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1350 qxeDispatchMessage (&msg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 mswindows_unmodalize_signal_maybe ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 * This is a special flavor of the mswindows_need_event function,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 * used while in event pump. Actually, there is only kind of events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 * allowed while in event pump: a timer. An attempt to fetch any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 * 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
1360 * ('cause event pump mirrors windows modal loop, which is a sole
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 * owner of thread message queue).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 * To detect this, we use a counter of active timers, and allow
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 * fetching WM_TIMER messages. Instead of trying to fetch a WM_TIMER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365 * which will never come when there are no pending timers, which leads
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 * to deadlock, we simply signal an error.
487
54fa1a5c2d12 [xemacs-hg @ 2001-04-28 07:48:36 by ben]
ben
parents: 464
diff changeset
1367 *
54fa1a5c2d12 [xemacs-hg @ 2001-04-28 07:48:36 by ben]
ben
parents: 464
diff changeset
1368 * 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
1369 * 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
1370 * whether the result would be more complex than is justified.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 mswindows_need_event_in_modal_loop (int badly_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 MSG msg;
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 /* Check if already have one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378 if (!NILP (mswindows_u_dispatch_event_queue)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 || !NILP (mswindows_s_dispatch_event_queue))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380 return;
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 /* No event is ok */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 if (!badly_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386 /* We do not check the _u_ queue, because timers go to _s_ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 while (NILP (mswindows_s_dispatch_event_queue))
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 /* We'll deadlock if go waiting */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 if (mswindows_pending_timers_count == 0)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 560
diff changeset
1391 invalid_operation ("Deadlock due to an attempt to call next-event in a wrong context", Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393 /* Fetch and dispatch any pending timers */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1394 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
1395 qxeDispatchMessage (&msg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 * This drains the event queue and fills up two internal queues until
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 * an event of a type specified by USER_P is retrieved.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 * Used by emacs_mswindows_event_pending_p and emacs_mswindows_next_event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407 mswindows_need_event (int badly_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 while (NILP (mswindows_u_dispatch_event_queue)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410 && NILP (mswindows_s_dispatch_event_queue))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 #ifdef HAVE_MSG_SELECT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 int i;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
1414 int active;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 SELECT_TYPE temp_mask = input_wait_mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 EMACS_TIME sometime;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417 EMACS_SELECT_TIME select_time_to_block, *pointer_to_this;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1419 if (badly_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 pointer_to_this = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 EMACS_SET_SECS_USECS (sometime, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 EMACS_TIME_TO_SELECT_TIME (sometime, select_time_to_block);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425 pointer_to_this = &select_time_to_block;
534
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1426 if (mswindows_in_modal_loop)
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1427 /* 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
1428 Windows events. */
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1429 FD_CLR (windows_fd, &temp_mask);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 active = select (MAXDESC, &temp_mask, 0, 0, pointer_to_this);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434 if (active == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436 assert (!badly_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 return; /* timeout */
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 else if (active > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441 if (FD_ISSET (windows_fd, &temp_mask))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 {
534
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1443 if (mswindows_in_modal_loop)
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1444 mswindows_need_event_in_modal_loop (badly_p);
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1445 else
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1446 mswindows_drain_windows_queue ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1448 else
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1450 #ifdef HAVE_TTY
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1451 /* Look for a TTY event */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1452 for (i = 0; i < MAXDESC-1; i++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1454 /* To avoid race conditions (among other things, an infinite
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1455 loop when called from Fdiscard_input()), we must return
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1456 user events ahead of process events. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1457 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
1458 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1459 struct console *c = tty_find_console_from_fd (i);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1460 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
1461 Lisp_Event *event = XEVENT (emacs_event);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1462
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1463 assert (c);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1464 if (read_event_from_tty_or_stream_desc (event, c))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1465 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1466 mswindows_enqueue_dispatch_event (emacs_event);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1467 return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1468 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471 #endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1472 /* Look for a process event */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1473 for (i = 0; i < MAXDESC-1; i++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1474 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1475 if (FD_ISSET (i, &temp_mask))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1477 if (FD_ISSET (i, &process_only_mask))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1478 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1479 Lisp_Process *p =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1480 get_process_from_usid (FD_TO_USID(i));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1481
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1482 mswindows_enqueue_process_event (p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1483 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1484 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1485 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1486 /* We might get here when a fake event came
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1487 through a signal. Return a dummy event, so
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1488 that a cycle of the command loop will
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1489 occur. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1490 drain_signal_event_pipe ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1491 mswindows_enqueue_magic_event (NULL, XM_BUMPQUEUE);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1492 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1497 else if (active == -1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 if (errno != EINTR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 /* something bad happened */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 assert(0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507 assert(0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 }
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
1509 #else /* not HAVE_MSG_SELECT */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510 /* 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
1511 DWORD active;
487
54fa1a5c2d12 [xemacs-hg @ 2001-04-28 07:48:36 by ben]
ben
parents: 464
diff changeset
1512 DWORD what_events;
54fa1a5c2d12 [xemacs-hg @ 2001-04-28 07:48:36 by ben]
ben
parents: 464
diff changeset
1513 if (mswindows_in_modal_loop)
534
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1514 /* 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
1515 we really need one. */
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1516 {
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1517 if (badly_p)
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1518 what_events = QS_TIMER;
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1519 else
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1520 what_events = 0;
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1521 }
487
54fa1a5c2d12 [xemacs-hg @ 2001-04-28 07:48:36 by ben]
ben
parents: 464
diff changeset
1522 else
534
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1523 /* Look for any event */
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1524 what_events = QS_ALLINPUT;
487
54fa1a5c2d12 [xemacs-hg @ 2001-04-28 07:48:36 by ben]
ben
parents: 464
diff changeset
1525
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1526 /*
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1527 #### YUCK YUCK YUCK!!!!
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 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
1530 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
1531
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1532 NTDLL! DbgBreakPoint@0 address 0x77f9eea9
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1533 KERNEL32! BaseAttachComplete@4 + 41 bytes
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1534 KERNEL32! BaseAttachCompleteThunk@0 + 19 bytes
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1535 USER32! MsgWaitForMultipleObjectsEx@20 + 224 bytes
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1536 USER32! MsgWaitForMultipleObjects@20 + 30 bytes
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 Microsoft says:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1539
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1540 (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
1541 Exception When Debugging)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1542
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1543 CAUSE
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1544
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1545 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
1546 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
1547 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
1548 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
1549
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1550 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
1551 as WinDbg from the Windows 32-bit SDK.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1552
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1553 RESOLUTION
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1554
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1555 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
1556 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
1557 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
1558 the F5 key.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1559
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1560 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
1561 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
1562 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
1563
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1564 STATUS
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1565
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1566 This behavior is by design.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1567
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1568
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1569 However, elsewhere I found this:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1570
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1571 UserDebuggerHotKey
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1572 HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1573
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1574 Data type Range Default value
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1575 REG_DWORD 0x0 - 0xFF 0x0
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1576
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1577 Description
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1578
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1579 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
1580 code being debugged.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1581
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1582 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
1583 programmer can examine a suspected problem.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1584
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1585 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
1586 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
1587 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
1588 mode.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1589
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1590 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
1591 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
1592 (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
1593 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1594
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1595 __try
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1596 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1597 active = MsgWaitForMultipleObjects (mswindows_waitable_count,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1598 mswindows_waitable_handles,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1599 FALSE, badly_p ? INFINITE : 0,
534
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1600 what_events);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1601 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1602 __except (GetExceptionCode () == EXCEPTION_BREAKPOINT ?
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1603 EXCEPTION_CONTINUE_EXECUTION :
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1604 EXCEPTION_CONTINUE_SEARCH)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1605 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1606 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1607
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1608 /* This will assert if handle being waited for becomes abandoned.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1609 Not the case currently tho */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1610 assert ((!badly_p && active == WAIT_TIMEOUT) ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1611 (active >= WAIT_OBJECT_0 &&
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1612 active <= WAIT_OBJECT_0 + mswindows_waitable_count));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1613
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1614 if (active == WAIT_TIMEOUT)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1615 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1616 /* No luck trying - just return what we've already got */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1617 return;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1618 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1619 else if (active == WAIT_OBJECT_0 + mswindows_waitable_count)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1620 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1621 /* Got your message, thanks */
534
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1622 if (mswindows_in_modal_loop)
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1623 mswindows_need_event_in_modal_loop (badly_p);
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1624 else
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1625 mswindows_drain_windows_queue ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1626 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1627 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1628 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1629 int ix = active - WAIT_OBJECT_0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1630 /* First, try to find which process' output has signaled */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1631 Lisp_Process *p =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1632 get_process_from_usid (HANDLE_TO_USID (mswindows_waitable_handles[ix]));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1633 if (p != NULL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1634 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1635 /* Found a signaled process input handle */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1636 mswindows_enqueue_process_event (p);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1637 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1638 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1639 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1640 /* None. This means that the process handle itself has signaled.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1641 Remove the handle from the wait vector, and make status_notify
534
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1642 note the exited process. First find the process object if
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1643 possible. */
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1644 LIST_LOOP_3 (vaffanculo, Vprocess_list, vproctail)
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1645 if (get_nt_process_handle (XPROCESS (vaffanculo)) ==
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1646 mswindows_waitable_handles [ix])
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1647 break;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1648 mswindows_waitable_handles [ix] =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1649 mswindows_waitable_handles [--mswindows_waitable_count];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1650 kick_status_notify ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1651 /* We need to return a process event here so that
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1652 (1) accept-process-output will return when called on this
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1653 process, and (2) status notifications will happen in
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1654 accept-process-output, sleep-for, and sit-for. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1655 /* #### horrible kludge till my real process fixes go in.
534
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1656 #### Replaced with a slightly less horrible kluge that
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1657 at least finds the right process instead of axing the
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1658 first one on the list.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1659 */
534
a0266879cecf [xemacs-hg @ 2001-05-14 04:16:17 by mta]
mta
parents: 531
diff changeset
1660 if (!NILP (vproctail))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1661 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1662 mswindows_enqueue_process_event (XPROCESS (vaffanculo));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1663 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1664 else /* trash me soon. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1665 /* Have to return something: there may be no accompanying
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1666 process event */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1667 mswindows_enqueue_magic_event (NULL, XM_BUMPQUEUE);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1668 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1669 }
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
1670 #endif /* not HAVE_MSG_SELECT */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1671 } /* while */
428
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
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 /* Event generators */
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
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 * Callback procedure for synchronous timer messages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1680 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681 static void CALLBACK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 mswindows_wm_timer_callback (HWND hwnd, UINT umsg, UINT id_timer, DWORD dwtime)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1685 Lisp_Event *event = XEVENT (emacs_event);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687 if (KillTimer (NULL, id_timer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 --mswindows_pending_timers_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690 event->channel = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691 event->timestamp = dwtime;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692 event->event_type = timeout_event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 event->event.timeout.interval_id = id_timer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694 event->event.timeout.function = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695 event->event.timeout.object = Qnil;
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 mswindows_enqueue_dispatch_event (emacs_event);
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
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 * Callback procedure for dde messages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1702 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1703 * 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
1704 * depends on dnd support.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1705 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1706 #ifdef HAVE_DRAGNDROP
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 656
diff changeset
1707 extern int mswindows_dde_enable;
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 656
diff changeset
1708
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709 HDDEDATA CALLBACK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1710 mswindows_dde_callback (UINT uType, UINT uFmt, HCONV hconv,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1711 HSZ hszTopic, HSZ hszItem, HDDEDATA hdata,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1712 DWORD dwData1, DWORD dwData2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1713 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714 switch (uType)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1715 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1716 case XTYP_CONNECT:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1717 if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1718 return (HDDEDATA)TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1719 return (HDDEDATA)FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1720
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1721 case XTYP_WILDCONNECT:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1722 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1723 /* We only support one {service,topic} pair */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1724 HSZPAIR pairs[2] =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1725 {
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1726 { mswindows_dde_service, mswindows_dde_topic_system }, { 0, 0 } };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1727
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1728 if (!(hszItem
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1729 || DdeCmpStringHandles (hszItem, mswindows_dde_service)) &&
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1730 !(hszTopic
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1731 || DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1732 return (DdeCreateDataHandle (mswindows_dde_mlid, (LPBYTE)pairs,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1733 sizeof (pairs), 0L, 0, uFmt, 0));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1734 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735 return (HDDEDATA)NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1736
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1737 case XTYP_EXECUTE:
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 656
diff changeset
1738 if (!mswindows_dde_enable)
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 656
diff changeset
1739 return (HDDEDATA) DDE_FBUSY;
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 656
diff changeset
1740
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1741 if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1742 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1743 DWORD len = DdeGetData (hdata, NULL, 0, 0);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1744 LPBYTE extcmd = (LPBYTE) alloca (len+1);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1745 Intbyte *cmd;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1746 Intbyte *end;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1747 struct gcpro gcpro1, gcpro2;
657
ce0b3f2eff35 [xemacs-hg @ 2001-09-09 04:37:41 by andyp]
andyp
parents: 656
diff changeset
1748 Lisp_Object l_dndlist = Qnil;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1749 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1750 Lisp_Object frmcons, devcons, concons;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1751 Lisp_Event *event = XEVENT (emacs_event);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1752
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1753 DdeGetData (hdata, extcmd, len, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1754 DdeFreeDataHandle (hdata);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1755
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1756 TO_INTERNAL_FORMAT (DATA, (extcmd, len),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1757 C_STRING_ALLOCA, cmd,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1758 Qmswindows_tstr);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1759
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1760 /* Check syntax & that it's an [Open("foo")] command, which we
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1761 * treat like a file drop */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1762 /* #### Ought to be generalised and accept some other commands */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1763 if (*cmd == '[')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1764 cmd++;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1765 if (qxestrncasecmp_c (cmd, MSWINDOWS_DDE_ITEM_OPEN,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1766 strlen (MSWINDOWS_DDE_ITEM_OPEN)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1767 return DDE_FNOTPROCESSED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1768 cmd += strlen (MSWINDOWS_DDE_ITEM_OPEN);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1769 while (*cmd == ' ')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1770 cmd++;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1771 if (*cmd != '(' || *(cmd + 1) != '\"')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1772 return DDE_FNOTPROCESSED;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1773 end = (cmd += 2);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1774 while (*end && *end != '\"')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1775 end++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1776 if (!*end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1777 return DDE_FNOTPROCESSED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1778 *end = '\0';
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1779 if (*++end != ')')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1780 return DDE_FNOTPROCESSED;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1781 if (*++end == ']')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1782 end++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1783 if (*end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1784 return DDE_FNOTPROCESSED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1785
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1786 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1787 /* 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
1788 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
1789 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
1790 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
1791
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1792 file:///C|/foo/bar/ or equivalently
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1793 file:///C:/foo/bar/ (less portably)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1794
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1795 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
1796 cmd = urlify_filename (cmd);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1797 l_dndlist = build_intstring (cmd);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1798 xfree (cmd);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
1799 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1800 GCPRO2 (emacs_event, l_dndlist);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1801
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1802 /* Find a mswindows frame */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1803 event->channel = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1804 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1805 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1806 Lisp_Object frame = XCAR (frmcons);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1807 if (FRAME_TYPE_P (XFRAME (frame), mswindows))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1808 event->channel = frame;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1809 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1810 assert (!NILP (event->channel));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1811
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1812 event->timestamp = GetTickCount();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1813 event->event_type = misc_user_event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1814 event->event.misc.button = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1815 event->event.misc.modifiers = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1816 event->event.misc.x = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1817 event->event.misc.y = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1818 event->event.misc.function = Qdragdrop_drop_dispatch;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1819 event->event.misc.object = Fcons (Qdragdrop_URL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1820 Fcons (l_dndlist, Qnil));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1821 mswindows_enqueue_dispatch_event (emacs_event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1822 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1823 return (HDDEDATA) DDE_FACK;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1824 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1825 DdeFreeDataHandle (hdata);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1826 return (HDDEDATA) DDE_FNOTPROCESSED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1827
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1828 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1829 return (HDDEDATA) NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1830 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1831 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1832 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1833
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1834 /*
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1835 * Helper to do repainting - repaints can happen both from the windows
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1836 * procedure and from magic events
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1837 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1838 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1839 mswindows_handle_paint (struct frame *frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1840 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1841 HWND hwnd = FRAME_MSWINDOWS_HANDLE (frame);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1842
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1843 /* According to the docs we need to check GetUpdateRect() before
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1844 actually doing a WM_PAINT */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1845 if (GetUpdateRect (hwnd, NULL, FALSE))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1846 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1847 PAINTSTRUCT paintStruct;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1848 int x, y, width, height;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1849
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1850 BeginPaint (hwnd, &paintStruct);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1851 x = paintStruct.rcPaint.left;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1852 y = paintStruct.rcPaint.top;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1853 width = paintStruct.rcPaint.right - paintStruct.rcPaint.left;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1854 height = paintStruct.rcPaint.bottom - paintStruct.rcPaint.top;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1855 /* Normally we want to ignore expose events when child
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1856 windows are unmapped, however once we are in the guts of
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1857 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
1858 unmaps then because they will not actually occur. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1859 /* #### commenting out the next line seems to fix some problems
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1860 but not all. only andy currently understands this stuff and
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1861 he needs to review it more carefully. --ben */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1862 if (!check_for_ignored_expose (frame, x, y, width, height))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1863 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1864 hold_ignored_expose_registration = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1865 mswindows_redraw_exposed_area (frame, x, y, width, height);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1866 hold_ignored_expose_registration = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1867 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1868 EndPaint (hwnd, &paintStruct);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1869 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1870 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1871
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1872 /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1873 * 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
1874 * is better handled by DefWindowProc
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1875 */
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1876 static int
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1877 key_needs_default_processing_p (UINT vkey)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1878 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1879 if (mswindows_alt_by_itself_activates_menu && vkey == VK_MENU
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1880 /* 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
1881 keystrokes become impossible. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1882 && !modifier_keys_are_sticky)
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1883 return 1;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1884
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1885 return 0;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1886 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
1887
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1888 /* 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
1889 that way.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1890
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1891 #### Most of the sticky-modifier code below is copied from similar
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1892 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
1893
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1894 Here are some pointers:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1895
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1896 -- DOWN_MASK indicates which modifiers should be treated as "down"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1897 when the corresponding upstroke happens. It gets reset for
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1898 a particular modifier when that modifier goes up, and reset
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1899 for all modifiers when a non-modifier key is pressed. Example:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1900
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1901 I press Control-A-Shift and then release Control-A-Shift.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1902 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
1903
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1904 -- 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
1905 the modifier key again. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1906
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1907 static WPARAM last_downkey;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1908 static int need_to_add_mask, down_mask;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1909
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1910 #define XEMSW_LCONTROL (1<<0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1911 #define XEMSW_RCONTROL (1<<1)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1912 #define XEMSW_LSHIFT (1<<2)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1913 #define XEMSW_RSHIFT (1<<3)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1914 #define XEMSW_LMENU (1<<4)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1915 #define XEMSW_RMENU (1<<5)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1916
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1917 static int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1918 mswindows_handle_sticky_modifiers (WPARAM wParam, LPARAM lParam,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1919 int downp, int keyp)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1920 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1921 int mods = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1922
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1923 if (!modifier_keys_are_sticky) /* Optimize for non-sticky modifiers */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1924 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1925
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1926 if (! (keyp &&
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1927 (wParam == VK_CONTROL || wParam == VK_LCONTROL ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1928 wParam == VK_RCONTROL ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1929 wParam == VK_MENU || wParam == VK_LMENU ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1930 wParam == VK_RMENU ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1931 wParam == VK_SHIFT || wParam == VK_LSHIFT ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1932 wParam == VK_RSHIFT)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1933 { /* Not a modifier key */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1934 if (downp && keyp && !last_downkey)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1935 last_downkey = wParam;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1936 /* 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
1937 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
1938 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
1939 manually press the Right arrow a bunch of times, I want
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1940 to see one Control-Right and then a bunch of Rights.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1941 This means that we need to distinguish between an
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1942 auto-repeated key and a key pressed and released a bunch
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1943 of times. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1944 else if ((downp && !keyp) ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1945 (downp && keyp && last_downkey &&
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1946 (wParam != last_downkey ||
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1947 /* the "previous key state" bit indicates autorepeat */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1948 ! (lParam & (1 << 30)))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1949 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1950 need_to_add_mask = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1951 last_downkey = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1952 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1953 if (downp)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1954 down_mask = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1955
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1956 mods = need_to_add_mask;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1957 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1958 else /* Modifier key pressed */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1959 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1960 /* 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
1961 of modifiers, then it unsticks all the modifiers that were
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1962 previously pressed. We cannot unstick the modifiers until
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1963 now because we want to check for auto-repeat of the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1964 non-modifier key. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1965
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1966 if (last_downkey)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1967 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1968 last_downkey = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1969 need_to_add_mask = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1970 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1971
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1972 #define FROB(mask) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1973 do { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1974 if (downp && keyp) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1975 { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1976 /* If modifier key is already sticky, \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1977 then unstick it. Note that we do \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1978 not test down_mask to deal with the \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1979 unlikely but possible case that the \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1980 modifier key auto-repeats. */ \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1981 if (need_to_add_mask & mask) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1982 { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1983 need_to_add_mask &= ~mask; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1984 down_mask &= ~mask; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1985 } \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1986 else \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1987 down_mask |= mask; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1988 } \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1989 else \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1990 { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1991 if (down_mask & mask) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1992 { \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1993 down_mask &= ~mask; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1994 need_to_add_mask |= mask; \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1995 } \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1996 } \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1997 } while (0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1998
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1999 if ((wParam == VK_CONTROL && (lParam & 0x1000000))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2000 || wParam == VK_RCONTROL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2001 FROB (XEMSW_RCONTROL);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2002 if ((wParam == VK_CONTROL && !(lParam & 0x1000000))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2003 || wParam == VK_LCONTROL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2004 FROB (XEMSW_LCONTROL);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2005
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2006 if ((wParam == VK_SHIFT && (lParam & 0x1000000))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2007 || wParam == VK_RSHIFT)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2008 FROB (XEMSW_RSHIFT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2009 if ((wParam == VK_SHIFT && !(lParam & 0x1000000))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2010 || wParam == VK_LSHIFT)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2011 FROB (XEMSW_LSHIFT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2012
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2013 if ((wParam == VK_MENU && (lParam & 0x1000000))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2014 || wParam == VK_RMENU)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2015 FROB (XEMSW_RMENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2016 if ((wParam == VK_MENU && !(lParam & 0x1000000))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2017 || wParam == VK_LMENU)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2018 FROB (XEMSW_LMENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2019 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2020 #undef FROB
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2021
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2022 if (mods && downp)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2023 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2024 BYTE keymap[256];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2025
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2026 GetKeyboardState (keymap);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2027
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2028 if (mods & XEMSW_LCONTROL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2029 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2030 keymap [VK_CONTROL] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2031 keymap [VK_LCONTROL] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2032 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2033 if (mods & XEMSW_RCONTROL)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2034 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2035 keymap [VK_CONTROL] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2036 keymap [VK_RCONTROL] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2037 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2038
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2039 if (mods & XEMSW_LSHIFT)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2040 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2041 keymap [VK_SHIFT] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2042 keymap [VK_LSHIFT] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2043 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2044 if (mods & XEMSW_RSHIFT)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2045 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2046 keymap [VK_SHIFT] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2047 keymap [VK_RSHIFT] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2048 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2049
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2050 if (mods & XEMSW_LMENU)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2051 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2052 keymap [VK_MENU] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2053 keymap [VK_LMENU] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2054 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2055 if (mods & XEMSW_RMENU)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2056 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2057 keymap [VK_MENU] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2058 keymap [VK_RMENU] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2059 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2060
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2061 SetKeyboardState (keymap);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2062 return 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2063 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2064
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2065 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2066 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2067
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2068 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2069 clear_sticky_modifiers (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2070 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2071 need_to_add_mask = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2072 last_downkey = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2073 down_mask = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2074 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2075
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2076 #ifdef DEBUG_XEMACS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2077
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2078 #if 0
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2079
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2080 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2081 output_modifier_keyboard_state (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2082 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2083 BYTE keymap[256];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2084
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2085 GetKeyboardState (keymap);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2086
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2087 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
2088 keymap[VK_MENU] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2089 keymap[VK_MENU] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2090 keymap[VK_LMENU] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2091 keymap[VK_LMENU] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2092 keymap[VK_RMENU] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2093 keymap[VK_RMENU] & 0x1 ? 1 : 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2094 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
2095 keymap[VK_CONTROL] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2096 keymap[VK_CONTROL] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2097 keymap[VK_LCONTROL] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2098 keymap[VK_LCONTROL] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2099 keymap[VK_RCONTROL] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2100 keymap[VK_RCONTROL] & 0x1 ? 1 : 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2101 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
2102 keymap[VK_SHIFT] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2103 keymap[VK_SHIFT] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2104 keymap[VK_LSHIFT] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2105 keymap[VK_LSHIFT] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2106 keymap[VK_RSHIFT] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2107 keymap[VK_RSHIFT] & 0x1 ? 1 : 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2108 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2109
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2110 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2111
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2112 /* try to debug the stuck-alt-key problem.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2113
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2114 #### this happens only inconsistently, and may only happen when using
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2115 StickyKeys in the Win2000 accessibility section of the control panel,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2116 which is extremely broken for other reasons. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2117
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2118 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2119 output_alt_keyboard_state (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2120 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2121 BYTE keymap[256];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2122 SHORT keystate[3];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2123 // SHORT asyncstate[3];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2124
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2125 GetKeyboardState (keymap);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2126 keystate[0] = GetKeyState (VK_MENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2127 keystate[1] = GetKeyState (VK_LMENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2128 keystate[2] = GetKeyState (VK_RMENU);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2129 /* Doing this interferes with key processing. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2130 /* asyncstate[0] = GetAsyncKeyState (VK_MENU); */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2131 /* asyncstate[1] = GetAsyncKeyState (VK_LMENU); */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2132 /* asyncstate[2] = GetAsyncKeyState (VK_RMENU); */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2133
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2134 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
2135 keymap[VK_MENU] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2136 keymap[VK_MENU] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2137 keymap[VK_LMENU] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2138 keymap[VK_LMENU] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2139 keymap[VK_RMENU] & 0x80 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2140 keymap[VK_RMENU] & 0x1 ? 1 : 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2141 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
2142 keystate[0] & 0x8000 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2143 keystate[0] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2144 keystate[1] & 0x8000 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2145 keystate[1] & 0x1 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2146 keystate[2] & 0x8000 ? 1 : 0,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2147 keystate[2] & 0x1 ? 1 : 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2148 /* 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
2149 /* asyncstate[0] & 0x8000 ? 1 : 0, */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2150 /* asyncstate[0] & 0x1 ? 1 : 0, */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2151 /* asyncstate[1] & 0x8000 ? 1 : 0, */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2152 /* asyncstate[1] & 0x1 ? 1 : 0, */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2153 /* asyncstate[2] & 0x8000 ? 1 : 0, */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2154 /* asyncstate[2] & 0x1 ? 1 : 0); */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2155 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2156
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2157 #endif /* DEBUG_XEMACS */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2158
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2159
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2160 /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2161 * The windows procedure for the window class XEMACS_CLASS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2162 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2163 LRESULT WINAPI
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2164 mswindows_wnd_proc (HWND hwnd, UINT message_, WPARAM wParam, LPARAM lParam)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2165 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2166 /* Note: Remember to initialize emacs_event and event before use.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2167 This code calls code that can GC. You must GCPRO before calling such code. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2168 Lisp_Object emacs_event = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2169 Lisp_Object fobj = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2170
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2171 Lisp_Event *event;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2172 struct frame *frame;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
2173 struct mswindows_frame *msframe;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2174
611
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 604
diff changeset
2175 /* 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
2176 using register_post_gc_action(). */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 604
diff changeset
2177 assert (!gc_in_progress);
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2178
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2179 #ifdef DEBUG_XEMACS
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2180 if (debug_mswindows_events)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2181 debug_output_mswin_message (hwnd, message_, wParam, lParam);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2182 #endif /* DEBUG_XEMACS */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2183
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2184 assert (!qxeGetWindowLong (hwnd, GWL_USERDATA));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2185 switch (message_)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2186 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2187 case WM_DESTROYCLIPBOARD:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2188 mswindows_handle_destroyclipboard ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2189 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2190
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2191 case WM_ERASEBKGND:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2192 /* Erase background only during non-dynamic sizing */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2193 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2194 if (msframe->sizing && !mswindows_dynamic_frame_resize)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2195 goto defproc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2196 return 1;
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 case WM_CLOSE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2199 fobj = mswindows_find_frame (hwnd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2200 mswindows_enqueue_misc_user_event (fobj, Qeval, list3 (Qdelete_frame, fobj, Qt));
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
2201 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2202
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2203 case WM_KEYUP:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2204 case WM_SYSKEYUP:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2205
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2206 /* See Win95 comment under WM_KEYDOWN */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2207 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2208 BYTE keymap[256];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2209 int should_set_keymap = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2210
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2211 #ifdef DEBUG_XEMACS
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2212 if (debug_mswindows_events > 2)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2213 output_alt_keyboard_state ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2214 #endif /* DEBUG_XEMACS */
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 mswindows_handle_sticky_modifiers (wParam, lParam, 0, 1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2217 if (wParam == VK_CONTROL)
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 GetKeyboardState (keymap);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2220 keymap [(lParam & 0x1000000) ? VK_RCONTROL : VK_LCONTROL] &= ~0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2221 should_set_keymap = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2222 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2223 else if (wParam == VK_MENU)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2224 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2225 GetKeyboardState (keymap);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2226 keymap [(lParam & 0x1000000) ? VK_RMENU : VK_LMENU] &= ~0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2227 should_set_keymap = 1;
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
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2230 if (should_set_keymap)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2231 // && (message_ != WM_SYSKEYUP
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2232 // || NILP (Vmenu_accelerator_enabled)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2233 SetKeyboardState (keymap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2234
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2235 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2236
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2237 if (key_needs_default_processing_p (wParam))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2238 goto defproc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2239 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2240 break;
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 case WM_KEYDOWN:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2243 case WM_SYSKEYDOWN:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2244
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2245 /* 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
2246 * should produce alternative characters when combined with another key.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2247 * eg on a German keyboard pressing AltGr+q should produce '@'.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2248 * AltGr generates exactly the same keystrokes as LCtrl+RAlt. But if
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2249 * TranslateMessage() is called with *any* combination of Ctrl+Alt down,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2250 * it translates as if AltGr were down.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2251 * 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
2252 * calling TranslateMessage() unless AltGr is *really* down. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2253 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2254 BYTE keymap_trans[256];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2255 BYTE keymap_orig[256];
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2256 BYTE keymap_sticky[256];
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2257 /* 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
2258 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
2259 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
2260 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
2261 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
2262 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
2263 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
2264 package.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2265
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2266 (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
2267 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
2268 consistently triggered here? I saw the problem
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2269 consistently. Answer: It appears that, currently,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2270 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
2271 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
2272 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
2273 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
2274 the 1/4-second timer consistently fires while
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2275 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
2276 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
2277 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
2278
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2279 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
2280 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
2281 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
2282 wrong.)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2283
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2284 #### We should probably wrap this whole function in
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2285 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
2286 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
2287 from within this function, specifically from
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2288 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
2289 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
2290 calls begin_dont_check_for_quit(). */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2291
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2292 int count = begin_dont_check_for_quit ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2293 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
2294 int mods = 0, mods_with_shift = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2295 int extendedp = lParam & 0x1000000;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2296 Lisp_Object keysym;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2297 int sticky_changed;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2298
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2299 #ifdef DEBUG_XEMACS
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2300 if (debug_mswindows_events > 2)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2301 output_alt_keyboard_state ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2302 #endif /* DEBUG_XEMACS */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2303
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2304 GetKeyboardState (keymap_orig);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2305 frame = XFRAME (mswindows_find_frame (hwnd));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2306 if ((sticky_changed =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2307 mswindows_handle_sticky_modifiers (wParam, lParam, 1, 1)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2308 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2309 GetKeyboardState (keymap_sticky);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2310 if (keymap_sticky[VK_MENU] & 0x80)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2311 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2312 message_ = WM_SYSKEYDOWN;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2313 /* We have to set the "context bit" so that the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2314 TranslateMessage() call below that generates the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2315 SYSCHAR message does its thing; see the documentation
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2316 on WM_SYSKEYDOWN */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2317 lParam |= 1 << 29;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2318 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2319 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2320 else
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2321 memcpy (keymap_sticky, keymap_orig, 256);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2322
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2323 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
2324 mods_with_shift = mods;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2325
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2326 /* Handle non-printables */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2327 if (!NILP (keysym = mswindows_key_to_emacs_keysym (wParam, mods,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2328 extendedp)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2329 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2330 mswindows_enqueue_keypress_event (hwnd, keysym, mods);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2331 if (sticky_changed)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2332 SetKeyboardState (keymap_orig);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2333 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2334 else /* Normal keys & modifiers */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2335 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2336 Emchar quit_ch =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2337 CONSOLE_QUIT_CHAR (XCONSOLE (mswindows_find_console (hwnd)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2338 POINT pnt = { LOWORD (GetMessagePos()), HIWORD (GetMessagePos()) };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2339 MSG msg, tranmsg;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2340 int potential_accelerator = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2341 int got_accelerator = 0;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2342 /* 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
2343 queue when we retrieve it. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2344 Lisp_Object lastev = Qnil;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2345
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2346 msg.hwnd = hwnd;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2347 msg.message = message_;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2348 msg.wParam = wParam;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2349 msg.lParam = lParam;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2350 msg.time = GetMessageTime();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2351 msg.pt = pnt;
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 /* GetKeyboardState() does not work as documented on Win95. We have
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2354 * 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
2355 * without screwing up Windows NT which tracks them properly. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2356 if (wParam == VK_CONTROL)
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 keymap_orig[extendedp ? VK_RCONTROL : VK_LCONTROL] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2359 keymap_sticky[extendedp ? VK_RCONTROL : VK_LCONTROL] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2360 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2361 else if (wParam == VK_MENU)
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 keymap_orig[extendedp ? VK_RMENU : VK_LMENU] |= 0x80;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2364 keymap_sticky[extendedp ? VK_RMENU : VK_LMENU] |= 0x80;
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
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2367 if (!NILP (Vmenu_accelerator_enabled) &&
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2368 !(mods & XEMACS_MOD_SHIFT) && message_ == WM_SYSKEYDOWN)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2369 potential_accelerator = 1;
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 /* Remove shift modifier from an ascii character */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2372 mods &= ~XEMACS_MOD_SHIFT;
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 memcpy (keymap_trans, keymap_sticky, 256);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2375
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2376 /* Clear control and alt modifiers unless AltGr is pressed */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2377 keymap_trans[VK_RCONTROL] = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2378 keymap_trans[VK_LMENU] = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2379 if (!has_AltGr || !(keymap_trans[VK_LCONTROL] & 0x80)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2380 || !(keymap_trans[VK_RMENU] & 0x80))
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_trans[VK_LCONTROL] = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2383 keymap_trans[VK_CONTROL] = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2384 keymap_trans[VK_RMENU] = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2385 keymap_trans[VK_MENU] = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2386 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2387 SetKeyboardState (keymap_trans);
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 /* Maybe generate some WM_[SYS]CHARs in the queue */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2390 TranslateMessage (&msg);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2391
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2392 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
2393 || qxePeekMessage (&tranmsg, hwnd, WM_SYSCHAR, WM_SYSCHAR,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2394 PM_REMOVE))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2395 {
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
2396 int mods_with_quit = mods;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2397 int length;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2398 Extbyte extchar[4];
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2399 Intbyte *intchar;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2400 Emchar ch;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2401
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2402 if (XEUNICODE_P)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2403 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2404 length = unicode_char_to_text (tranmsg.wParam, extchar);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2405 TO_INTERNAL_FORMAT (DATA, (extchar, length),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2406 C_STRING_ALLOCA, (intchar),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2407 Qmswindows_unicode);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2408 ch = charptr_emchar (intchar);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2409 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2410 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2411 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2412 length = ansi_char_to_text (tranmsg.wParam, extchar);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2413 intchar = (convert_multibyte_to_internal_malloc
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2414 (extchar, length,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2415 mswindows_locale_to_code_page
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2416 /* See intl-win32.c for an explanation of
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2417 the following */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2418 ((LCID) GetKeyboardLayout (0) & 0xFFFF),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2419 NULL));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2420 ch = charptr_emchar (intchar);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2421 xfree (intchar);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2422 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2423
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2424 #ifdef DEBUG_XEMACS
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2425 if (debug_mswindows_events)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2426 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2427 stderr_out ("-> ");
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2428 debug_output_mswin_message (tranmsg.hwnd, tranmsg.message,
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2429 tranmsg.wParam,
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2430 tranmsg.lParam);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2431 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2432 #endif /* DEBUG_XEMACS */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2433
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2434 /* If a quit char with no modifiers other than control and
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2435 shift, then mark it with a fake modifier, which is removed
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2436 upon dequeueing the event */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2437 if (((quit_ch < ' ' && (mods & XEMACS_MOD_CONTROL)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2438 && DOWNCASE (0, quit_ch + 'a' - 1) ==
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2439 DOWNCASE (0, ch))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2440 || (quit_ch >= ' ' && !(mods & XEMACS_MOD_CONTROL)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2441 && DOWNCASE (0, quit_ch) ==
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2442 DOWNCASE (0, ch)))
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
2443 && ((mods_with_shift &
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
2444 ~(XEMACS_MOD_CONTROL | XEMACS_MOD_SHIFT))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2445 == 0))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2446 {
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
2447 mods_with_quit |= FAKE_MOD_QUIT;
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
2448 if (mods_with_shift & XEMACS_MOD_SHIFT)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
2449 mods_with_quit |= FAKE_MOD_QUIT_CRITICAL;
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2450 mswindows_quit_chars_count++;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2451 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2452 else if (potential_accelerator && !got_accelerator &&
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2453 mswindows_char_is_accelerator (frame, ch))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2454 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2455 got_accelerator = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2456 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2457 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2458 lastev = mswindows_enqueue_keypress_event (hwnd,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2459 make_char (ch),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2460 mods_with_quit);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2461 } /* while */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2462
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2463 #ifdef MULE
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2464 /* 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
2465 possible keyboard layouts, in this order:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2466
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2467 -- current language environment
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2468 -- user default language environment
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2469 -- system default language environment
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2470 -- same three, but checking the underlying virtual key,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2471 and only paying attention if it's alphabetic
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2472 -- US ASCII
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2473
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2474 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
2475 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2476
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2477 if (!NILP (lastev))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2478 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2479 int i;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2480 int scan = (lParam >> 16) && 0xFF;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2481
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2482 for (i = 0; i < KEYCHAR_LAST; i++)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2483 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2484 int vk_only = 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2485 LCID lcid;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2486 int virtual_key;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2487
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2488 switch (i)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2489 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2490 case KEYCHAR_UNDERLYING_VIRTUAL_KEY_CURRENT_LANGENV:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2491 vk_only = 1;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2492 case KEYCHAR_CURRENT_LANGENV:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2493 lcid = mswindows_current_locale ();
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2494 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2495
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2496 case KEYCHAR_UNDERLYING_VIRTUAL_KEY_DEFAULT_USER:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2497 vk_only = 1;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2498 case KEYCHAR_DEFAULT_USER:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2499 lcid = GetUserDefaultLCID ();
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2500 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2501
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2502 case KEYCHAR_UNDERLYING_VIRTUAL_KEY_DEFAULT_SYSTEM:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2503 vk_only = 1;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2504 case KEYCHAR_DEFAULT_SYSTEM:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2505 lcid = GetSystemDefaultLCID ();
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2506 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2507
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2508 case KEYCHAR_QWERTY:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2509 lcid = MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH_US);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2510 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2511
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2512 default: abort (); lcid = 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2513 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2514
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2515 /* VERY CONFUSING! See intl-win32.c. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2516 lcid = lcid & 0xFFFF;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2517
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
2518 virtual_key = qxeMapVirtualKeyEx (scan, 1, (HKL) lcid);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2519 if (!vk_only)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2520 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2521 if (XEUNICODE_P)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2522 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2523 Extbyte received_keys[32];
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2524 int tounret =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2525 ToUnicodeEx
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2526 (virtual_key, scan, keymap_trans,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2527 (LPWSTR) received_keys,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2528 sizeof (received_keys) / XETCHAR_SIZE,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2529 0, /* #### what about this flag? "if
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2530 bit 0 is set, a menu is
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2531 active???" */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2532 (HKL) lcid);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2533 if (tounret > 0)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2534 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2535 Intbyte *intchar;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2536
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2537 TO_INTERNAL_FORMAT
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2538 (DATA,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2539 (received_keys + (tounret - 1) * 2, 2),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2540 C_STRING_ALLOCA, intchar,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2541 Qmswindows_unicode);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2542 XEVENT (lastev)->event.key.alt_keychars[i] =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2543 charptr_emchar (intchar);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2544 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2545 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2546 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2547 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2548 WORD received_keys[32];
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2549 int tounret =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2550 ToAsciiEx (virtual_key, scan, keymap_trans,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2551 received_keys,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2552 0, /* #### what about this
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2553 flag? "if bit 0 is set, a
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2554 menu is active???" */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2555 (HKL) lcid);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2556 if (tounret > 0)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2557 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2558 /* #### I cannot find proper
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2559 documentation on what format the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2560 return value is in. I'm assuming
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2561 it's like WM_IME_CHAR: DBCS chars
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2562 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
2563 the short. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2564 Intbyte *intchar;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2565 Extbyte mbstuff[2];
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2566 Bytecount mblength = 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2567 WORD thechar = received_keys[tounret - 1];
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2568
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2569 mbstuff[mblength++] =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2570 (Extbyte) (thechar & 0xFF);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2571 if (thechar > 0xFF)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2572 mbstuff[mblength++] =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2573 (Extbyte) ((thechar >> 8) & 0xFF);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2574
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2575 intchar = convert_multibyte_to_internal_malloc
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2576 (mbstuff, mblength,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2577 mswindows_locale_to_code_page (lcid),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2578 NULL);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2579
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2580 XEVENT (lastev)->event.key.alt_keychars[i] =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2581 charptr_emchar (intchar);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2582 xfree (intchar);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2583 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2584 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2585 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2586 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2587 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2588 Emchar altch;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2589
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2590 if (virtual_key >= 'A' && virtual_key <= 'Z')
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2591 altch =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2592 virtual_key + (mods_with_shift & XEMACS_MOD_SHIFT ?
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2593 'a' - 'A' : 0);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2594 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2595 altch = 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2596
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2597 XEVENT (lastev)->event.key.alt_keychars[i] = altch;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2598 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2599 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2600 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2601 #endif /* MULE */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2602
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2603 /* This generates WM_SYSCHAR messages, which are interpreted
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2604 by DefWindowProc as the menu selections. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2605 if (got_accelerator)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2606 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2607 SetKeyboardState (keymap_sticky);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2608 TranslateMessage (&msg);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2609 SetKeyboardState (keymap_orig);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2610 unbind_to (count);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2611 goto defproc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2612 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2613
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2614 SetKeyboardState (keymap_orig);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2615 } /* else */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2616
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2617 if (key_needs_default_processing_p (wParam))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2618 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2619 unbind_to (count);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2620 goto defproc;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2621 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2622 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2623 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2624 unbind_to (count);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2625 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2626 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2627 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2628
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2629 case WM_MBUTTONDOWN:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2630 case WM_MBUTTONUP:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2631 /* Real middle mouse button has nothing to do with emulated one:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2632 if one wants to exercise fingers playing chords on the mouse,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2633 he is allowed to do that! */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2634 mswindows_enqueue_mouse_button_event (hwnd, message_,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2635 MAKEPOINTS (lParam),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2636 wParam &~ MK_MBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2637 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2638 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2639
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2640 case WM_LBUTTONUP:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2641 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
2642 msframe->last_click_time = GetMessageTime();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2643
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2644 KillTimer (hwnd, BUTTON_2_TIMER_ID);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2645 msframe->button2_need_lbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2646 if (msframe->ignore_next_lbutton_up)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2647 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2648 msframe->ignore_next_lbutton_up = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2649 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2650 else if (msframe->button2_is_down)
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 msframe->button2_is_down = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2653 msframe->ignore_next_rbutton_up = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2654 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONUP,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2655 MAKEPOINTS (lParam),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2656 wParam
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2657 &~ (MK_LBUTTON | MK_MBUTTON
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2658 | MK_RBUTTON),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2659 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2660 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2661 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2662 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2663 if (msframe->button2_need_rbutton)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2664 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2665 msframe->button2_need_rbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2666 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2667 MAKEPOINTS (lParam),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2668 wParam &~ MK_LBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2669 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2670 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2671 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONUP,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2672 MAKEPOINTS (lParam),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2673 wParam &~ MK_LBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2674 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2675 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2676 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2677
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2678 case WM_RBUTTONUP:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2679 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
2680 msframe->last_click_time = GetMessageTime();
442
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 KillTimer (hwnd, BUTTON_2_TIMER_ID);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2683 msframe->button2_need_rbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2684 if (msframe->ignore_next_rbutton_up)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2685 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2686 msframe->ignore_next_rbutton_up = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2687 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2688 else if (msframe->button2_is_down)
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 msframe->button2_is_down = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2691 msframe->ignore_next_lbutton_up = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2692 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONUP,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2693 MAKEPOINTS (lParam),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2694 wParam
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2695 &~ (MK_LBUTTON | MK_MBUTTON
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2696 | MK_RBUTTON),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2697 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2698 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2699 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2700 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2701 if (msframe->button2_need_lbutton)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2702 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2703 msframe->button2_need_lbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2704 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2705 MAKEPOINTS (lParam),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2706 wParam &~ MK_RBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2707 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2708 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2709 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONUP,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2710 MAKEPOINTS (lParam),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2711 wParam &~ MK_RBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2712 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2713 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2714 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2715
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2716 case WM_LBUTTONDOWN:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2717 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2718
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2719 if (msframe->button2_need_lbutton)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2720 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2721 KillTimer (hwnd, BUTTON_2_TIMER_ID);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2722 msframe->button2_need_lbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2723 msframe->button2_need_rbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2724 if (mswindows_button2_near_enough (msframe->last_click_point,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2725 MAKEPOINTS (lParam)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2726 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2727 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONDOWN,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2728 MAKEPOINTS (lParam),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2729 wParam
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2730 &~ (MK_LBUTTON | MK_MBUTTON
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2731 | MK_RBUTTON),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2732 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2733 msframe->button2_is_down = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2734 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2735 else
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2736 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2737 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2738 msframe->last_click_point,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2739 msframe->last_click_mods
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2740 &~ MK_RBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2741 msframe->last_click_time);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2742 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2743 MAKEPOINTS (lParam),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2744 wParam &~ MK_LBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2745 GetMessageTime());
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2746 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2747 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2748 else
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2749 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2750 mswindows_set_chord_timer (hwnd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2751 msframe->button2_need_rbutton = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2752 msframe->last_click_point = MAKEPOINTS (lParam);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2753 msframe->last_click_mods = wParam;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2754 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2755 msframe->last_click_time = GetMessageTime();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2756 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2757
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2758 case WM_RBUTTONDOWN:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2759 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2760
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2761 if (msframe->button2_need_rbutton)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2762 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2763 KillTimer (hwnd, BUTTON_2_TIMER_ID);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2764 msframe->button2_need_lbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2765 msframe->button2_need_rbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2766 if (mswindows_button2_near_enough (msframe->last_click_point,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2767 MAKEPOINTS (lParam)))
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 mswindows_enqueue_mouse_button_event (hwnd, WM_MBUTTONDOWN,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2770 MAKEPOINTS (lParam),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2771 wParam
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2772 &~ (MK_LBUTTON | MK_MBUTTON
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2773 | MK_RBUTTON),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2774 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2775 msframe->button2_is_down = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2776 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2777 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2778 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2779 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2780 msframe->last_click_point,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2781 msframe->last_click_mods
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2782 &~ MK_LBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2783 msframe->last_click_time);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2784 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2785 MAKEPOINTS (lParam),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2786 wParam &~ MK_RBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2787 GetMessageTime());
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2788 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2789 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2790 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2791 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2792 mswindows_set_chord_timer (hwnd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2793 msframe->button2_need_lbutton = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2794 msframe->last_click_point = MAKEPOINTS (lParam);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2795 msframe->last_click_mods = wParam;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2796 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2797 msframe->last_click_time = GetMessageTime();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2798 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2799
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2800 case WM_TIMER:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2801 if (wParam == BUTTON_2_TIMER_ID)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2802 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2803 msframe =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2804 FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2805 KillTimer (hwnd, BUTTON_2_TIMER_ID);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2806
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2807 if (msframe->button2_need_lbutton)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2808 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2809 msframe->button2_need_lbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2810 mswindows_enqueue_mouse_button_event (hwnd, WM_RBUTTONDOWN,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2811 msframe->last_click_point,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2812 msframe->last_click_mods
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2813 &~ MK_RBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2814 msframe->last_click_time);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2815 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2816 else if (msframe->button2_need_rbutton)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2817 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2818 msframe->button2_need_rbutton = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2819 mswindows_enqueue_mouse_button_event (hwnd, WM_LBUTTONDOWN,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2820 msframe->last_click_point,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2821 msframe->last_click_mods
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2822 &~ MK_LBUTTON,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2823 msframe->last_click_time);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2824 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2825 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2826 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2827 assert ("Spurious timer fired" == 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2828 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2829
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2830 case WM_MOUSEMOVE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2831 /* 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
2832 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2833 if (!msframe->sizing)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2834 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2835 /* When waiting for the second mouse button to finish
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2836 button2 emulation, and have moved too far, just pretend
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2837 as if timer has expired. This improves drag-select feedback */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2838 if ((msframe->button2_need_lbutton || msframe->button2_need_rbutton)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2839 && !mswindows_button2_near_enough (msframe->last_click_point,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2840 MAKEPOINTS (lParam)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2841 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2842 KillTimer (hwnd, BUTTON_2_TIMER_ID);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2843 qxeSendMessage (hwnd, WM_TIMER, BUTTON_2_TIMER_ID, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2844 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2845
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2846 emacs_event = Fmake_event (Qnil, Qnil);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2847 event = XEVENT(emacs_event);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2848
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2849 event->channel = mswindows_find_frame (hwnd);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2850 event->timestamp = GetMessageTime ();
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2851 event->event_type = pointer_motion_event;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2852 event->event.motion.x = MAKEPOINTS (lParam).x;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2853 event->event.motion.y = MAKEPOINTS (lParam).y;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2854 event->event.motion.modifiers =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2855 mswindows_modifier_state (NULL, wParam, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2856
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2857 mswindows_enqueue_dispatch_event (emacs_event);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2858 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2859 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2860
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2861 case WM_CANCELMODE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2862 ReleaseCapture ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2863 /* Queue a `cancel-mode-internal' misc user event, so mouse
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2864 selection would be canceled if any */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2865 mswindows_enqueue_misc_user_event (mswindows_find_frame (hwnd),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2866 Qcancel_mode_internal, Qnil);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2867 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2868
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2869 case WM_NOTIFY:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2870 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
2871 LPNMHDR nmhdr = (LPNMHDR) lParam;
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
2872
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
2873 if ((int) nmhdr->code == TTN_NEEDTEXT)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2874 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2875 #ifdef HAVE_TOOLBARS
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2876 LPTOOLTIPTEXTW tttextw = (LPTOOLTIPTEXTW) lParam;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2877 Lisp_Object btext;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2878 Extbyte *btextext = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2879
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2880 /* find out which toolbar */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2881 frame = XFRAME (mswindows_find_frame (hwnd));
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
2882 btext = mswindows_get_toolbar_button_text (frame, nmhdr->idFrom);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2883
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2884 tttextw->hinst = NULL;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2885
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2886 if (!NILP (btext))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2887 LISP_STRING_TO_TSTR (btext, btextext);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2888
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2889 if (btextext)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2890 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2891 /* 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
2892 "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
2893 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
2894 zero the whole thing. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2895 xzero (*tttextw->szText);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2896 xetcsncpy ((Extbyte *) tttextw->szText, btextext, 79);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2897 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2898 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2899 tttextw->lpszText = NULL;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2900 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2901 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2902 /* handle tree view callbacks */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
2903 else if ((int) nmhdr->code == TVN_SELCHANGED)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2904 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
2905 NM_TREEVIEW *ptree = (NM_TREEVIEW *) lParam;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2906 frame = XFRAME (mswindows_find_frame (hwnd));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2907 mswindows_handle_gui_wm_command (frame, 0, ptree->itemNew.lParam);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2908 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2909 /* handle tab control callbacks */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
2910 else if ((int) nmhdr->code == TCN_SELCHANGE)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2911 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2912 TC_ITEM item;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2913 int idx = qxeSendMessage (nmhdr->hwndFrom, TCM_GETCURSEL, 0, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2914 frame = XFRAME (mswindows_find_frame (hwnd));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2915
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2916 item.mask = TCIF_PARAM;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2917 qxeSendMessage (nmhdr->hwndFrom, TCM_GETITEM, (WPARAM) idx,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2918 (LPARAM) &item);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2919
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2920 mswindows_handle_gui_wm_command (frame, 0, item.lParam);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2921 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2922 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2923 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2924
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2925 case WM_PAINT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2926 /* 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
2927 shouldn't have received a paint message for it here. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2928 assert (wParam == 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2929
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2930 /* 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
2931 messages directly to the windows procedure when doing solid drags
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2932 and the message queue doesn't get processed. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2933 mswindows_handle_paint (XFRAME (mswindows_find_frame (hwnd)));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2934 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2935
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2936 case WM_WINDOWPOSCHANGED:
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2937 /* 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
2938 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
2939 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
2940 this and update the state flags. */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2941 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2942 fobj = mswindows_find_frame (hwnd);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2943 frame = XFRAME (fobj);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2944 if (IsIconic (hwnd))
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2945 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2946 FRAME_VISIBLE_P (frame) = 0;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2947 FRAME_ICONIFIED_P (frame) = 1;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2948 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2949 else if (IsWindowVisible (hwnd))
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2950 {
707
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
2951 /* 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
2952 * 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
2953 * 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
2954 * did). */
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
2955 /* FRAME_VISIBLE_P (frame) = 1; */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2956 FRAME_ICONIFIED_P (frame) = 0;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2957 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2958 else
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2959 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2960 FRAME_VISIBLE_P (frame) = 0;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2961 FRAME_ICONIFIED_P (frame) = 0;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2962 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2963
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2964 goto defproc;
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2965 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
2966
731
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2967 case WM_SHOWWINDOW:
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2968 /*
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2969 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
2970 is about to be hidden or shown.
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2971 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
2972 desktop under the virtuawin virtual window manager.
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2973
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2974 */
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2975 {
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2976 fobj = mswindows_find_frame (hwnd);
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2977 frame = XFRAME (fobj);
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2978 if (wParam == TRUE)
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2979 {
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2980 mswindows_enqueue_magic_event (hwnd, XM_MAPFRAME);
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2981 FRAME_VISIBLE_P (frame) = 1;
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2982 }
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2983 else
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2984 {
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2985 mswindows_enqueue_magic_event (hwnd, XM_UNMAPFRAME);
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2986 FRAME_VISIBLE_P (frame) = 0;
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2987 }
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2988 }
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2989 break;
46d76bae9921 [xemacs-hg @ 2002-01-18 18:01:02 by adrian]
adrian
parents: 707
diff changeset
2990
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2991 case WM_SIZE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2992 /* 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
2993 if (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED ||
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
2994 wParam == SIZE_MINIMIZED)
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 RECT rect;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2997 int columns, rows;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2998
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
2999 fobj = mswindows_find_frame (hwnd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3000 frame = XFRAME (fobj);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3001 msframe = FRAME_MSWINDOWS_DATA (frame);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3002
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3003 /* We cannot handle frame map and unmap hooks right in
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3004 this routine, because these may throw. We queue
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3005 magic events to run these hooks instead - kkm */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3006
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3007 if (wParam == SIZE_MINIMIZED)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3008 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3009 /* Iconified */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3010 mswindows_enqueue_magic_event (hwnd, XM_UNMAPFRAME);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3011 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3012 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3013 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3014 GetClientRect(hwnd, &rect);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3015 FRAME_PIXWIDTH(frame) = rect.right;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3016 FRAME_PIXHEIGHT(frame) = rect.bottom;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3017
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3018 pixel_to_real_char_size (frame, rect.right, rect.bottom,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3019 &FRAME_MSWINDOWS_CHARWIDTH (frame),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3020 &FRAME_MSWINDOWS_CHARHEIGHT (frame));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3021
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3022 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
3023 &rows);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3024 change_frame_size (frame, rows, columns, 1);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3025
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3026 /* If we are inside frame creation, we have to apply geometric
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3027 properties now. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3028 if (FRAME_MSWINDOWS_TARGET_RECT (frame))
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 /* Yes, we have to size again */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3031 mswindows_size_frame_internal (frame,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3032 FRAME_MSWINDOWS_TARGET_RECT
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3033 (frame));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3034 /* 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
3035 * call in mswindows_size_frame_internal can cause
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3036 * recursion here. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3037 if (FRAME_MSWINDOWS_TARGET_RECT (frame))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3038 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3039 xfree (FRAME_MSWINDOWS_TARGET_RECT (frame));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3040 FRAME_MSWINDOWS_TARGET_RECT (frame) = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3041 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3042 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3043 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3044 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3045 if (!msframe->sizing && !FRAME_VISIBLE_P (frame))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3046 mswindows_enqueue_magic_event (hwnd, XM_MAPFRAME);
707
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
3047 /* APA: Now that the magic XM_MAPFRAME event has
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
3048 * been sent we can mark the frame as visible (just
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
3049 * like 21.1 did). */
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
3050 FRAME_VISIBLE_P (frame) = 1;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3051
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3052 if (!msframe->sizing || mswindows_dynamic_frame_resize)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3053 redisplay ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3054 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3055 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3056 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3057 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3058
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3059 case WM_DISPLAYCHANGE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3060 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3061 struct device *d;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3062 DWORD message_tick = GetMessageTime ();
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 fobj = mswindows_find_frame (hwnd);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3065 frame = XFRAME (fobj);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3066 d = XDEVICE (FRAME_DEVICE (frame));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3067
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3068 /* Do this only once per message. XEmacs can receive this message
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3069 through as many frames as it currently has open. Message time
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3070 will be the same for all these messages. Despite extreme
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3071 efficiency, the code below has about one in 4 billion
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3072 probability that the HDC is not recreated, provided that
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3073 XEmacs is running sufficiently longer than 52 days. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3074 if (DEVICE_MSWINDOWS_UPDATE_TICK(d) != message_tick)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3075 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3076 DEVICE_MSWINDOWS_UPDATE_TICK(d) = message_tick;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3077 DeleteDC (DEVICE_MSWINDOWS_HCDC(d));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3078 DEVICE_MSWINDOWS_HCDC(d) = CreateCompatibleDC (NULL);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3079 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3080 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3081 break;
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 /* Misc magic events which only require that the frame be identified */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3084 case WM_SETFOCUS:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3085 case WM_KILLFOCUS:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3086 mswindows_enqueue_magic_event (hwnd, message_);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3087 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3088
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3089 case WM_WINDOWPOSCHANGING:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3090 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3091 WINDOWPOS *wp = (LPWINDOWPOS) lParam;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3092 WINDOWPLACEMENT wpl = { sizeof(WINDOWPLACEMENT) };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3093 GetWindowPlacement(hwnd, &wpl);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3094
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3095 /* 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
3096 if (wpl.showCmd != SW_SHOWMINIMIZED
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3097 && wpl.showCmd != SW_SHOWMAXIMIZED
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3098 && !(wp->flags & SWP_NOSIZE))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3099 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3100 RECT ncsize = { 0, 0, 0, 0 };
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3101 int pixwidth, pixheight;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3102 AdjustWindowRectEx (&ncsize, qxeGetWindowLong (hwnd, GWL_STYLE),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3103 GetMenu(hwnd) != NULL,
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3104 qxeGetWindowLong (hwnd, GWL_EXSTYLE));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3105
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3106 round_size_to_real_char (XFRAME (mswindows_find_frame (hwnd)),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3107 wp->cx - (ncsize.right - ncsize.left),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3108 wp->cy - (ncsize.bottom - ncsize.top),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3109 &pixwidth, &pixheight);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3110
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3111 /* Convert client sizes to window sizes */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3112 pixwidth += (ncsize.right - ncsize.left);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3113 pixheight += (ncsize.bottom - ncsize.top);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3114
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3115 if (wpl.showCmd != SW_SHOWMAXIMIZED)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3116 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3117 /* 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
3118 * the top or left that's being changed */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3119 RECT rect;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3120 GetWindowRect (hwnd, &rect);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3121
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3122 if (rect.left != wp->x)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3123 wp->x += wp->cx - pixwidth;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3124 if (rect.top != wp->y)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3125 wp->y += wp->cy - pixheight;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3126 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3127
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3128 wp->cx = pixwidth;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3129 wp->cy = pixheight;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3130 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3131 /* DefWindowProc sends useful WM_GETMINMAXINFO message, and adjusts
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3132 window position if the user tries to track window too small */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3133 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3134 goto defproc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3135
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3136 case WM_ENTERSIZEMOVE:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3137 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3138 msframe->sizing = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3139 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3140
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3141 case WM_EXITSIZEMOVE:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3142 msframe = FRAME_MSWINDOWS_DATA (XFRAME (mswindows_find_frame (hwnd)));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3143 msframe->sizing = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3144 /* Queue noop event */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3145 mswindows_enqueue_magic_event (NULL, XM_BUMPQUEUE);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3146 return 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3147
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3148 #ifdef HAVE_SCROLLBARS
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3149 case WM_VSCROLL:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3150 case WM_HSCROLL:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3151 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3152 /* Direction of scroll is determined by scrollbar instance. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3153 int code = (int) LOWORD(wParam);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3154 int pos = (short int) HIWORD(wParam);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3155 HWND hwndScrollBar = (HWND) lParam;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3156 struct gcpro gcpro1, gcpro2;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3157
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3158 mswindows_handle_scrollbar_event (hwndScrollBar, code, pos);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3159 GCPRO2 (emacs_event, fobj);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3160 if (UNBOUNDP (mswindows_pump_outstanding_events())) /* Can GC */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3161 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3162 /* Error during event pumping - cancel scroll */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3163 qxeSendMessage (hwndScrollBar, WM_CANCELMODE, 0, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3164 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3165 UNGCPRO;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3166 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3167 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3168
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3169 case WM_MOUSEWHEEL:
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 int keys = LOWORD (wParam); /* Modifier key flags */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3172 int delta = (short) HIWORD (wParam); /* Wheel rotation amount */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3173
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
3174 if (mswindows_handle_mousewheel_event (mswindows_find_frame (hwnd),
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
3175 keys, delta,
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 462
diff changeset
3176 MAKEPOINTS (lParam)))
707
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
3177 /* We are not in a modal loop so no pumping is necessary. */
a307f9a2021d [xemacs-hg @ 2001-12-20 05:49:28 by andyp]
andyp
parents: 673
diff changeset
3178 break;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3179 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3180 goto defproc;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3181 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3182 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3183
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3184 #ifdef HAVE_MENUBARS
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3185 case WM_INITMENU:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3186 if (UNBOUNDP (mswindows_handle_wm_initmenu
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3187 ((HMENU) wParam,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3188 XFRAME (mswindows_find_frame (hwnd)))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3189 qxeSendMessage (hwnd, WM_CANCELMODE, 0, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3190 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3191
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3192 case WM_INITMENUPOPUP:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3193 if (!HIWORD(lParam))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3194 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3195 if (UNBOUNDP (mswindows_handle_wm_initmenupopup
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3196 ((HMENU) wParam,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3197 XFRAME (mswindows_find_frame (hwnd)))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3198 qxeSendMessage (hwnd, WM_CANCELMODE, 0, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3199 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3200 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3201
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3202 #endif /* HAVE_MENUBARS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3203
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3204 case WM_COMMAND:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3205 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3206 WORD id = LOWORD (wParam);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3207 WORD nid = HIWORD (wParam);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3208 HWND cid = (HWND)lParam;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3209 frame = XFRAME (mswindows_find_frame (hwnd));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3211 #ifdef HAVE_TOOLBARS
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3212 if (!NILP (mswindows_handle_toolbar_wm_command (frame, cid, id)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3213 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3214 #endif
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3215 /* 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
3216 switch (nid)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3217 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3218 case BN_CLICKED:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3219 case EN_CHANGE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3220 case CBN_EDITCHANGE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3221 case CBN_SELCHANGE:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3222 if (!NILP (mswindows_handle_gui_wm_command (frame, cid, id)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3223 return 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3224 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3225 /* 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
3226 always exist */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3227 #ifdef HAVE_MENUBARS
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3228 if (!NILP (mswindows_handle_wm_command (frame, id)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3229 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3230 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3231
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3232 goto defproc;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3233 /* 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
3234 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
3235 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
3236 more bugs than a termite's nest! */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3237 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3238 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3239
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3240 case WM_CTLCOLORBTN:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3241 case WM_CTLCOLORLISTBOX:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3242 case WM_CTLCOLOREDIT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3243 case WM_CTLCOLORSTATIC:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3244 case WM_CTLCOLORSCROLLBAR:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3245 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3246 /* 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
3247 there is an appropriate face */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3248 HWND crtlwnd = (HWND) lParam;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3249 LONG ii = qxeGetWindowLong (crtlwnd, GWL_USERDATA);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3250 if (ii)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3251 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3252 Lisp_Object image_instance;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3253 VOID_TO_LISP (image_instance, ii);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3254 if (IMAGE_INSTANCEP (image_instance)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3255 &&
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3256 IMAGE_INSTANCE_TYPE_P (image_instance, IMAGE_WIDGET))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3257 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3258 /* set colors for the buttons */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3259 HDC hdc = (HDC) wParam;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3260 if (last_widget_brushed != ii)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3261 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3262 if (widget_brush)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3263 DeleteObject (widget_brush);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3264 widget_brush = CreateSolidBrush
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3265 (COLOR_INSTANCE_MSWINDOWS_COLOR
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3266 (XCOLOR_INSTANCE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3267 (FACE_BACKGROUND
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3268 (XIMAGE_INSTANCE_WIDGET_FACE (image_instance),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3269 XIMAGE_INSTANCE_FRAME (image_instance)))));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3270 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3271 last_widget_brushed = ii;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3272 SetTextColor
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3273 (hdc,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3274 COLOR_INSTANCE_MSWINDOWS_COLOR
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3275 (XCOLOR_INSTANCE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3276 (FACE_FOREGROUND
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3277 (XIMAGE_INSTANCE_WIDGET_FACE (image_instance),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3278 XIMAGE_INSTANCE_FRAME (image_instance)))));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3279 SetBkMode (hdc, OPAQUE);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3280 SetBkColor
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3281 (hdc,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3282 COLOR_INSTANCE_MSWINDOWS_COLOR
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3283 (XCOLOR_INSTANCE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3284 (FACE_BACKGROUND
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3285 (XIMAGE_INSTANCE_WIDGET_FACE (image_instance),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3286 XIMAGE_INSTANCE_FRAME (image_instance)))));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3287 return (LRESULT)widget_brush;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3288 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3289 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3290 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3291 goto defproc;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3292
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3293 #ifdef HAVE_DRAGNDROP
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3294 case WM_DROPFILES: /* implementation ripped-off from event-Xt.c */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3295 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3296 UINT filecount, i;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3297 POINT point;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3298
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3299 Lisp_Object l_dndlist = Qnil, l_item = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3300 struct gcpro gcpro1, gcpro2, gcpro3;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3301
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3302 emacs_event = Fmake_event (Qnil, Qnil);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3303 event = XEVENT (emacs_event);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3304
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3305 GCPRO3 (emacs_event, l_dndlist, l_item);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3306
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3307 if (!DragQueryPoint ((HDROP) wParam, &point))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3308 point.x = point.y = -1; /* outside client area */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3309
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3310 event->event_type = misc_user_event;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3311 event->channel = mswindows_find_frame (hwnd);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3312 event->timestamp = GetMessageTime();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3313 event->event.misc.button = 1; /* #### Should try harder */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3314 event->event.misc.modifiers = mswindows_modifier_state (NULL,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3315 (DWORD) -1, 0);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3316 event->event.misc.x = point.x;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3317 event->event.misc.y = point.y;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3318 event->event.misc.function = Qdragdrop_drop_dispatch;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3319
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3320 filecount = qxeDragQueryFile ((HDROP) wParam, 0xffffffff, NULL, 0);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3321 for (i = 0; i < filecount; i++)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3322 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3323 Intbyte *fname;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3324 Extbyte *fname_ext;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3325 Bytecount fnamelen;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3326 Charcount len = qxeDragQueryFile ((HDROP) wParam, i, NULL, 0);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3327 /* 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
3328 * 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
3329 * because they may contain reserved characters. But that's OK -
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3330 * they just need to be good enough to keep dragdrop.el happy. */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3331 fname_ext = (Extbyte *) alloca ((len + 1) * XETCHAR_SIZE);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3332 qxeDragQueryFile ((HDROP) wParam, i, fname_ext, len + 1);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3333
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3334 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
3335 ALLOCA, (fname, fnamelen),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3336 Qmswindows_tstr);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3337
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3338 /* May be a shell link aka "shortcut" - replace fname if so */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3339 #if !defined (NO_CYGWIN_COM_SUPPORT)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3340 if (!qxestrcasecmp_c (fname + fnamelen - 4, ".LNK"))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3341 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3342 /* ####
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3343
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3344 Note the following in the docs:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3345
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3346 Note: The IShellLink interface has an ANSI version
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3347 (IShellLinkA) and a Unicode version (IShellLinkW). The
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3348 version that will be used depends on whether you compile
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3349 for ANSI or Unicode. However, Microsoft® Windows 95 and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3350 Microsoft® Windows 98 only support IShellLinkA.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3351
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3352 We haven't yet implemented COM support in the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3353 Unicode-splitting library. I don't quite understand how
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3354 COM works yet, but it looks like what's happening is
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3355 that the ShellLink class implements both the IShellLinkA
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3356 and IShellLinkW interfaces. To make this work at
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3357 run-time, we have to do something like this:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3358
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3359 -- define a new interface qxeIShellLink that uses
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3360 Extbyte * instead of LPSTR or LPWSTR. (not totally
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3361 necessary since Extbyte * == LPSTR).
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3362
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3363 -- define a new class qxeShellLink that implements
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3364 qxeIShellLink. the methods on this class need to create
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3365 a shadow ShellLink object to do all the real work, and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3366 call the corresponding function from either the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3367 IShellLinkA or IShellLinkW interfaces on this object,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3368 depending on whether XEUNICODE_P is defined.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3369
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3370 -- with appropriate preprocessor magic, of course, we
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3371 could make things appear transparent; but we've decided
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3372 not to do preprocessor magic for the moment.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3373 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3374
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3375 /* #### Not Unicode-split for the moment; we have to do it
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3376 ourselves. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3377 if (XEUNICODE_P)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3378 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3379 IShellLinkW *psl;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3380
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3381 if (CoCreateInstance (
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3382 XECOMID (CLSID_ShellLink),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3383 NULL,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3384 CLSCTX_INPROC_SERVER,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3385 XECOMID (IID_IShellLinkW),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3386 (void **) &psl) == S_OK)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3387 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3388 IPersistFile *ppf;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3389
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3390 if (XECOMCALL2 (psl, QueryInterface,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3391 XECOMID (IID_IPersistFile),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3392 (void **) &ppf) ==
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3393 S_OK)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3394 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3395 Extbyte *fname_unicode;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3396 WIN32_FIND_DATAW wfd;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3397 LPWSTR resolved =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3398 alloca_array (WCHAR, PATH_MAX + 1);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3399
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3400 TO_EXTERNAL_FORMAT (DATA, (fname, fnamelen),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3401 C_STRING_ALLOCA,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3402 fname_unicode,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3403 Qmswindows_unicode);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3404
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3405 if (XECOMCALL2 (ppf, Load,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3406 (LPWSTR) fname_unicode,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3407 STGM_READ) == S_OK &&
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3408 /* #### YUCK! Docs read
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3409
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3410 cchMaxPath
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3411
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3412 Maximum number of bytes to copy to the buffer pointed to by the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3413 pszFile parameter.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3414
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3415 But "cch" means "count of characters", not bytes. I'll assume the doc
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3416 writers messed up and the programmer was correct. Also, this approach
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3417 is safe even if it's actually the other way around. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3418 #ifdef CYGWIN_HEADERS /* Another Cygwin prototype error */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3419 XECOMCALL4 (psl, GetPath, (LPSTR) resolved,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3420 PATH_MAX, &wfd, 0)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3421 #else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3422 XECOMCALL4 (psl, GetPath, resolved,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3423 PATH_MAX, &wfd, 0)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3424 #endif
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3425 == S_OK)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3426 TO_INTERNAL_FORMAT (C_STRING, resolved,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3427 ALLOCA, (fname, fnamelen),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3428 Qmswindows_tstr);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3429
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3430 XECOMCALL0 (ppf, Release);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3431 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3432
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3433 XECOMCALL0 (psl, Release);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3434 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3435 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3436 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3437 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3438 IShellLinkA *psl;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3439
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3440 if (CoCreateInstance (
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3441 XECOMID (CLSID_ShellLink),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3442 NULL,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3443 CLSCTX_INPROC_SERVER,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3444 XECOMID (IID_IShellLinkA),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3445 (void **) &psl) == S_OK)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3446 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3447 IPersistFile *ppf;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3448
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3449 if (XECOMCALL2 (psl, QueryInterface,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3450 XECOMID (IID_IPersistFile),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3451 (void **) &ppf) ==
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3452 S_OK)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3453 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3454 Extbyte *fname_unicode;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3455 WIN32_FIND_DATAA wfd;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3456 LPSTR resolved =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3457 alloca_array (CHAR, PATH_MAX + 1);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3458
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3459 /* Always Unicode. Not obvious from the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3460 IPersistFile documentation, but look under
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3461 "Shell Link" for example code. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3462 TO_EXTERNAL_FORMAT (DATA, (fname, fnamelen),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3463 C_STRING_ALLOCA,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3464 fname_unicode,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3465 Qmswindows_unicode);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3466
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3467 if (XECOMCALL2 (ppf, Load,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3468 (LPWSTR) fname_unicode,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3469 STGM_READ) == S_OK
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3470 && XECOMCALL4 (psl, GetPath, resolved,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3471 PATH_MAX, &wfd, 0) == S_OK)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3472 TO_INTERNAL_FORMAT (C_STRING, resolved,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3473 ALLOCA, (fname, fnamelen),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3474 Qmswindows_tstr);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3475
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3476 XECOMCALL0 (ppf, Release);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3477 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3478
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3479 XECOMCALL0 (psl, Release);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3480 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3481 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3482 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3483 #endif /* !defined (NO_CYGWIN_COM_SUPPORT) */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3484 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3485 fname = urlify_filename (fname);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3486 l_item = build_intstring (fname);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3487 xfree (fname);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3488 l_dndlist = Fcons (l_item, l_dndlist);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3489 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3490 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3491
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3492 DragFinish ((HDROP) wParam);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3493
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3494 event->event.misc.object = Fcons (Qdragdrop_URL, l_dndlist);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3495 mswindows_enqueue_dispatch_event (emacs_event);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3496 UNGCPRO;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3497 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3498 break;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3499 #endif /* HAVE_DRAGNDROP */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3500
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3501 #ifdef MULE
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3502 case WM_IME_CHAR:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3503
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3504 case WM_IME_STARTCOMPOSITION:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3505 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
3506 goto defproc;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3507
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3508 case WM_IME_COMPOSITION:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3509 if (lParam & GCS_RESULTSTR)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3510 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3511 HIMC imc = ImmGetContext (hwnd);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3512 Extbyte *result;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3513 Bytecount len;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3514 Intbyte *resultint, *endptr;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3515 Bytecount lenint;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3516 int speccount;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3517
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3518 if (!imc)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3519 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3520
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3521 /* See WM_KEYDOWN above. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3522 speccount = begin_dont_check_for_quit ();
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3523
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3524 /* Sizes always in bytes, even for unicode.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3525 ImmGetCompositionStringW is supported even on Windows 9x, and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3526 allows us to handle multiple languages. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3527 len = ImmGetCompositionStringW (imc, GCS_RESULTSTR, NULL, 0);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3528 result = alloca_array (Extbyte, len);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3529 ImmGetCompositionStringW (imc, GCS_RESULTSTR, (WCHAR *) result, len);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3530 ImmReleaseContext (hwnd, imc);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3531
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3532 TO_INTERNAL_FORMAT (DATA, (result, len),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3533 ALLOCA, (resultint, lenint),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3534 Qmswindows_tstr);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3535
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3536 endptr = resultint + lenint;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3537
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3538 while (resultint < endptr)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3539 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3540 Emchar ch = charptr_emchar (resultint);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3541 if (ch == ' ')
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3542 mswindows_enqueue_keypress_event (hwnd, QKspace, 0);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3543 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3544 mswindows_enqueue_keypress_event (hwnd, make_char (ch), 0);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3545 INC_CHARPTR (resultint);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3546 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3547
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3548 unbind_to (speccount);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3549 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3550 goto defproc;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3551 #endif /* MULE */
442
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 defproc:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3554 default:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3555 return qxeDefWindowProc (hwnd, message_, wParam, lParam);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3556 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3557 return (0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3558 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3559
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3560
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3561 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3562 /* keyboard, mouse & other helpers for the windows procedure */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3563 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3564 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3565 mswindows_set_chord_timer (HWND hwnd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3566 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3567 int interval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3568
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3569 /* We get one third half system double click threshold */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3570 if (mswindows_mouse_button_tolerance <= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3571 interval = GetDoubleClickTime () / 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3572 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3573 interval = mswindows_mouse_button_tolerance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3574
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3575 SetTimer (hwnd, BUTTON_2_TIMER_ID, interval, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3576 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3577
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3578 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3579 mswindows_button2_near_enough (POINTS p1, POINTS p2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3580 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3581 int dx, dy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3582 if (mswindows_mouse_button_max_skew_x <= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3583 dx = GetSystemMetrics (SM_CXDOUBLECLK) / 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3584 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3585 dx = mswindows_mouse_button_max_skew_x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3586
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3587 if (mswindows_mouse_button_max_skew_y <= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3588 dy = GetSystemMetrics (SM_CYDOUBLECLK) / 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3589 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3590 dy = mswindows_mouse_button_max_skew_y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3591
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3592 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
3593 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3594
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3595 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3596 mswindows_current_layout_has_AltGr (void)
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 /* This simple caching mechanism saves 10% of CPU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3599 time when a key typed at autorepeat rate of 30 cps! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3600 static HKL last_hkl = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3601 static int last_hkl_has_AltGr;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3602 HKL current_hkl = GetKeyboardLayout (0);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3603
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3604 if (current_hkl != last_hkl)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3605 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
3606 int c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3607 last_hkl_has_AltGr = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3608 /* In this loop, we query whether a character requires
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3609 AltGr to be down to generate it. If at least such one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3610 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
3611 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
3612 /* #### 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
3613 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
3614 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
3615 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
3616 if (HIBYTE (VkKeyScanA ((char) c)) == 6)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3617 last_hkl_has_AltGr = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3618 last_hkl = current_hkl;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3619 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3620 return last_hkl_has_AltGr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3621 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3622
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3623
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3624 /* 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
3625 * 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
3626 static int
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3627 mswindows_modifier_state (BYTE *keymap, DWORD fwKeys, int has_AltGr)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3628 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3629 int mods = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3630 int keys_is_real = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3631 BYTE keymap2[256];
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 (fwKeys == (DWORD) -1)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3634 fwKeys = mswindows_last_mouse_button_state;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3635 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3636 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3637 keys_is_real = 1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3638 mswindows_last_mouse_button_state = fwKeys;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3639 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3640
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3641 if (keymap == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3642 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3643 keymap = keymap2;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3644 GetKeyboardState (keymap);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3645 has_AltGr = mswindows_current_layout_has_AltGr ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3646 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3647
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3648 /* #### 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
3649 AltGr works. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3650 if (has_AltGr && (keymap [VK_LCONTROL] & 0x80) && (keymap [VK_RMENU] & 0x80))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3651 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3652 mods |= (keymap [VK_LMENU] & 0x80) ? XEMACS_MOD_META : 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3653 mods |= (keymap [VK_RCONTROL] & 0x80) ? XEMACS_MOD_CONTROL : 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3654 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3655 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3656 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3657 mods |= (keymap [VK_MENU] & 0x80) ? XEMACS_MOD_META : 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3658 mods |= (keymap [VK_CONTROL] & 0x80) ? XEMACS_MOD_CONTROL : 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3659 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3660
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3661 mods |= (keys_is_real ? fwKeys & MK_SHIFT : (keymap [VK_SHIFT] & 0x80))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3662 ? XEMACS_MOD_SHIFT : 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3663 mods |= fwKeys & MK_LBUTTON ? XEMACS_MOD_BUTTON1 : 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3664 mods |= fwKeys & MK_MBUTTON ? XEMACS_MOD_BUTTON2 : 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3665 mods |= fwKeys & MK_RBUTTON ? XEMACS_MOD_BUTTON3 : 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3666
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3667 return mods;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3668 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3669
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3670 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3671 * Translate a mswindows virtual key to a keysym.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3672 * 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
3673 * or whose ASCII codes (like space) xemacs doesn't like.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3674 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3675 Lisp_Object mswindows_key_to_emacs_keysym (int mswindows_key, int mods,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3676 int extendedp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3677 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3678 if (extendedp) /* Keys not present on a 82 key keyboard */
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 switch (mswindows_key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3681 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3682 case VK_CANCEL: return KEYSYM ("pause");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3683 case VK_RETURN: return KEYSYM ("kp-enter");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3684 case VK_PRIOR: return KEYSYM ("prior");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3685 case VK_NEXT: return KEYSYM ("next");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3686 case VK_END: return KEYSYM ("end");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3687 case VK_HOME: return KEYSYM ("home");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3688 case VK_LEFT: return KEYSYM ("left");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3689 case VK_UP: return KEYSYM ("up");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3690 case VK_RIGHT: return KEYSYM ("right");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3691 case VK_DOWN: return KEYSYM ("down");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3692 case VK_INSERT: return KEYSYM ("insert");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3693 case VK_DELETE: return QKdelete;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3694 #if 0 /* FSF Emacs allows these to return configurable syms/mods */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3695 case VK_LWIN return KEYSYM ("");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3696 case VK_RWIN return KEYSYM ("");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3697 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3698 case VK_APPS: return KEYSYM ("menu");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3699 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3700 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3701 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3702 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3703 switch (mswindows_key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3704 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3705
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3706 #if 0
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3707 VK_LBUTTON:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3708 VK_RBUTTON:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3709 VK_CANCEL:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3710 VK_MBUTTON:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3711 VK_XBUTTON1:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3712 VK_XBUTTON2:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3713 #endif /* 0 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3714
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3715 case VK_BACK: return QKbackspace;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3716 case VK_TAB: return QKtab;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3717 /* #### Officially 0A (and 0B too) are "reserved". */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3718 case '\n': return QKlinefeed;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3719 case VK_CLEAR: return KEYSYM ("clear");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3720 case VK_RETURN: return QKreturn;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3721
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3722 #if 0
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3723 VK_SHIFT: "shift"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3724 VK_CONTROL: "control"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3725 VK_MENU: "alt"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3726 #endif /* 0 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3727
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
3728 case VK_PAUSE: return KEYSYM ("pause");
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3729
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3730 #if 0
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3731 VK_CAPITAL: "caps-lock"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3732 VK_KANA: IME Kana mode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3733 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
3734 VK_HANGUL: IME Hangul mode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3735 VK_JUNJA: IME Junja mode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3736 VK_FINAL: IME final mode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3737 VK_HANJA: IME Hanja mode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3738 VK_KANJI: IME Kanji mode
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3739 #endif /* 0 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3740
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3741 case VK_ESCAPE: return QKescape;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3742
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3743 #if 0
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3744 VK_CONVERT: IME convert
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3745 VK_NONCONVERT: IME nonconvert
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3746 VK_ACCEPT: IME accept
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3747 VK_MODECHANGE: IME mode change request
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3748 #endif /* 0 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3749
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3750 case VK_SPACE: return QKspace;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3751 case VK_PRIOR: return KEYSYM ("kp-prior");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3752 case VK_NEXT: return KEYSYM ("kp-next");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3753 case VK_END: return KEYSYM ("kp-end");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3754 case VK_HOME: return KEYSYM ("kp-home");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3755 case VK_LEFT: return KEYSYM ("kp-left");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3756 case VK_UP: return KEYSYM ("kp-up");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3757 case VK_RIGHT: return KEYSYM ("kp-right");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3758 case VK_DOWN: return KEYSYM ("kp-down");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3759 case VK_SELECT: return KEYSYM ("select");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3760 case VK_PRINT: return KEYSYM ("print");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3761 case VK_EXECUTE: return KEYSYM ("execute");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3762 case VK_SNAPSHOT: return KEYSYM ("print");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3763 case VK_INSERT: return KEYSYM ("kp-insert");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3764 case VK_DELETE: return KEYSYM ("kp-delete");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3765 case VK_HELP: return KEYSYM ("help");
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3766 #if 0
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3767 '0' through '9': numeric keys
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3768 'A' through 'Z': alphabetic keys
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3769 VK_LWIN: "lwin"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3770 VK_RWIN: "rwin"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3771 VK_APPS: "apps"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3772 VK_SLEEP: "sleep"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3773 #endif /* 0 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3774 case VK_NUMPAD0: return KEYSYM ("kp-0");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3775 case VK_NUMPAD1: return KEYSYM ("kp-1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3776 case VK_NUMPAD2: return KEYSYM ("kp-2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3777 case VK_NUMPAD3: return KEYSYM ("kp-3");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3778 case VK_NUMPAD4: return KEYSYM ("kp-4");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3779 case VK_NUMPAD5: return KEYSYM ("kp-5");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3780 case VK_NUMPAD6: return KEYSYM ("kp-6");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3781 case VK_NUMPAD7: return KEYSYM ("kp-7");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3782 case VK_NUMPAD8: return KEYSYM ("kp-8");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3783 case VK_NUMPAD9: return KEYSYM ("kp-9");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3784 case VK_MULTIPLY: return KEYSYM ("kp-multiply");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3785 case VK_ADD: return KEYSYM ("kp-add");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3786 case VK_SEPARATOR: return KEYSYM ("kp-separator");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3787 case VK_SUBTRACT: return KEYSYM ("kp-subtract");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3788 case VK_DECIMAL: return KEYSYM ("kp-decimal");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3789 case VK_DIVIDE: return KEYSYM ("kp-divide");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3790 case VK_F1: return KEYSYM ("f1");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3791 case VK_F2: return KEYSYM ("f2");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3792 case VK_F3: return KEYSYM ("f3");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3793 case VK_F4: return KEYSYM ("f4");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3794 case VK_F5: return KEYSYM ("f5");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3795 case VK_F6: return KEYSYM ("f6");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3796 case VK_F7: return KEYSYM ("f7");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3797 case VK_F8: return KEYSYM ("f8");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3798 case VK_F9: return KEYSYM ("f9");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3799 case VK_F10: return KEYSYM ("f10");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3800 case VK_F11: return KEYSYM ("f11");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3801 case VK_F12: return KEYSYM ("f12");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3802 case VK_F13: return KEYSYM ("f13");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3803 case VK_F14: return KEYSYM ("f14");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3804 case VK_F15: return KEYSYM ("f15");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3805 case VK_F16: return KEYSYM ("f16");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3806 case VK_F17: return KEYSYM ("f17");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3807 case VK_F18: return KEYSYM ("f18");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3808 case VK_F19: return KEYSYM ("f19");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3809 case VK_F20: return KEYSYM ("f20");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3810 case VK_F21: return KEYSYM ("f21");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3811 case VK_F22: return KEYSYM ("f22");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3812 case VK_F23: return KEYSYM ("f23");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3813 case VK_F24: return KEYSYM ("f24");
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3814
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3815 #if 0
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3816 VK_NUMLOCK: 90 NUM LOCK key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3817 VK_SCROLL: 91 SCROLL LOCK key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3818 92~96 OEM specific;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3819 VK_LSHIFT:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3820 VK_RSHIFT:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3821 VK_LCONTROL:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3822 VK_RCONTROL:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3823 VK_LMENU:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3824 VK_RMENU:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3825
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3826 #ifdef VK_BROWSER_BACK /* Windows 2000 only */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3827 VK_BROWSER_BACK: Browser Back key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3828 VK_BROWSER_FORWARD: Browser Forward key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3829 VK_BROWSER_REFRESH: Browser Refresh key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3830 VK_BROWSER_STOP: Browser Stop key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3831 VK_BROWSER_SEARCH: Browser Search key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3832 VK_BROWSER_FAVORITES: Browser Favorites key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3833 VK_BROWSER_HOME: Browser Start and Home key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3834 VK_VOLUME_MUTE: Volume Mute key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3835 VK_VOLUME_DOWN: Volume Down key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3836 VK_VOLUME_UP: Volume Up key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3837 VK_MEDIA_NEXT_TRACK: Next Track key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3838 VK_MEDIA_PREV_TRACK: Previous Track key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3839 VK_MEDIA_STOP: Stop Media key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3840 VK_MEDIA_PLAY_PAUSE: Play/Pause Media key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3841 VK_LAUNCH_MAIL: Start Mail key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3842 VK_LAUNCH_MEDIA_SELECT: Select Media key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3843 VK_LAUNCH_APP1: Start Application 1 key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3844 VK_LAUNCH_APP2: Start Application 2 key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3845 B8-B9 Reserved;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3846 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
3847 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
3848 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
3849 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
3850 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
3851 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
3852 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
3853 C1~D7 Reserved;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3854 D8~DA Unassigned;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3855 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
3856 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
3857 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
3858 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
3859 VK_OEM_8:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3860 E0 Reserved;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3861 E1 OEM specific;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3862 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
3863 E3~E4 OEM specific;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3864 #endif /* VK_BROWSER_BACK */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3865 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
3866 E6 OEM specific;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3867 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
3868 E8 Unassigned;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3869 E9~F5 OEM specific;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3870 VK_ATTN: Attn key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3871 VK_CRSEL: CrSel key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3872 VK_EXSEL: ExSel key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3873 VK_EREOF: Erase EOF key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3874 VK_PLAY: Play key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3875 VK_ZOOM: Zoom key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3876 VK_NONAME: Reserved for future use
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3877 VK_PA1: PA1 key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3878 VK_OEM_CLEAR: Clear key
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3879 #endif /* 0 */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3880
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3881 }
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 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3884 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3885
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3886 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3887 * Find the console that matches the supplied mswindows window handle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3888 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3889 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3890 mswindows_find_console (HWND hwnd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3891 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3892 /* We only support one console */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3893 return XCAR (Vconsole_list);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3896 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3897 * Find the frame that matches the supplied mswindows window handle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3898 */
546
666d73d6ac56 [xemacs-hg @ 2001-05-20 01:17:07 by ben]
ben
parents: 535
diff changeset
3899 Lisp_Object
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3900 mswindows_find_frame (HWND hwnd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3901 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
3902 LONG l = qxeGetWindowLong (hwnd, XWL_FRAMEOBJ);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3903 Lisp_Object f;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3904 if (l == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3905 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3906 /* We are in progress of frame creation. Return the frame
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3907 being created, as it still not remembered in the window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3908 extra storage. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3909 assert (!NILP (Vmswindows_frame_being_created));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3910 return Vmswindows_frame_being_created;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3911 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3912 VOID_TO_LISP (f, l);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3913 return f;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3914 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3915
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3916
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3917 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3918 /* methods */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3919 /************************************************************************/
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 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3922 emacs_mswindows_add_timeout (EMACS_TIME thyme)
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 int milliseconds;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3925 EMACS_TIME current_time;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3926 EMACS_GET_TIME (current_time);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3927 EMACS_SUB_TIME (thyme, thyme, current_time);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3928 milliseconds = EMACS_SECS (thyme) * 1000 +
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3929 (EMACS_USECS (thyme) + 500) / 1000;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3930 if (milliseconds < 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3931 milliseconds = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3932 ++mswindows_pending_timers_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3933 return SetTimer (NULL, 0, milliseconds,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3934 (TIMERPROC) mswindows_wm_timer_callback);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3935 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3936
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3937 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3938 emacs_mswindows_remove_timeout (int id)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3939 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
3940 Lisp_Event match_against;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3941 Lisp_Object emacs_event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3942
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3943 if (KillTimer (NULL, id))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3944 --mswindows_pending_timers_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3945
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3946 /* If there is a dispatch event generated by this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3947 timeout in the queue, we have to remove it too. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3948 match_against.event_type = timeout_event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3949 match_against.event.timeout.interval_id = id;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3950 emacs_event = mswindows_cancel_dispatch_event (&match_against);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3951 if (!NILP (emacs_event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3952 Fdeallocate_event(emacs_event);
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 /* 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
3956 * or subprocess events pending (that is, whether
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3957 * emacs_mswindows_next_event() would return immediately without blocking).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3958 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3959 * 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
3960 * events available (that is, whether there are keyboard or mouse-click
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3961 * events ready to be read). This also implies that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3962 * emacs_mswindows_next_event() would not block.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3963 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3964 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3965 emacs_mswindows_event_pending_p (int user_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3966 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3967 mswindows_need_event (0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3968 return (!NILP (mswindows_u_dispatch_event_queue)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3969 || (!user_p && !NILP (mswindows_s_dispatch_event_queue)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3970 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3971
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3972 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3973 * Return the next event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3974 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3975 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
3976 emacs_mswindows_next_event (Lisp_Event *emacs_event)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3977 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3978 Lisp_Object event, event2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3979
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3980 mswindows_need_event (1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3981
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3982 event = mswindows_dequeue_dispatch_event ();
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
3983 event2 = wrap_event (emacs_event);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3984 Fcopy_event (event, event2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3985 Fdeallocate_event (event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3986 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3987
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
3988 static void
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
3989 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
3990 Lisp_Object pstream)
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
3991 {
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
3992 #define FROB(msg) case msg: write_c_string ("type=" #msg, pstream); break
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
3993
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
3994 switch (EVENT_MSWINDOWS_MAGIC_TYPE (emacs_event))
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
3995 {
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
3996 FROB (XM_BUMPQUEUE);
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
3997 FROB (WM_PAINT);
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
3998 FROB (WM_SETFOCUS);
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
3999 FROB (WM_KILLFOCUS);
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4000 FROB (XM_MAPFRAME);
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4001 FROB (XM_UNMAPFRAME);
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4002
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4003 default: abort ();
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4004 }
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4005 #undef FROB
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4006
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4007 if (!NILP (EVENT_CHANNEL (emacs_event)))
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4008 {
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4009 write_c_string (" ", pstream);
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4010 print_internal (EVENT_CHANNEL (emacs_event), pstream, 1);
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4011 }
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4012 }
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4013
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4014 static int
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4015 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
4016 {
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4017 return (e1->event.magic.underlying_mswindows_event ==
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4018 e2->event.magic.underlying_mswindows_event);
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4019 }
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4020
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4021 static Hashcode
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4022 emacs_mswindows_hash_magic_event (Lisp_Event *e)
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4023 {
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4024 return e->event.magic.underlying_mswindows_event;
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4025 }
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 771
diff changeset
4026
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4027 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4028 * Handle a magic event off the dispatch queue.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4029 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4030 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4031 emacs_mswindows_handle_magic_event (Lisp_Event *emacs_event)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4032 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4033 switch (EVENT_MSWINDOWS_MAGIC_TYPE (emacs_event))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4034 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4035 case XM_BUMPQUEUE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4036 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4037
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4038 case WM_PAINT:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4039 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4040 struct frame *f = XFRAME (EVENT_CHANNEL (emacs_event));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4041 mswindows_handle_paint (f);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4042 (FRAME_MSWINDOWS_DATA (f))->paint_pending = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4043 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4044 break;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4045
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4046 case WM_SETFOCUS:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4047 case WM_KILLFOCUS:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4048 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4049 Lisp_Object frame = EVENT_CHANNEL (emacs_event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4050 struct frame *f = XFRAME (frame);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4051 int in_p = (EVENT_MSWINDOWS_MAGIC_TYPE (emacs_event) == WM_SETFOCUS);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4052 Lisp_Object conser;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4053 struct gcpro gcpro1;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4054
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4055 /* On focus change, clear all memory of sticky modifiers
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4056 to avoid non-intuitive behavior. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4057 clear_sticky_modifiers ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4058
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4059 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
4060 GCPRO1 (conser);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4061 emacs_handle_focus_change_preliminary (conser);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4062 /* 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
4063 I Don't know why */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4064 emacs_handle_focus_change_final (conser);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4065 UNGCPRO;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4066
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4067 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4068 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4069
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4070 case XM_MAPFRAME:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4071 case XM_UNMAPFRAME:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4072 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4073 Lisp_Object frame = EVENT_CHANNEL (emacs_event);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4074 va_run_hook_with_args (EVENT_MSWINDOWS_MAGIC_TYPE (emacs_event)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4075 == XM_MAPFRAME ?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4076 Qmap_frame_hook : Qunmap_frame_hook,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4077 1, frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4078 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4079 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4080
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4081 /* #### What about Enter & Leave */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4082 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4083 va_run_hook_with_args (in_p ? Qmouse_enter_frame_hook :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4084 Qmouse_leave_frame_hook, 1, frame);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4085 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4086
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4087 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4088 assert(0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4089 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4090 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4091
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4092 #ifndef HAVE_MSG_SELECT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4093 static HANDLE
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4094 get_process_input_waitable (Lisp_Process *process)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4095 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4096 Lisp_Object instr, outstr, p;
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
4097 p = wrap_process (process);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4098 get_process_streams (process, &instr, &outstr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4099 assert (!NILP (instr));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4100 #if defined (HAVE_SOCKETS) && !defined(HAVE_MSG_SELECT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4101 return (network_connection_p (p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4102 ? get_winsock_stream_waitable (XLSTREAM (instr))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4103 : get_ntpipe_input_stream_waitable (XLSTREAM (instr)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4104 #else
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4105 return get_ntpipe_input_stream_waitable (XLSTREAM (instr));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4106 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4107 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4109 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4110 emacs_mswindows_select_process (Lisp_Process *process)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4111 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4112 HANDLE hev = get_process_input_waitable (process);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4114 if (!add_waitable_handle (hev))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 560
diff changeset
4115 invalid_operation ("Too many active processes", Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4116
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4117 #ifdef HAVE_WIN32_PROCESSES
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4118 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
4119 Lisp_Object p = wrap_process (process);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 791
diff changeset
4120
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4121 if (!network_connection_p (p))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4122 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4123 HANDLE hprocess = get_nt_process_handle (process);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4124 if (!add_waitable_handle (hprocess))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4125 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4126 remove_waitable_handle (hev);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 560
diff changeset
4127 invalid_operation ("Too many active processes", Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4128 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4129 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4130 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4131 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4132 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4133
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4134 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4135 emacs_mswindows_unselect_process (Lisp_Process *process)
428
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 /* Process handle is removed in the event loop as soon
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4138 as it is signaled, so don't bother here about it */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4139 HANDLE hev = get_process_input_waitable (process);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4140 remove_waitable_handle (hev);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4141 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4142 #endif /* HAVE_MSG_SELECT */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4144 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4145 emacs_mswindows_select_console (struct console *con)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4146 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4147 #ifdef HAVE_MSG_SELECT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4148 if (CONSOLE_MSWINDOWS_P (con))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4149 return; /* mswindows consoles are automatically selected */
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 event_stream_unixoid_select_console (con);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4152 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4153 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4155 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4156 emacs_mswindows_unselect_console (struct console *con)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4157 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4158 #ifdef HAVE_MSG_SELECT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4159 if (CONSOLE_MSWINDOWS_P (con))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4160 return; /* mswindows consoles are automatically selected */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4161
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4162 event_stream_unixoid_unselect_console (con);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4163 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4164 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4165
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4166 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4167 emacs_mswindows_quit_p (void)
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 /* Quit cannot happen in modal loop: all program
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4170 input is dedicated to Windows. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4171 if (mswindows_in_modal_loop)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4172 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4173
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4174 mswindows_quit_chars_count = 0;
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
4175 /* Drain windows queue. This sets up number of quit characters in
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
4176 the queue. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4177 mswindows_drain_windows_queue ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4178
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4179 if (mswindows_quit_chars_count > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4180 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4181 /* Yes there's a hidden one... Throw it away */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4182 Lisp_Event match_against;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4183 Lisp_Object emacs_event;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4184 int critical_p = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4185
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4186 match_against.event_type = key_press_event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4187 match_against.event.key.modifiers = FAKE_MOD_QUIT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4188
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4189 while (mswindows_quit_chars_count > 0)
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4190 {
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4191 emacs_event = mswindows_cancel_dispatch_event (&match_against);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4192 assert (!NILP (emacs_event));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4193
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
4194 if (XEVENT (emacs_event)->event.key.modifiers &
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
4195 FAKE_MOD_QUIT_CRITICAL)
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4196 critical_p = 1;
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4197
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
4198 Fdeallocate_event (emacs_event);
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4199 mswindows_quit_chars_count--;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4200 }
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4201
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4202 Vquit_flag = critical_p ? Qcritical : Qt;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4203 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4204 }
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 USID
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4207 emacs_mswindows_create_stream_pair (void *inhandle, void *outhandle,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4208 Lisp_Object *instream,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4209 Lisp_Object *outstream,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4210 int flags)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4211 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4212 /* Handles for streams */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4213 HANDLE hin, hout;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4214 /* fds. These just stored along with the streams, and are closed in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4215 delete stream pair method, because we need to handle fake unices
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4216 here. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4217 int fdi, fdo;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4218
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4219 /* Decode inhandle and outhandle. Their meaning depends on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4220 the process implementation being used. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4221 #if defined (HAVE_WIN32_PROCESSES)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4222 /* We're passed in Windows handles. That's what we like most... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4223 hin = (HANDLE) inhandle;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4224 hout = (HANDLE) outhandle;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4225 fdi = fdo = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4226 #elif defined (HAVE_UNIX_PROCESSES)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4227 /* We are passed UNIX fds. This must be Cygwin.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4228 Fetch os handles */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4229 hin = inhandle >= 0 ? (HANDLE)get_osfhandle ((int)inhandle) : INVALID_HANDLE_VALUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4230 hout = outhandle >= 0 ? (HANDLE)get_osfhandle ((int)outhandle) : INVALID_HANDLE_VALUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4231 fdi=(int)inhandle;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4232 fdo=(int)outhandle;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4233 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4234 #error "So, WHICH kind of processes do you want?"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4235 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4236
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4237 *instream = (hin == INVALID_HANDLE_VALUE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4238 ? Qnil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4239 #if defined (HAVE_SOCKETS) && !defined (HAVE_MSG_SELECT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4240 : flags & STREAM_NETWORK_CONNECTION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4241 ? make_winsock_input_stream ((SOCKET)hin, fdi)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4242 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4243 : make_ntpipe_input_stream (hin, fdi));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4244
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4245 #ifdef HAVE_WIN32_PROCESSES
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4246 *outstream = (hout == INVALID_HANDLE_VALUE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4247 ? Qnil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4248 #if defined (HAVE_SOCKETS) && !defined (HAVE_MSG_SELECT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4249 : flags & STREAM_NETWORK_CONNECTION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4250 ? make_winsock_output_stream ((SOCKET)hout, fdo)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4251 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4252 : make_ntpipe_output_stream (hout, fdo));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4253 #elif defined (HAVE_UNIX_PROCESSES)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4254 *outstream = (fdo >= 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4255 ? make_filedesc_output_stream (fdo, 0, -1, LSTR_BLOCKED_OK)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4256 : Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4257
535
c69610198c35 [xemacs-hg @ 2001-05-14 04:52:02 by martinb]
martinb
parents: 534
diff changeset
4258 #if defined(HAVE_UNIX_PROCESSES)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4259 /* FLAGS is process->pty_flag for UNIX_PROCESSES */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4260 if ((flags & STREAM_PTY_FLUSHING) && fdo >= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4261 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 657
diff changeset
4262 Intbyte eof_char = get_eof_char (fdo);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4263 int pty_max_bytes = get_pty_max_bytes (fdo);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4264 filedesc_stream_set_pty_flushing (XLSTREAM(*outstream), pty_max_bytes, eof_char);
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 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4267 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4269 return (NILP (*instream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4270 ? USID_ERROR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4271 #if defined(HAVE_SOCKETS) && !defined(HAVE_MSG_SELECT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4272 : flags & STREAM_NETWORK_CONNECTION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4273 ? HANDLE_TO_USID (get_winsock_stream_waitable (XLSTREAM (*instream)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4274 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4275 : HANDLE_TO_USID (get_ntpipe_input_stream_waitable (XLSTREAM (*instream))));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4276 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4277
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4278 USID
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4279 emacs_mswindows_delete_stream_pair (Lisp_Object instream,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4280 Lisp_Object outstream)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4281 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4282 /* Oh nothing special here for Win32 at all */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4283 #if defined (HAVE_UNIX_PROCESSES)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4284 int in = (NILP(instream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4285 ? -1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4286 #if defined(HAVE_SOCKETS) && !defined(HAVE_MSG_SELECT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4287 : LSTREAM_TYPE_P (XLSTREAM (instream), winsock)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4288 ? get_winsock_stream_param (XLSTREAM (instream))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4289 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4290 : get_ntpipe_input_stream_param (XLSTREAM (instream)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4291 int out = (NILP(outstream) ? -1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4292 : filedesc_stream_fd (XLSTREAM (outstream)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4293
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4294 if (in >= 0)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4295 retry_close (in);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4296 if (out != in && out >= 0)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4297 retry_close (out);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4298 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4300 return (NILP (instream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4301 ? USID_DONTHASH
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4302 #if defined(HAVE_SOCKETS) && !defined(HAVE_MSG_SELECT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4303 : LSTREAM_TYPE_P (XLSTREAM (instream), winsock)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4304 ? HANDLE_TO_USID (get_winsock_stream_waitable (XLSTREAM (instream)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4305 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4306 : HANDLE_TO_USID (get_ntpipe_input_stream_waitable (XLSTREAM (instream))));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4307 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4308
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4309 static int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4310 emacs_mswindows_current_event_timestamp (struct console *c)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4311 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4312 return GetTickCount ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4313 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4314
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4315 #ifndef HAVE_X_WINDOWS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4316 /* 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
4317 If we've still got pointers to it in this file, we're gonna lose hard.
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 void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
4320 debug_process_finalization (Lisp_Process *p)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4321 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4322 #if 0 /* #### */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4323 Lisp_Object instr, outstr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4324
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4325 get_process_streams (p, &instr, &outstr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4326 /* 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
4327 assert (NILP (instr));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4328 assert (NILP (outstr));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4329
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4330 /* #### More checks here */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4331 #endif
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 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4334
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4335 #ifdef DEBUG_XEMACS
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4336
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4337 struct mswin_message_debug
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4338 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4339 int mess;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4340 char *string;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4341 };
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4342
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4343 #define FROB(val) { val, #val, },
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4344
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4345 struct mswin_message_debug debug_mswin_messages[] =
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4346 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4347 FROB (WM_NULL)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4348 FROB (WM_CREATE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4349 FROB (WM_DESTROY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4350 FROB (WM_MOVE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4351 FROB (WM_SIZE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4352
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4353 FROB (WM_ACTIVATE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4354
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4355 FROB (WM_SETFOCUS)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4356 FROB (WM_KILLFOCUS)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4357 FROB (WM_ENABLE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4358 FROB (WM_SETREDRAW)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4359 FROB (WM_SETTEXT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4360 FROB (WM_GETTEXT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4361 FROB (WM_GETTEXTLENGTH)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4362 FROB (WM_PAINT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4363 FROB (WM_CLOSE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4364 FROB (WM_QUERYENDSESSION)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4365 FROB (WM_QUIT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4366 FROB (WM_QUERYOPEN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4367 FROB (WM_ERASEBKGND)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4368 FROB (WM_SYSCOLORCHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4369 FROB (WM_ENDSESSION)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4370 FROB (WM_SHOWWINDOW)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4371 FROB (WM_WININICHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4372 #if(WINVER >= 0x0400)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4373 FROB (WM_SETTINGCHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4374 #endif /* WINVER >= 0x0400 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4375
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4376 FROB (WM_DEVMODECHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4377 FROB (WM_ACTIVATEAPP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4378 FROB (WM_FONTCHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4379 FROB (WM_TIMECHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4380 FROB (WM_CANCELMODE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4381 FROB (WM_SETCURSOR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4382 FROB (WM_MOUSEACTIVATE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4383 FROB (WM_CHILDACTIVATE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4384 FROB (WM_QUEUESYNC)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4385
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4386 FROB (WM_GETMINMAXINFO)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4387
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4388 FROB (WM_PAINTICON)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4389 FROB (WM_ICONERASEBKGND)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4390 FROB (WM_NEXTDLGCTL)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4391 FROB (WM_SPOOLERSTATUS)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4392 FROB (WM_DRAWITEM)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4393 FROB (WM_MEASUREITEM)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4394 FROB (WM_DELETEITEM)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4395 FROB (WM_VKEYTOITEM)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4396 FROB (WM_CHARTOITEM)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4397 FROB (WM_SETFONT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4398 FROB (WM_GETFONT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4399 FROB (WM_SETHOTKEY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4400 FROB (WM_GETHOTKEY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4401 FROB (WM_QUERYDRAGICON)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4402 FROB (WM_COMPAREITEM)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4403 #if(WINVER >= 0x0500)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4404 FROB (WM_GETOBJECT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4405 #endif /* WINVER >= 0x0500 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4406 FROB (WM_COMPACTING)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4407 FROB (WM_COMMNOTIFY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4408 FROB (WM_WINDOWPOSCHANGING)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4409 FROB (WM_WINDOWPOSCHANGED)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4410
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4411 FROB (WM_POWER)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4412
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4413 FROB (WM_COPYDATA)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4414 FROB (WM_CANCELJOURNAL)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4415
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4416 #if(WINVER >= 0x0400)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4417 FROB (WM_NOTIFY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4418 FROB (WM_INPUTLANGCHANGEREQUEST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4419 FROB (WM_INPUTLANGCHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4420 FROB (WM_TCARD)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4421 FROB (WM_HELP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4422 FROB (WM_USERCHANGED)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4423 FROB (WM_NOTIFYFORMAT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4424
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4425 FROB (WM_CONTEXTMENU)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4426 FROB (WM_STYLECHANGING)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4427 FROB (WM_STYLECHANGED)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4428 FROB (WM_DISPLAYCHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4429 FROB (WM_GETICON)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4430 FROB (WM_SETICON)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4431 #endif /* WINVER >= 0x0400 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4432
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4433 FROB (WM_NCCREATE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4434 FROB (WM_NCDESTROY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4435 FROB (WM_NCCALCSIZE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4436 FROB (WM_NCHITTEST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4437 FROB (WM_NCPAINT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4438 FROB (WM_NCACTIVATE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4439 FROB (WM_GETDLGCODE)
604
fa3b8eb89cb2 [xemacs-hg @ 2001-06-02 05:40:49 by ben]
ben
parents: 593
diff changeset
4440 #ifdef WM_SYNCPAINT /* not in VC 5 */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4441 FROB (WM_SYNCPAINT)
604
fa3b8eb89cb2 [xemacs-hg @ 2001-06-02 05:40:49 by ben]
ben
parents: 593
diff changeset
4442 #endif /* WM_SYNCPAINT */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4443 FROB (WM_NCMOUSEMOVE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4444 FROB (WM_NCLBUTTONDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4445 FROB (WM_NCLBUTTONUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4446 FROB (WM_NCLBUTTONDBLCLK)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4447 FROB (WM_NCRBUTTONDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4448 FROB (WM_NCRBUTTONUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4449 FROB (WM_NCRBUTTONDBLCLK)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4450 FROB (WM_NCMBUTTONDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4451 FROB (WM_NCMBUTTONUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4452 FROB (WM_NCMBUTTONDBLCLK)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4453
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4454 /* FROB (WM_KEYFIRST) */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4455 FROB (WM_KEYDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4456 FROB (WM_KEYUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4457 FROB (WM_CHAR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4458 FROB (WM_DEADCHAR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4459 FROB (WM_SYSKEYDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4460 FROB (WM_SYSKEYUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4461 FROB (WM_SYSCHAR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4462 FROB (WM_SYSDEADCHAR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4463 FROB (WM_KEYLAST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4464
604
fa3b8eb89cb2 [xemacs-hg @ 2001-06-02 05:40:49 by ben]
ben
parents: 593
diff changeset
4465 #if(WINVER >= 0x0400) && defined (WM_IME_STARTCOMPOSITION)
fa3b8eb89cb2 [xemacs-hg @ 2001-06-02 05:40:49 by ben]
ben
parents: 593
diff changeset
4466 /* not in Cygwin? */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4467 FROB (WM_IME_STARTCOMPOSITION)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4468 FROB (WM_IME_ENDCOMPOSITION)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4469 FROB (WM_IME_COMPOSITION)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4470 FROB (WM_IME_KEYLAST)
604
fa3b8eb89cb2 [xemacs-hg @ 2001-06-02 05:40:49 by ben]
ben
parents: 593
diff changeset
4471 #endif /* WINVER >= 0x0400 && defined (WM_IME_STARTCOMPOSITION) */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4472
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4473 FROB (WM_INITDIALOG)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4474 FROB (WM_COMMAND)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4475 FROB (WM_SYSCOMMAND)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4476 FROB (WM_TIMER)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4477 FROB (WM_HSCROLL)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4478 FROB (WM_VSCROLL)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4479 FROB (WM_INITMENU)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4480 FROB (WM_INITMENUPOPUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4481 FROB (WM_MENUSELECT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4482 FROB (WM_MENUCHAR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4483 FROB (WM_ENTERIDLE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4484 #if(WINVER >= 0x0500)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4485 FROB (WM_MENURBUTTONUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4486 FROB (WM_MENUDRAG)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4487 FROB (WM_MENUGETOBJECT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4488 FROB (WM_UNINITMENUPOPUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4489 FROB (WM_MENUCOMMAND)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4490 #endif /* WINVER >= 0x0500 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4491
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4492
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4493 FROB (WM_CTLCOLORMSGBOX)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4494 FROB (WM_CTLCOLOREDIT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4495 FROB (WM_CTLCOLORLISTBOX)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4496 FROB (WM_CTLCOLORBTN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4497 FROB (WM_CTLCOLORDLG)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4498 FROB (WM_CTLCOLORSCROLLBAR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4499 FROB (WM_CTLCOLORSTATIC)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4500
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4501
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4502 /* FROB (WM_MOUSEFIRST) */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4503 FROB (WM_MOUSEMOVE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4504 FROB (WM_LBUTTONDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4505 FROB (WM_LBUTTONUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4506 FROB (WM_LBUTTONDBLCLK)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4507 FROB (WM_RBUTTONDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4508 FROB (WM_RBUTTONUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4509 FROB (WM_RBUTTONDBLCLK)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4510 FROB (WM_MBUTTONDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4511 FROB (WM_MBUTTONUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4512 FROB (WM_MBUTTONDBLCLK)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4513
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4514 #if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4515 FROB (WM_MOUSEWHEEL)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4516 FROB (WM_MOUSELAST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4517 #else
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4518 FROB (WM_MOUSELAST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4519 #endif /* if (_WIN32_WINNT < 0x0400) */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4520
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4521 FROB (WM_PARENTNOTIFY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4522 FROB (WM_ENTERMENULOOP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4523 FROB (WM_EXITMENULOOP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4524
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4525 #if(WINVER >= 0x0400)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4526 FROB (WM_NEXTMENU)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4527
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4528 FROB (WM_SIZING)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4529 FROB (WM_CAPTURECHANGED)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4530 FROB (WM_MOVING)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4531 FROB (WM_POWERBROADCAST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4532
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4533 FROB (WM_DEVICECHANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4534
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4535 #endif /* WINVER >= 0x0400 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4536
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4537 FROB (WM_MDICREATE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4538 FROB (WM_MDIDESTROY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4539 FROB (WM_MDIACTIVATE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4540 FROB (WM_MDIRESTORE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4541 FROB (WM_MDINEXT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4542 FROB (WM_MDIMAXIMIZE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4543 FROB (WM_MDITILE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4544 FROB (WM_MDICASCADE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4545 FROB (WM_MDIICONARRANGE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4546 FROB (WM_MDIGETACTIVE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4547
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4548
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4549 FROB (WM_MDISETMENU)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4550 FROB (WM_ENTERSIZEMOVE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4551 FROB (WM_EXITSIZEMOVE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4552 FROB (WM_DROPFILES)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4553 FROB (WM_MDIREFRESHMENU)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4554
604
fa3b8eb89cb2 [xemacs-hg @ 2001-06-02 05:40:49 by ben]
ben
parents: 593
diff changeset
4555 #ifdef WM_IME_SETCONTEXT /* not in Cygwin? */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4556
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4557 #if(WINVER >= 0x0400)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4558 FROB (WM_IME_SETCONTEXT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4559 FROB (WM_IME_NOTIFY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4560 FROB (WM_IME_CONTROL)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4561 FROB (WM_IME_COMPOSITIONFULL)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4562 FROB (WM_IME_SELECT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4563 FROB (WM_IME_CHAR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4564 #endif /* WINVER >= 0x0400 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4565 #if(WINVER >= 0x0500)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4566 FROB (WM_IME_REQUEST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4567 #endif /* WINVER >= 0x0500 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4568 #if(WINVER >= 0x0400)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4569 FROB (WM_IME_KEYDOWN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4570 FROB (WM_IME_KEYUP)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4571 #endif /* WINVER >= 0x0400 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4572
604
fa3b8eb89cb2 [xemacs-hg @ 2001-06-02 05:40:49 by ben]
ben
parents: 593
diff changeset
4573 #endif /* WM_IME_SETCONTEXT */
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4574
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4575 #if(_WIN32_WINNT >= 0x0400)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4576 FROB (WM_MOUSEHOVER)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4577 FROB (WM_MOUSELEAVE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4578 #endif /* _WIN32_WINNT >= 0x0400 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4579
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4580 FROB (WM_CUT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4581 FROB (WM_COPY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4582 FROB (WM_PASTE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4583 FROB (WM_CLEAR)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4584 FROB (WM_UNDO)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4585 FROB (WM_RENDERFORMAT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4586 FROB (WM_RENDERALLFORMATS)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4587 FROB (WM_DESTROYCLIPBOARD)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4588 FROB (WM_DRAWCLIPBOARD)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4589 FROB (WM_PAINTCLIPBOARD)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4590 FROB (WM_VSCROLLCLIPBOARD)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4591 FROB (WM_SIZECLIPBOARD)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4592 FROB (WM_ASKCBFORMATNAME)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4593 FROB (WM_CHANGECBCHAIN)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4594 FROB (WM_HSCROLLCLIPBOARD)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4595 FROB (WM_QUERYNEWPALETTE)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4596 FROB (WM_PALETTEISCHANGING)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4597 FROB (WM_PALETTECHANGED)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4598 FROB (WM_HOTKEY)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4599
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4600 #if(WINVER >= 0x0400)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4601 FROB (WM_PRINT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4602 FROB (WM_PRINTCLIENT)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4603
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4604 FROB (WM_HANDHELDFIRST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4605 FROB (WM_HANDHELDLAST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4606
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4607 FROB (WM_AFXFIRST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4608 FROB (WM_AFXLAST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4609 #endif /* WINVER >= 0x0400 */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4610
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4611 FROB (WM_PENWINFIRST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4612 FROB (WM_PENWINLAST)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4613 };
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4614
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4615 #undef FROB
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4616
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4617 static void
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4618 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
4619 LPARAM lParam)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4620 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4621 Lisp_Object frame = mswindows_find_frame (hwnd);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4622 int i;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4623 char *str = 0;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4624 /* 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
4625
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4626 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
4627 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
4628 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
4629 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4630 str = debug_mswin_messages[i].string;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4631 break;
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4632 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4633 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4634
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4635 if (str)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4636 stderr_out ("%s", str);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4637 else
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4638 stderr_out ("%x", message_);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4639
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4640 if (debug_mswindows_events > 1)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4641 {
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4642 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
4643 wParam, (int) lParam, (unsigned int) hwnd);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4644 debug_print (frame);
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4645 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4646 else
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4647 stderr_out ("\n");
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4648 }
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4649
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4650 #endif /* DEBUG_XEMACS */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4651
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 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4654 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4655
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4656 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4657 reinit_vars_of_event_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4658 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4659 mswindows_in_modal_loop = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4660 mswindows_pending_timers_count = 0;
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 mswindows_event_stream = xnew (struct event_stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4663
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4664 mswindows_event_stream->event_pending_p = emacs_mswindows_event_pending_p;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4665 mswindows_event_stream->force_event_pending = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4666 mswindows_event_stream->next_event_cb = emacs_mswindows_next_event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4667 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
4668 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
4669 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
4670 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
4671 mswindows_event_stream->add_timeout_cb = emacs_mswindows_add_timeout;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4672 mswindows_event_stream->remove_timeout_cb = emacs_mswindows_remove_timeout;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4673 mswindows_event_stream->quit_p_cb = emacs_mswindows_quit_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4674 mswindows_event_stream->select_console_cb = emacs_mswindows_select_console;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4675 mswindows_event_stream->unselect_console_cb = emacs_mswindows_unselect_console;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4676 #ifdef HAVE_MSG_SELECT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4677 mswindows_event_stream->select_process_cb =
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4678 (void (*)(Lisp_Process *)) event_stream_unixoid_select_process;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4679 mswindows_event_stream->unselect_process_cb =
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4680 (void (*)(Lisp_Process *)) event_stream_unixoid_unselect_process;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4681 mswindows_event_stream->create_stream_pair_cb = event_stream_unixoid_create_stream_pair;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4682 mswindows_event_stream->delete_stream_pair_cb = event_stream_unixoid_delete_stream_pair;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4683 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4684 mswindows_event_stream->select_process_cb = emacs_mswindows_select_process;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4685 mswindows_event_stream->unselect_process_cb = emacs_mswindows_unselect_process;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4686 mswindows_event_stream->create_stream_pair_cb = emacs_mswindows_create_stream_pair;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4687 mswindows_event_stream->delete_stream_pair_cb = emacs_mswindows_delete_stream_pair;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4688 #endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4689 mswindows_event_stream->current_event_timestamp_cb =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4690 emacs_mswindows_current_event_timestamp;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4691 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4692
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4693 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4694 vars_of_event_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4695 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4696 reinit_vars_of_event_mswindows ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4697
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4698 mswindows_u_dispatch_event_queue = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4699 staticpro (&mswindows_u_dispatch_event_queue);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4700 mswindows_u_dispatch_event_queue_tail = Qnil;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
4701 dump_add_root_object (&mswindows_u_dispatch_event_queue_tail);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4702
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4703 mswindows_s_dispatch_event_queue = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4704 staticpro (&mswindows_s_dispatch_event_queue);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4705 mswindows_s_dispatch_event_queue_tail = Qnil;
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 446
diff changeset
4706 dump_add_root_object (&mswindows_s_dispatch_event_queue_tail);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4707
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4708 mswindows_error_caught_in_modal_loop = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4709 staticpro (&mswindows_error_caught_in_modal_loop);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4710
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4711
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4712 #ifdef DEBUG_XEMACS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4713 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
4714 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
4715 Information is displayed in a console window. Currently defined values are:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4716
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4717 1 == non-verbose output (just the message name)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4718 2 == verbose output (all parameters)
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 588
diff changeset
4719 3 == even more verbose output (extra debugging info)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4720 */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4721 debug_mswindows_events = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4722 #endif
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4723
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4724 DEFVAR_BOOL ("mswindows-alt-by-itself-activates-menu",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4725 &mswindows_alt_by_itself_activates_menu /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4726 *Controls whether pressing and releasing the Alt key activates the menubar.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4727 This applies only if no intervening key was pressed. See also
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4728 `menu-accelerator-enabled', which is probably the behavior you actually want.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4729 Default is t.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4730 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4731
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4732 DEFVAR_BOOL ("mswindows-dynamic-frame-resize",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4733 &mswindows_dynamic_frame_resize /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4734 *Controls redrawing frame contents during mouse-drag or keyboard resize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4735 operation. When non-nil, the frame is redrawn while being resized. When
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4736 nil, frame is not redrawn, and exposed areas are filled with default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4737 MDI application background color. Note that this option only has effect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4738 if "Show window contents while dragging" is on in system Display/Plus!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4739 settings.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4740 Default is t on fast machines, nil on slow.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4741 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4742
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4743 DEFVAR_INT ("mswindows-mouse-button-tolerance",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4744 &mswindows_mouse_button_tolerance /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4745 *Analogue of double click interval for faking middle mouse events.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4746 The value is the minimum time in milliseconds that must elapse between
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4747 left/right button down events before they are considered distinct events.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4748 If both mouse buttons are depressed within this interval, a middle mouse
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4749 button down event is generated instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4750 If negative or zero, currently set system default is used instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4751 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4752
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4753 DEFVAR_INT ("mswindows-num-mouse-buttons", &mswindows_num_mouse_buttons /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4754 Number of physical mouse buttons.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4755 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4756
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4757 DEFVAR_INT ("mswindows-mouse-button-max-skew-x",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4758 &mswindows_mouse_button_max_skew_x /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4759 *Maximum horizontal distance in pixels between points in which left and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4760 right button clicks occurred for them to be translated into single
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4761 middle button event. Clicks must occur in time not longer than defined
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4762 by the variable `mswindows-mouse-button-tolerance'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4763 If negative or zero, currently set system default is used instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4764 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4765
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4766 DEFVAR_INT ("mswindows-mouse-button-max-skew-y",
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4767 &mswindows_mouse_button_max_skew_y /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4768 *Maximum vertical distance in pixels between points in which left and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4769 right button clicks occurred for them to be translated into single
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4770 middle button event. Clicks must occur in time not longer than defined
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4771 by the variable `mswindows-mouse-button-tolerance'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4772 If negative or zero, currently set system default is used instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4773 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4774
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4775 mswindows_mouse_button_max_skew_x = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4776 mswindows_mouse_button_max_skew_y = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4777 mswindows_mouse_button_tolerance = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
4778 mswindows_alt_by_itself_activates_menu = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4779 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4780
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4781 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4782 syms_of_event_mswindows (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4783 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4784 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4785
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4786 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4787 lstream_type_create_mswindows_selectable (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4788 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4789 init_slurp_stream ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4790 init_shove_stream ();
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
4791 #if defined (HAVE_SOCKETS) && !defined (HAVE_MSG_SELECT)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4792 init_winsock_stream ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4793 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4794 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4795
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4796 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4797 init_event_mswindows_late (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4798 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4799 #ifdef HAVE_MSG_SELECT
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 731
diff changeset
4800 windows_fd = retry_open ("/dev/windows", O_RDONLY | O_NONBLOCK, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4801 assert (windows_fd>=0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4802 FD_SET (windows_fd, &input_wait_mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4803 FD_ZERO(&zero_mask);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4804 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4805
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4806 event_stream = mswindows_event_stream;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4807
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4808 mswindows_dynamic_frame_resize = !GetSystemMetrics (SM_SLOWMACHINE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4809 mswindows_num_mouse_buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4810 }