aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2000-08-21 18:59:19 +0000
committerGerd Moellmann2000-08-21 18:59:19 +0000
commit0bbfdc25a083f7908e81af3e35f64eb1ea4335a0 (patch)
tree0f3a12594d5b819d504b31f9c31e581e731da18c
parent2ed8e984db93eb6a330d4aac855f15a31610b66b (diff)
downloademacs-0bbfdc25a083f7908e81af3e35f64eb1ea4335a0.tar.gz
emacs-0bbfdc25a083f7908e81af3e35f64eb1ea4335a0.zip
(gen_help_event): Add parameter SIZE.
(kbd_buffer_events_waiting): Slightly rewritten. (clear_event): New function. (kbd_buffer_get_event): Use it, and clear the input_events of HELP_EVENTs. (init_keyboard): Remove duplicate creation of kbd_buffer_gcpro and don't fill the newly created array with nils. (toplevel): Convert some old-style function forward declarations to prototypes.
-rw-r--r--src/ChangeLog16
-rw-r--r--src/keyboard.c117
2 files changed, 90 insertions, 43 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 911179e385f..ca7a2b9295a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,21 @@
12000-08-21 Gerd Moellmann <gerd@gnu.org> 12000-08-21 Gerd Moellmann <gerd@gnu.org>
2 2
3 * keyboard.c (gen_help_event): Add parameter SIZE.
4 (kbd_buffer_events_waiting): Slightly rewritten.
5 (clear_event): New function.
6 (kbd_buffer_get_event): Use it, and clear the input_events of
7 HELP_EVENTs.
8 (init_keyboard): Remove duplicate creation of kbd_buffer_gcpro and
9 don't fill the newly created array with nils.
10 (toplevel): Convert some old-style function forward declarations
11 to prototypes.
12
13 * keyboard.h (gen_help_event): Change prototype.
14
15 * xterm.c (XTread_socket): Change calls to gen_help_event.
16
17 * w32term.c (w32_read_socket): Change calls to gen_help_event.
18
3 * eval.c (Fmacroexpand): Doc fix. 19 * eval.c (Fmacroexpand): Doc fix.
4 20
52000-08-20 Jason Rumney <jasonr@gnu.org> 212000-08-20 Jason Rumney <jasonr@gnu.org>
diff --git a/src/keyboard.c b/src/keyboard.c
index 97687aad09f..0dfae2f76d7 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -636,21 +636,32 @@ Lisp_Object Vglobal_disable_point_adjustment;
636/* Function for init_keyboard to call with no args (if nonzero). */ 636/* Function for init_keyboard to call with no args (if nonzero). */
637void (*keyboard_init_hook) (); 637void (*keyboard_init_hook) ();
638 638
639static int read_avail_input (); 639static int read_avail_input P_ ((int));
640static void get_input_pending (); 640static void get_input_pending P_ ((int *, int));
641static int readable_events (); 641static int readable_events P_ ((int));
642static Lisp_Object read_char_x_menu_prompt P_ ((int, Lisp_Object *,
643 Lisp_Object, int *));
642static Lisp_Object read_char_x_menu_prompt (); 644static Lisp_Object read_char_x_menu_prompt ();
643static Lisp_Object read_char_minibuf_menu_prompt (); 645static Lisp_Object read_char_minibuf_menu_prompt P_ ((int, int,
644static Lisp_Object make_lispy_event (); 646 Lisp_Object *));
647static Lisp_Object make_lispy_event P_ ((struct input_event *));
645#ifdef HAVE_MOUSE 648#ifdef HAVE_MOUSE
646static Lisp_Object make_lispy_movement (); 649static Lisp_Object make_lispy_movement P_ ((struct frame *, Lisp_Object,
650 enum scroll_bar_part,
651 Lisp_Object, Lisp_Object,
652 unsigned long));
647#endif 653#endif
648static Lisp_Object modify_event_symbol (); 654static Lisp_Object modify_event_symbol P_ ((int, unsigned, Lisp_Object,
649static Lisp_Object make_lispy_switch_frame (); 655 Lisp_Object, char **,
656 Lisp_Object *, unsigned));
657static Lisp_Object make_lispy_switch_frame P_ ((Lisp_Object));
658static int parse_solitary_modifier P_ ((Lisp_Object));
650static int parse_solitary_modifier (); 659static int parse_solitary_modifier ();
660static void save_getcjmp P_ ((jmp_buf));
651static void save_getcjmp (); 661static void save_getcjmp ();
652static void restore_getcjmp (); 662static void restore_getcjmp P_ ((jmp_buf));
653static Lisp_Object apply_modifiers P_ ((int, Lisp_Object)); 663static Lisp_Object apply_modifiers P_ ((int, Lisp_Object));
664static void clear_event P_ ((struct input_event *));
654 665
655/* Nonzero means don't try to suspend even if the operating system seems 666/* Nonzero means don't try to suspend even if the operating system seems
656 to support it. */ 667 to support it. */
@@ -3173,7 +3184,9 @@ kbd_buffer_store_event (event)
3173} 3184}
3174 3185
3175 3186
3176/* Generate HELP_EVENT input_events in BUFP. 3187/* Generate HELP_EVENT input_events in BUFP which has roon for
3188 SIZE events. If there's not enough room in BUFP, ignore this
3189 event.
3177 3190
3178 HELP is the help form. 3191 HELP is the help form.
3179 3192
@@ -3185,24 +3198,31 @@ kbd_buffer_store_event (event)
3185 Value is the number of input_events generated. */ 3198 Value is the number of input_events generated. */
3186 3199
3187int 3200int
3188gen_help_event (bufp, help, frame, window, object, pos) 3201gen_help_event (bufp, size, help, frame, window, object, pos)
3189 struct input_event *bufp; 3202 struct input_event *bufp;
3203 int size;
3190 Lisp_Object help, frame, object, window; 3204 Lisp_Object help, frame, object, window;
3191 int pos; 3205 int pos;
3192{ 3206{
3193 bufp->kind = HELP_EVENT; 3207 int nevents_stored = 0;
3194 bufp->frame_or_window = frame; 3208
3195 bufp->arg = object; 3209 if (size >= 2)
3196 bufp->x = make_number (pos); 3210 {
3197 bufp->code = 0; 3211 bufp->kind = HELP_EVENT;
3212 bufp->frame_or_window = frame;
3213 bufp->arg = object;
3214 bufp->x = make_number (pos);
3215 bufp->code = 0;
3198 3216
3199 ++bufp; 3217 ++bufp;
3200 bufp->kind = HELP_EVENT; 3218 bufp->kind = HELP_EVENT;
3201 bufp->frame_or_window = WINDOWP (window) ? window : frame; 3219 bufp->frame_or_window = WINDOWP (window) ? window : frame;
3202 bufp->arg = help; 3220 bufp->arg = help;
3203 bufp->code = 1; 3221 bufp->code = 1;
3222 nevents_stored = 2;
3223 }
3204 3224
3205 return 2; 3225 return nevents_stored;
3206} 3226}
3207 3227
3208 3228
@@ -3252,31 +3272,48 @@ discard_mouse_events ()
3252 } 3272 }
3253} 3273}
3254 3274
3255/* Return non-zero if there are any events waiting in the event buffer 3275
3256 whose .kind is not no_event. If DISCARD is non-zero, discard all 3276/* Return non-zero if there are any real events waiting in the event
3257 no_event placeholders up to the first real event. If there are no 3277 buffer, not counting `no_event's.
3258 real events waiting and DISCARD is non-zero, this function makes 3278
3259 the event buffer empty as side effect. */ 3279 If DISCARD is non-zero, discard no_event events at the front of
3280 the input queue, possibly leaving the input queue empty if there
3281 are no real input events. */
3282
3260int 3283int
3261kbd_buffer_events_waiting (discard) 3284kbd_buffer_events_waiting (discard)
3262 int discard; 3285 int discard;
3263{ 3286{
3264 struct input_event *sp; 3287 struct input_event *sp;
3265 for (sp = kbd_fetch_ptr; sp != kbd_store_ptr; sp++) 3288
3289 for (sp = kbd_fetch_ptr;
3290 sp != kbd_store_ptr && sp->kind == no_event;
3291 ++sp)
3266 { 3292 {
3267 if (sp == kbd_buffer + KBD_BUFFER_SIZE) 3293 if (sp == kbd_buffer + KBD_BUFFER_SIZE)
3268 sp = kbd_buffer; 3294 sp = kbd_buffer;
3269
3270 if (sp->kind != no_event)
3271 return 1;
3272 if (discard)
3273 kbd_fetch_ptr = sp;
3274 } 3295 }
3296
3275 if (discard) 3297 if (discard)
3276 kbd_fetch_ptr = sp; 3298 kbd_fetch_ptr = sp;
3277 return 0; 3299
3300 return sp != kbd_store_ptr && sp->kind != no_event;
3278} 3301}
3302
3279 3303
3304/* Clear input event EVENT. */
3305
3306static INLINE void
3307clear_event (event)
3308 struct input_event *event;
3309{
3310 int idx = 2 * (event - kbd_buffer);
3311 ASET (kbd_buffer_gcpro, idx, Qnil);
3312 ASET (kbd_buffer_gcpro, idx + 1, Qnil);
3313 event->kind = no_event;
3314}
3315
3316
3280/* Read one event from the event buffer, waiting if necessary. 3317/* Read one event from the event buffer, waiting if necessary.
3281 The value is a Lisp object representing the event. 3318 The value is a Lisp object representing the event.
3282 The value is nil for an event that should be ignored, 3319 The value is nil for an event that should be ignored,
@@ -3481,6 +3518,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu)
3481 frame = event->frame_or_window; 3518 frame = event->frame_or_window;
3482 object = event->arg; 3519 object = event->arg;
3483 position = event->x; 3520 position = event->x;
3521 clear_event (event);
3484 3522
3485 kbd_fetch_ptr = event + 1; 3523 kbd_fetch_ptr = event + 1;
3486 event = ((kbd_fetch_ptr < kbd_buffer + KBD_BUFFER_SIZE) 3524 event = ((kbd_fetch_ptr < kbd_buffer + KBD_BUFFER_SIZE)
@@ -3493,6 +3531,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu)
3493 window = Qnil; 3531 window = Qnil;
3494 obj = Fcons (Qhelp_echo, 3532 obj = Fcons (Qhelp_echo,
3495 list5 (frame, help, window, object, position)); 3533 list5 (frame, help, window, object, position));
3534 clear_event (event);
3496 kbd_fetch_ptr = event + 1; 3535 kbd_fetch_ptr = event + 1;
3497 } 3536 }
3498 else if (event->kind == FOCUS_IN_EVENT) 3537 else if (event->kind == FOCUS_IN_EVENT)
@@ -3558,11 +3597,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu)
3558#endif 3597#endif
3559 3598
3560 /* Wipe out this event, to catch bugs. */ 3599 /* Wipe out this event, to catch bugs. */
3561 event->kind = no_event; 3600 clear_event (event);
3562 idx = 2 * (event - kbd_buffer);
3563 ASET (kbd_buffer_gcpro, idx, Qnil);
3564 ASET (kbd_buffer_gcpro, idx + 1, Qnil);
3565
3566 kbd_fetch_ptr = event + 1; 3601 kbd_fetch_ptr = event + 1;
3567 } 3602 }
3568 } 3603 }
@@ -9897,10 +9932,6 @@ init_keyboard ()
9897 wipe_kboard (current_kboard); 9932 wipe_kboard (current_kboard);
9898 init_kboard (current_kboard); 9933 init_kboard (current_kboard);
9899 9934
9900 if (initialized)
9901 Ffillarray (kbd_buffer_gcpro, Qnil);
9902
9903 kbd_buffer_gcpro = Fmake_vector (make_number (2 * KBD_BUFFER_SIZE), Qnil);
9904 if (!noninteractive && !read_socket_hook && NILP (Vwindow_system)) 9935 if (!noninteractive && !read_socket_hook && NILP (Vwindow_system))
9905 { 9936 {
9906 signal (SIGINT, interrupt_signal); 9937 signal (SIGINT, interrupt_signal);