comparison src/event-unixoid.c @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents 2f8bb876ab1d
children
comparison
equal deleted inserted replaced
411:12e008d41344 412:697ef44129c6
39 #include "sysdep.h" 39 #include "sysdep.h"
40 #include "sysfile.h" 40 #include "sysfile.h"
41 #include "sysproc.h" /* select stuff */ 41 #include "sysproc.h" /* select stuff */
42 #include "systime.h" 42 #include "systime.h"
43 43
44 #ifdef HAVE_GPM
45 #include "gpmevent.h"
46 #endif
47
44 /* Mask of bits indicating the descriptors that we wait for input on. 48 /* Mask of bits indicating the descriptors that we wait for input on.
45 These work as follows: 49 These work as follows:
46 50
47 input_wait_mask == mask of all file descriptors we select() on, 51 input_wait_mask == mask of all file descriptors we select() on,
48 including TTY/stream console descriptors, 52 including TTY/stream console descriptors,
69 int signal_event_pipe_initialized; 73 int signal_event_pipe_initialized;
70 74
71 int fake_event_occurred; 75 int fake_event_occurred;
72 76
73 int 77 int
74 read_event_from_tty_or_stream_desc (Lisp_Event *event, 78 read_event_from_tty_or_stream_desc (struct Lisp_Event *event,
75 struct console *con, int fd) 79 struct console *con, int fd)
76 { 80 {
77 unsigned char ch; 81 unsigned char ch;
78 int nread; 82 int nread;
79 Lisp_Object console; 83 Lisp_Object console;
80 84
81 XSETCONSOLE (console, con); 85 XSETCONSOLE (console, con);
86
87 #ifdef HAVE_GPM
88 if (fd == CONSOLE_TTY_MOUSE_FD (con)) {
89 return handle_gpm_read (event,con,fd);
90 }
91 #endif
82 92
83 nread = read (fd, &ch, 1); 93 nread = read (fd, &ch, 1);
84 if (nread <= 0) 94 if (nread <= 0)
85 { 95 {
86 /* deleting the console might not be safe right now ... */ 96 /* deleting the console might not be safe right now ... */
172 FD_CLR (infd, &tty_only_mask); 182 FD_CLR (infd, &tty_only_mask);
173 return infd; 183 return infd;
174 } 184 }
175 185
176 static int 186 static int
177 get_process_infd (Lisp_Process *p) 187 get_process_infd (struct Lisp_Process *p)
178 { 188 {
179 Lisp_Object instr, outstr; 189 Lisp_Object instr, outstr;
180 get_process_streams (p, &instr, &outstr); 190 get_process_streams (p, &instr, &outstr);
181 assert (!NILP (instr)); 191 assert (!NILP (instr));
182 return filedesc_stream_fd (XLSTREAM (instr)); 192 return filedesc_stream_fd (XLSTREAM (instr));
183 } 193 }
184 194
185 int 195 int
186 event_stream_unixoid_select_process (Lisp_Process *proc) 196 event_stream_unixoid_select_process (struct Lisp_Process *proc)
187 { 197 {
188 int infd = get_process_infd (proc); 198 int infd = get_process_infd (proc);
189 199
190 FD_SET (infd, &input_wait_mask); 200 FD_SET (infd, &input_wait_mask);
191 FD_SET (infd, &non_fake_input_wait_mask); 201 FD_SET (infd, &non_fake_input_wait_mask);
192 FD_SET (infd, &process_only_mask); 202 FD_SET (infd, &process_only_mask);
193 return infd; 203 return infd;
194 } 204 }
195 205
196 int 206 int
197 event_stream_unixoid_unselect_process (Lisp_Process *proc) 207 event_stream_unixoid_unselect_process (struct Lisp_Process *proc)
198 { 208 {
199 int infd = get_process_infd (proc); 209 int infd = get_process_infd (proc);
200 210
201 FD_CLR (infd, &input_wait_mask); 211 FD_CLR (infd, &input_wait_mask);
202 FD_CLR (infd, &non_fake_input_wait_mask); 212 FD_CLR (infd, &non_fake_input_wait_mask);
223 return retval; 233 return retval;
224 if (errno != EINTR) 234 if (errno != EINTR)
225 { 235 {
226 /* Something went seriously wrong; don't abort since maybe 236 /* Something went seriously wrong; don't abort since maybe
227 the TTY just died at the wrong time. */ 237 the TTY just died at the wrong time. */
228 stderr_out ("xemacs: select failed: errno = %d\n", errno); 238 fprintf (stderr, "xemacs: select failed: errno = %d\n", errno);
229 return 0; 239 return 0;
230 } 240 }
231 /* else, we got interrupted by a signal, so try again. */ 241 /* else, we got interrupted by a signal, so try again. */
232 } 242 }
233 243