aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2015-06-23 16:29:27 -0700
committerPaul Eggert2015-06-23 16:30:58 -0700
commit1552e6737317ea2c85e06600e178114c6b0f9fb2 (patch)
tree3b68536fbd72bcaa840cc99aff6ea427120fa4bd /src
parent8769d0fe79dda776652c3bf342263568bbd7623b (diff)
downloademacs-1552e6737317ea2c85e06600e178114c6b0f9fb2.tar.gz
emacs-1552e6737317ea2c85e06600e178114c6b0f9fb2.zip
Fix bug that munged selection info
On some optimizing C compilers, copying a structure did not copy the padding bytes between elements, and the type punning between struct input_data and struct selection_input_data did not work. Change the C code to use a proper union type instead. Problem reported by YAMAMOTO Mitsuharu (Bug#20756). * src/keyboard.c (kbd_buffer, kbd_fetch_ptr, kbd_store_ptr) (readable_events, discard_mouse_events, kbd_buffer_events_waiting) (kbd_buffer_get_event, process_special_events, stuff_buffered_input) (mark_kboards): Use union buffered_input_event, not struct input_event. (clear_event, deliver_input_available_signal, process_special_events): Remove unnecessary forward decls. (kbd_buffer_store_buffered_event): New function, mostly just the old kbd_buffer_store_event_hold, except its argument is of type union buffered_input_event, not struct input_event. (kbd_buffer_unget_event): Define only if HAVE_X11, since it's not needed otherwise. Argument is now of type struct selection_input_event *, not struct input_event *. All callers changed. (clear_event): Arg is now of type union buffered_input_event *, not struct input_event *. All callers changed. * src/keyboard.h [HAVE_X11]: Include "xterm.h". (union buffered_input_event): New type. (kbd_buffer_store_event_hold): Now an inline function, defined here. * src/termhooks.h (EVENT_KIND_WIDTH): New constant. (struct input_event): Use it. * src/xselect.c (struct selection_event_queue): Make elements be of type struct selection_input_event, not struct input_event. (selection_input_event_equal): New static function. (x_queue_event): Use it. (x_queue_event, x_decline_selection_request) (x_selection_current_request, x_reply_selection_request) (x_handle_selection_request, x_handle_selection_clear) (x_handle_selection_event): Use struct selection_input_event, not struct input_event. All callers changed. (x_convert_selection): Omit unused first arg. All callers changed. (Fx_disown_selection_internal): Omit unnecessary union. * src/xterm.c (handle_one_xevent): Use new union buffered_input_event rather than rolling our own equivalent. Prefer sie.kind when setting up that kind of structure. Call kbd_buffer_store_buffered_event, not kbd_buffer_store_event_hold. * src/xterm.h (struct selection_input_event: Use EVENT_KIND_WIDTH. (SELECTION_EVENT_DISPLAY, SELECTION_EVENT_DPYINFO) (SELECTION_EVENT_REQUESTOR, SELECTION_EVENT_SELECTION) (SELECTION_EVENT_TARGET, SELECTION_EVENT_PROPERTY) (SELECTION_EVENT_TIME, x_handle_selection_event): Arg is now of type struct selection_input_event *) not struct input_event *. All callers changed.
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c151
-rw-r--r--src/keyboard.h30
-rw-r--r--src/termhooks.h5
-rw-r--r--src/xselect.c54
-rw-r--r--src/xterm.c13
-rw-r--r--src/xterm.h20
6 files changed, 151 insertions, 122 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 7bfc3f35220..8ea7b53a784 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -288,18 +288,18 @@ static bool input_was_pending;
288 288
289/* Circular buffer for pre-read keyboard input. */ 289/* Circular buffer for pre-read keyboard input. */
290 290
291static struct input_event kbd_buffer[KBD_BUFFER_SIZE]; 291static union buffered_input_event kbd_buffer[KBD_BUFFER_SIZE];
292 292
293/* Pointer to next available character in kbd_buffer. 293/* Pointer to next available character in kbd_buffer.
294 If kbd_fetch_ptr == kbd_store_ptr, the buffer is empty. 294 If kbd_fetch_ptr == kbd_store_ptr, the buffer is empty.
295 This may be kbd_buffer + KBD_BUFFER_SIZE, meaning that the 295 This may be kbd_buffer + KBD_BUFFER_SIZE, meaning that the
296 next available char is in kbd_buffer[0]. */ 296 next available char is in kbd_buffer[0]. */
297static struct input_event *kbd_fetch_ptr; 297static union buffered_input_event *kbd_fetch_ptr;
298 298
299/* Pointer to next place to store character in kbd_buffer. This 299/* Pointer to next place to store character in kbd_buffer. This
300 may be kbd_buffer + KBD_BUFFER_SIZE, meaning that the next 300 may be kbd_buffer + KBD_BUFFER_SIZE, meaning that the next
301 character should go in kbd_buffer[0]. */ 301 character should go in kbd_buffer[0]. */
302static struct input_event * volatile kbd_store_ptr; 302static union buffered_input_event *volatile kbd_store_ptr;
303 303
304/* The above pair of variables forms a "queue empty" flag. When we 304/* The above pair of variables forms a "queue empty" flag. When we
305 enqueue a non-hook event, we increment kbd_store_ptr. When we 305 enqueue a non-hook event, we increment kbd_store_ptr. When we
@@ -372,14 +372,9 @@ static bool help_char_p (Lisp_Object);
372static void save_getcjmp (sys_jmp_buf); 372static void save_getcjmp (sys_jmp_buf);
373static void restore_getcjmp (sys_jmp_buf); 373static void restore_getcjmp (sys_jmp_buf);
374static Lisp_Object apply_modifiers (int, Lisp_Object); 374static Lisp_Object apply_modifiers (int, Lisp_Object);
375static void clear_event (struct input_event *);
376static void restore_kboard_configuration (int); 375static void restore_kboard_configuration (int);
377#ifdef USABLE_SIGIO
378static void deliver_input_available_signal (int signo);
379#endif
380static void handle_interrupt (bool); 376static void handle_interrupt (bool);
381static _Noreturn void quit_throw_to_read_char (bool); 377static _Noreturn void quit_throw_to_read_char (bool);
382static void process_special_events (void);
383static void timer_start_idle (void); 378static void timer_start_idle (void);
384static void timer_stop_idle (void); 379static void timer_stop_idle (void);
385static void timer_resume_idle (void); 380static void timer_resume_idle (void);
@@ -3446,7 +3441,7 @@ readable_events (int flags)
3446#endif 3441#endif
3447 )) 3442 ))
3448 { 3443 {
3449 struct input_event *event; 3444 union buffered_input_event *event;
3450 3445
3451 event = ((kbd_fetch_ptr < kbd_buffer + KBD_BUFFER_SIZE) 3446 event = ((kbd_fetch_ptr < kbd_buffer + KBD_BUFFER_SIZE)
3452 ? kbd_fetch_ptr 3447 ? kbd_fetch_ptr
@@ -3463,8 +3458,8 @@ readable_events (int flags)
3463 && !((flags & READABLE_EVENTS_IGNORE_SQUEEZABLES) 3458 && !((flags & READABLE_EVENTS_IGNORE_SQUEEZABLES)
3464 && (event->kind == SCROLL_BAR_CLICK_EVENT 3459 && (event->kind == SCROLL_BAR_CLICK_EVENT
3465 || event->kind == HORIZONTAL_SCROLL_BAR_CLICK_EVENT) 3460 || event->kind == HORIZONTAL_SCROLL_BAR_CLICK_EVENT)
3466 && event->part == scroll_bar_handle 3461 && event->ie.part == scroll_bar_handle
3467 && event->modifiers == 0) 3462 && event->ie.modifiers == 0)
3468#endif 3463#endif
3469 && !((flags & READABLE_EVENTS_FILTER_EVENTS) 3464 && !((flags & READABLE_EVENTS_FILTER_EVENTS)
3470 && event->kind == BUFFER_SWITCH_EVENT)) 3465 && event->kind == BUFFER_SWITCH_EVENT))
@@ -3551,8 +3546,8 @@ kbd_buffer_store_event (register struct input_event *event)
3551 subsequent input events have been parsed (and discarded). */ 3546 subsequent input events have been parsed (and discarded). */
3552 3547
3553void 3548void
3554kbd_buffer_store_event_hold (register struct input_event *event, 3549kbd_buffer_store_buffered_event (union buffered_input_event *event,
3555 struct input_event *hold_quit) 3550 struct input_event *hold_quit)
3556{ 3551{
3557 if (event->kind == NO_EVENT) 3552 if (event->kind == NO_EVENT)
3558 emacs_abort (); 3553 emacs_abort ();
@@ -3562,36 +3557,36 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3562 3557
3563 if (event->kind == ASCII_KEYSTROKE_EVENT) 3558 if (event->kind == ASCII_KEYSTROKE_EVENT)
3564 { 3559 {
3565 register int c = event->code & 0377; 3560 int c = event->ie.code & 0377;
3566 3561
3567 if (event->modifiers & ctrl_modifier) 3562 if (event->ie.modifiers & ctrl_modifier)
3568 c = make_ctrl_char (c); 3563 c = make_ctrl_char (c);
3569 3564
3570 c |= (event->modifiers 3565 c |= (event->ie.modifiers
3571 & (meta_modifier | alt_modifier 3566 & (meta_modifier | alt_modifier
3572 | hyper_modifier | super_modifier)); 3567 | hyper_modifier | super_modifier));
3573 3568
3574 if (c == quit_char) 3569 if (c == quit_char)
3575 { 3570 {
3576 KBOARD *kb = FRAME_KBOARD (XFRAME (event->frame_or_window)); 3571 KBOARD *kb = FRAME_KBOARD (XFRAME (event->ie.frame_or_window));
3577 struct input_event *sp;
3578 3572
3579 if (single_kboard && kb != current_kboard) 3573 if (single_kboard && kb != current_kboard)
3580 { 3574 {
3581 kset_kbd_queue 3575 kset_kbd_queue
3582 (kb, list2 (make_lispy_switch_frame (event->frame_or_window), 3576 (kb, list2 (make_lispy_switch_frame (event->ie.frame_or_window),
3583 make_number (c))); 3577 make_number (c)));
3584 kb->kbd_queue_has_data = 1; 3578 kb->kbd_queue_has_data = 1;
3579 union buffered_input_event *sp;
3585 for (sp = kbd_fetch_ptr; sp != kbd_store_ptr; sp++) 3580 for (sp = kbd_fetch_ptr; sp != kbd_store_ptr; sp++)
3586 { 3581 {
3587 if (sp == kbd_buffer + KBD_BUFFER_SIZE) 3582 if (sp == kbd_buffer + KBD_BUFFER_SIZE)
3588 sp = kbd_buffer; 3583 sp = kbd_buffer;
3589 3584
3590 if (event_to_kboard (sp) == kb) 3585 if (event_to_kboard (&sp->ie) == kb)
3591 { 3586 {
3592 sp->kind = NO_EVENT; 3587 sp->ie.kind = NO_EVENT;
3593 sp->frame_or_window = Qnil; 3588 sp->ie.frame_or_window = Qnil;
3594 sp->arg = Qnil; 3589 sp->ie.arg = Qnil;
3595 } 3590 }
3596 } 3591 }
3597 return; 3592 return;
@@ -3599,7 +3594,7 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3599 3594
3600 if (hold_quit) 3595 if (hold_quit)
3601 { 3596 {
3602 *hold_quit = *event; 3597 *hold_quit = event->ie;
3603 return; 3598 return;
3604 } 3599 }
3605 3600
@@ -3610,9 +3605,9 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3610 { 3605 {
3611 Lisp_Object focus; 3606 Lisp_Object focus;
3612 3607
3613 focus = FRAME_FOCUS_FRAME (XFRAME (event->frame_or_window)); 3608 focus = FRAME_FOCUS_FRAME (XFRAME (event->ie.frame_or_window));
3614 if (NILP (focus)) 3609 if (NILP (focus))
3615 focus = event->frame_or_window; 3610 focus = event->ie.frame_or_window;
3616 internal_last_event_frame = focus; 3611 internal_last_event_frame = focus;
3617 Vlast_event_frame = focus; 3612 Vlast_event_frame = focus;
3618 } 3613 }
@@ -3682,22 +3677,27 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3682} 3677}
3683 3678
3684 3679
3685/* Put an input event back in the head of the event queue. */ 3680#ifdef HAVE_X11
3681
3682/* Put a selection input event back in the head of the event queue. */
3686 3683
3687void 3684void
3688kbd_buffer_unget_event (register struct input_event *event) 3685kbd_buffer_unget_event (struct selection_input_event *event)
3689{ 3686{
3690 if (kbd_fetch_ptr == kbd_buffer) 3687 if (kbd_fetch_ptr == kbd_buffer)
3691 kbd_fetch_ptr = kbd_buffer + KBD_BUFFER_SIZE; 3688 kbd_fetch_ptr = kbd_buffer + KBD_BUFFER_SIZE;
3692 3689
3693 /* Don't let the very last slot in the buffer become full, */ 3690 /* Don't let the very last slot in the buffer become full, */
3694 if (kbd_fetch_ptr - 1 != kbd_store_ptr) 3691 union buffered_input_event *kp = kbd_fetch_ptr - 1;
3692 if (kp != kbd_store_ptr)
3695 { 3693 {
3696 --kbd_fetch_ptr; 3694 kp->sie = *event;
3697 *kbd_fetch_ptr = *event; 3695 kbd_fetch_ptr = kp;
3698 } 3696 }
3699} 3697}
3700 3698
3699#endif
3700
3701/* Limit help event positions to this range, to avoid overflow problems. */ 3701/* Limit help event positions to this range, to avoid overflow problems. */
3702#define INPUT_EVENT_POS_MAX \ 3702#define INPUT_EVENT_POS_MAX \
3703 ((ptrdiff_t) min (PTRDIFF_MAX, min (TYPE_MAXIMUM (Time) / 2, \ 3703 ((ptrdiff_t) min (PTRDIFF_MAX, min (TYPE_MAXIMUM (Time) / 2, \
@@ -3776,7 +3776,7 @@ kbd_buffer_store_help_event (Lisp_Object frame, Lisp_Object help)
3776void 3776void
3777discard_mouse_events (void) 3777discard_mouse_events (void)
3778{ 3778{
3779 struct input_event *sp; 3779 union buffered_input_event *sp;
3780 for (sp = kbd_fetch_ptr; sp != kbd_store_ptr; sp++) 3780 for (sp = kbd_fetch_ptr; sp != kbd_store_ptr; sp++)
3781 { 3781 {
3782 if (sp == kbd_buffer + KBD_BUFFER_SIZE) 3782 if (sp == kbd_buffer + KBD_BUFFER_SIZE)
@@ -3806,7 +3806,7 @@ discard_mouse_events (void)
3806bool 3806bool
3807kbd_buffer_events_waiting (void) 3807kbd_buffer_events_waiting (void)
3808{ 3808{
3809 struct input_event *sp; 3809 union buffered_input_event *sp;
3810 3810
3811 for (sp = kbd_fetch_ptr; 3811 for (sp = kbd_fetch_ptr;
3812 sp != kbd_store_ptr && sp->kind == NO_EVENT; 3812 sp != kbd_store_ptr && sp->kind == NO_EVENT;
@@ -3824,7 +3824,7 @@ kbd_buffer_events_waiting (void)
3824/* Clear input event EVENT. */ 3824/* Clear input event EVENT. */
3825 3825
3826static void 3826static void
3827clear_event (struct input_event *event) 3827clear_event (union buffered_input_event *event)
3828{ 3828{
3829 event->kind = NO_EVENT; 3829 event->kind = NO_EVENT;
3830} 3830}
@@ -3945,13 +3945,13 @@ kbd_buffer_get_event (KBOARD **kbp,
3945 mouse movement enabled and available. */ 3945 mouse movement enabled and available. */
3946 if (kbd_fetch_ptr != kbd_store_ptr) 3946 if (kbd_fetch_ptr != kbd_store_ptr)
3947 { 3947 {
3948 struct input_event *event; 3948 union buffered_input_event *event;
3949 3949
3950 event = ((kbd_fetch_ptr < kbd_buffer + KBD_BUFFER_SIZE) 3950 event = ((kbd_fetch_ptr < kbd_buffer + KBD_BUFFER_SIZE)
3951 ? kbd_fetch_ptr 3951 ? kbd_fetch_ptr
3952 : kbd_buffer); 3952 : kbd_buffer);
3953 3953
3954 *kbp = event_to_kboard (event); 3954 *kbp = event_to_kboard (&event->ie);
3955 if (*kbp == 0) 3955 if (*kbp == 0)
3956 *kbp = current_kboard; /* Better than returning null ptr? */ 3956 *kbp = current_kboard; /* Better than returning null ptr? */
3957 3957
@@ -3964,12 +3964,10 @@ kbd_buffer_get_event (KBOARD **kbp,
3964 || event->kind == SELECTION_CLEAR_EVENT) 3964 || event->kind == SELECTION_CLEAR_EVENT)
3965 { 3965 {
3966#ifdef HAVE_X11 3966#ifdef HAVE_X11
3967 struct input_event copy;
3968
3969 /* Remove it from the buffer before processing it, 3967 /* Remove it from the buffer before processing it,
3970 since otherwise swallow_events will see it 3968 since otherwise swallow_events will see it
3971 and process it again. */ 3969 and process it again. */
3972 copy = *event; 3970 struct selection_input_event copy = event->sie;
3973 kbd_fetch_ptr = event + 1; 3971 kbd_fetch_ptr = event + 1;
3974 input_pending = readable_events (0); 3972 input_pending = readable_events (0);
3975 x_handle_selection_event (&copy); 3973 x_handle_selection_event (&copy);
@@ -3983,7 +3981,7 @@ kbd_buffer_get_event (KBOARD **kbp,
3983#if defined (HAVE_NS) 3981#if defined (HAVE_NS)
3984 else if (event->kind == NS_TEXT_EVENT) 3982 else if (event->kind == NS_TEXT_EVENT)
3985 { 3983 {
3986 if (event->code == KEY_NS_PUT_WORKING_TEXT) 3984 if (event->ie.code == KEY_NS_PUT_WORKING_TEXT)
3987 obj = list1 (intern ("ns-put-working-text")); 3985 obj = list1 (intern ("ns-put-working-text"));
3988 else 3986 else
3989 obj = list1 (intern ("ns-unput-working-text")); 3987 obj = list1 (intern ("ns-unput-working-text"));
@@ -3998,7 +3996,7 @@ kbd_buffer_get_event (KBOARD **kbp,
3998 else if (event->kind == DELETE_WINDOW_EVENT) 3996 else if (event->kind == DELETE_WINDOW_EVENT)
3999 { 3997 {
4000 /* Make an event (delete-frame (FRAME)). */ 3998 /* Make an event (delete-frame (FRAME)). */
4001 obj = list2 (Qdelete_frame, list1 (event->frame_or_window)); 3999 obj = list2 (Qdelete_frame, list1 (event->ie.frame_or_window));
4002 kbd_fetch_ptr = event + 1; 4000 kbd_fetch_ptr = event + 1;
4003 } 4001 }
4004#endif 4002#endif
@@ -4007,13 +4005,13 @@ kbd_buffer_get_event (KBOARD **kbp,
4007 else if (event->kind == ICONIFY_EVENT) 4005 else if (event->kind == ICONIFY_EVENT)
4008 { 4006 {
4009 /* Make an event (iconify-frame (FRAME)). */ 4007 /* Make an event (iconify-frame (FRAME)). */
4010 obj = list2 (Qiconify_frame, list1 (event->frame_or_window)); 4008 obj = list2 (Qiconify_frame, list1 (event->ie.frame_or_window));
4011 kbd_fetch_ptr = event + 1; 4009 kbd_fetch_ptr = event + 1;
4012 } 4010 }
4013 else if (event->kind == DEICONIFY_EVENT) 4011 else if (event->kind == DEICONIFY_EVENT)
4014 { 4012 {
4015 /* Make an event (make-frame-visible (FRAME)). */ 4013 /* Make an event (make-frame-visible (FRAME)). */
4016 obj = list2 (Qmake_frame_visible, list1 (event->frame_or_window)); 4014 obj = list2 (Qmake_frame_visible, list1 (event->ie.frame_or_window));
4017 kbd_fetch_ptr = event + 1; 4015 kbd_fetch_ptr = event + 1;
4018 } 4016 }
4019#endif 4017#endif
@@ -4029,8 +4027,8 @@ kbd_buffer_get_event (KBOARD **kbp,
4029 { 4027 {
4030 kbd_fetch_ptr = event + 1; 4028 kbd_fetch_ptr = event + 1;
4031 input_pending = readable_events (0); 4029 input_pending = readable_events (0);
4032 if (FRAME_LIVE_P (XFRAME (event->frame_or_window))) 4030 if (FRAME_LIVE_P (XFRAME (event->ie.frame_or_window)))
4033 x_activate_menubar (XFRAME (event->frame_or_window)); 4031 x_activate_menubar (XFRAME (event->ie.frame_or_window));
4034 } 4032 }
4035#endif 4033#endif
4036#ifdef HAVE_NTGUI 4034#ifdef HAVE_NTGUI
@@ -4038,9 +4036,9 @@ kbd_buffer_get_event (KBOARD **kbp,
4038 { 4036 {
4039 /* Make an event (language-change FRAME CODEPAGE LANGUAGE-ID). */ 4037 /* Make an event (language-change FRAME CODEPAGE LANGUAGE-ID). */
4040 obj = list4 (Qlanguage_change, 4038 obj = list4 (Qlanguage_change,
4041 event->frame_or_window, 4039 event->ie.frame_or_window,
4042 make_number (event->code), 4040 make_number (event->ie.code),
4043 make_number (event->modifiers)); 4041 make_number (event->ie.modifiers));
4044 kbd_fetch_ptr = event + 1; 4042 kbd_fetch_ptr = event + 1;
4045 } 4043 }
4046#endif 4044#endif
@@ -4049,16 +4047,16 @@ kbd_buffer_get_event (KBOARD **kbp,
4049 { 4047 {
4050#ifdef HAVE_W32NOTIFY 4048#ifdef HAVE_W32NOTIFY
4051 /* Make an event (file-notify (DESCRIPTOR ACTION FILE) CALLBACK). */ 4049 /* Make an event (file-notify (DESCRIPTOR ACTION FILE) CALLBACK). */
4052 obj = list3 (Qfile_notify, event->arg, event->frame_or_window); 4050 obj = list3 (Qfile_notify, event->ie.arg, event->ie.frame_or_window);
4053#else 4051#else
4054 obj = make_lispy_event (event); 4052 obj = make_lispy_event (&event->ie);
4055#endif 4053#endif
4056 kbd_fetch_ptr = event + 1; 4054 kbd_fetch_ptr = event + 1;
4057 } 4055 }
4058#endif /* USE_FILE_NOTIFY */ 4056#endif /* USE_FILE_NOTIFY */
4059 else if (event->kind == SAVE_SESSION_EVENT) 4057 else if (event->kind == SAVE_SESSION_EVENT)
4060 { 4058 {
4061 obj = list2 (Qsave_session, event->arg); 4059 obj = list2 (Qsave_session, event->ie.arg);
4062 kbd_fetch_ptr = event + 1; 4060 kbd_fetch_ptr = event + 1;
4063 } 4061 }
4064 /* Just discard these, by returning nil. 4062 /* Just discard these, by returning nil.
@@ -4075,11 +4073,11 @@ kbd_buffer_get_event (KBOARD **kbp,
4075 { 4073 {
4076 Lisp_Object object, position, help, frame, window; 4074 Lisp_Object object, position, help, frame, window;
4077 4075
4078 frame = event->frame_or_window; 4076 frame = event->ie.frame_or_window;
4079 object = event->arg; 4077 object = event->ie.arg;
4080 position = make_number (Time_to_position (event->timestamp)); 4078 position = make_number (Time_to_position (event->ie.timestamp));
4081 window = event->x; 4079 window = event->ie.x;
4082 help = event->y; 4080 help = event->ie.y;
4083 clear_event (event); 4081 clear_event (event);
4084 4082
4085 kbd_fetch_ptr = event + 1; 4083 kbd_fetch_ptr = event + 1;
@@ -4095,14 +4093,14 @@ kbd_buffer_get_event (KBOARD **kbp,
4095 switch-frame event if necessary. */ 4093 switch-frame event if necessary. */
4096 Lisp_Object frame, focus; 4094 Lisp_Object frame, focus;
4097 4095
4098 frame = event->frame_or_window; 4096 frame = event->ie.frame_or_window;
4099 focus = FRAME_FOCUS_FRAME (XFRAME (frame)); 4097 focus = FRAME_FOCUS_FRAME (XFRAME (frame));
4100 if (FRAMEP (focus)) 4098 if (FRAMEP (focus))
4101 frame = focus; 4099 frame = focus;
4102 4100
4103 if ( 4101 if (
4104#ifdef HAVE_X11 4102#ifdef HAVE_X11
4105 ! NILP (event->arg) 4103 ! NILP (event->ie.arg)
4106 && 4104 &&
4107#endif 4105#endif
4108 !EQ (frame, internal_last_event_frame) 4106 !EQ (frame, internal_last_event_frame)
@@ -4119,7 +4117,7 @@ kbd_buffer_get_event (KBOARD **kbp,
4119#ifdef HAVE_WINDOW_SYSTEM 4117#ifdef HAVE_WINDOW_SYSTEM
4120 4118
4121 Display_Info *di; 4119 Display_Info *di;
4122 Lisp_Object frame = event->frame_or_window; 4120 Lisp_Object frame = event->ie.frame_or_window;
4123 bool focused = false; 4121 bool focused = false;
4124 4122
4125 for (di = x_display_list; di && ! focused; di = di->next) 4123 for (di = x_display_list; di && ! focused; di = di->next)
@@ -4135,13 +4133,13 @@ kbd_buffer_get_event (KBOARD **kbp,
4135#ifdef HAVE_DBUS 4133#ifdef HAVE_DBUS
4136 else if (event->kind == DBUS_EVENT) 4134 else if (event->kind == DBUS_EVENT)
4137 { 4135 {
4138 obj = make_lispy_event (event); 4136 obj = make_lispy_event (&event->ie);
4139 kbd_fetch_ptr = event + 1; 4137 kbd_fetch_ptr = event + 1;
4140 } 4138 }
4141#endif 4139#endif
4142 else if (event->kind == CONFIG_CHANGED_EVENT) 4140 else if (event->kind == CONFIG_CHANGED_EVENT)
4143 { 4141 {
4144 obj = make_lispy_event (event); 4142 obj = make_lispy_event (&event->ie);
4145 kbd_fetch_ptr = event + 1; 4143 kbd_fetch_ptr = event + 1;
4146 } 4144 }
4147 else 4145 else
@@ -4151,7 +4149,7 @@ kbd_buffer_get_event (KBOARD **kbp,
4151 Lisp_Object frame; 4149 Lisp_Object frame;
4152 Lisp_Object focus; 4150 Lisp_Object focus;
4153 4151
4154 frame = event->frame_or_window; 4152 frame = event->ie.frame_or_window;
4155 if (CONSP (frame)) 4153 if (CONSP (frame))
4156 frame = XCAR (frame); 4154 frame = XCAR (frame);
4157 else if (WINDOWP (frame)) 4155 else if (WINDOWP (frame))
@@ -4171,7 +4169,7 @@ kbd_buffer_get_event (KBOARD **kbp,
4171 4169
4172 if (NILP (obj)) 4170 if (NILP (obj))
4173 { 4171 {
4174 obj = make_lispy_event (event); 4172 obj = make_lispy_event (&event->ie);
4175 4173
4176#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \ 4174#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
4177 || defined (HAVE_NS) || defined (USE_GTK) 4175 || defined (HAVE_NS) || defined (USE_GTK)
@@ -4181,7 +4179,7 @@ kbd_buffer_get_event (KBOARD **kbp,
4181 beginning of the menu sequence, and we might as well leave 4179 beginning of the menu sequence, and we might as well leave
4182 that as the `event with parameters' for this selection. */ 4180 that as the `event with parameters' for this selection. */
4183 if (used_mouse_menu 4181 if (used_mouse_menu
4184 && !EQ (event->frame_or_window, event->arg) 4182 && !EQ (event->ie.frame_or_window, event->ie.arg)
4185 && (event->kind == MENU_BAR_EVENT 4183 && (event->kind == MENU_BAR_EVENT
4186 || event->kind == TOOL_BAR_EVENT)) 4184 || event->kind == TOOL_BAR_EVENT))
4187 *used_mouse_menu = 1; 4185 *used_mouse_menu = 1;
@@ -4261,7 +4259,7 @@ kbd_buffer_get_event (KBOARD **kbp,
4261static void 4259static void
4262process_special_events (void) 4260process_special_events (void)
4263{ 4261{
4264 struct input_event *event; 4262 union buffered_input_event *event;
4265 4263
4266 for (event = kbd_fetch_ptr; event != kbd_store_ptr; ++event) 4264 for (event = kbd_fetch_ptr; event != kbd_store_ptr; ++event)
4267 { 4265 {
@@ -4284,23 +4282,22 @@ process_special_events (void)
4284 between kbd_fetch_ptr and EVENT one slot to the right, 4282 between kbd_fetch_ptr and EVENT one slot to the right,
4285 cyclically. */ 4283 cyclically. */
4286 4284
4287 struct input_event copy = *event; 4285 struct selection_input_event copy = event->sie;
4288 struct input_event *beg 4286 union buffered_input_event *beg
4289 = (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE) 4287 = (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE)
4290 ? kbd_buffer : kbd_fetch_ptr; 4288 ? kbd_buffer : kbd_fetch_ptr;
4291 4289
4292 if (event > beg) 4290 if (event > beg)
4293 memmove (beg + 1, beg, (event - beg) * sizeof (struct input_event)); 4291 memmove (beg + 1, beg, (event - beg) * sizeof *beg);
4294 else if (event < beg) 4292 else if (event < beg)
4295 { 4293 {
4296 if (event > kbd_buffer) 4294 if (event > kbd_buffer)
4297 memmove (kbd_buffer + 1, kbd_buffer, 4295 memmove (kbd_buffer + 1, kbd_buffer,
4298 (event - kbd_buffer) * sizeof (struct input_event)); 4296 (event - kbd_buffer) * sizeof *kbd_buffer);
4299 *kbd_buffer = *(kbd_buffer + KBD_BUFFER_SIZE - 1); 4297 *kbd_buffer = *(kbd_buffer + KBD_BUFFER_SIZE - 1);
4300 if (beg < kbd_buffer + KBD_BUFFER_SIZE - 1) 4298 if (beg < kbd_buffer + KBD_BUFFER_SIZE - 1)
4301 memmove (beg + 1, beg, 4299 memmove (beg + 1, beg,
4302 (kbd_buffer + KBD_BUFFER_SIZE - 1 - beg) 4300 (kbd_buffer + KBD_BUFFER_SIZE - 1 - beg) * sizeof *beg);
4303 * sizeof (struct input_event));
4304 } 4301 }
4305 4302
4306 if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE) 4303 if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE)
@@ -10311,7 +10308,7 @@ stuff_buffered_input (Lisp_Object stuffstring)
10311 if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE) 10308 if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE)
10312 kbd_fetch_ptr = kbd_buffer; 10309 kbd_fetch_ptr = kbd_buffer;
10313 if (kbd_fetch_ptr->kind == ASCII_KEYSTROKE_EVENT) 10310 if (kbd_fetch_ptr->kind == ASCII_KEYSTROKE_EVENT)
10314 stuff_char (kbd_fetch_ptr->code); 10311 stuff_char (kbd_fetch_ptr->ie.code);
10315 10312
10316 clear_event (kbd_fetch_ptr); 10313 clear_event (kbd_fetch_ptr);
10317 } 10314 }
@@ -11937,7 +11934,7 @@ mark_kboards (void)
11937 mark_object (KVAR (kb, echo_string)); 11934 mark_object (KVAR (kb, echo_string));
11938 } 11935 }
11939 { 11936 {
11940 struct input_event *event; 11937 union buffered_input_event *event;
11941 for (event = kbd_fetch_ptr; event != kbd_store_ptr; event++) 11938 for (event = kbd_fetch_ptr; event != kbd_store_ptr; event++)
11942 { 11939 {
11943 if (event == kbd_buffer + KBD_BUFFER_SIZE) 11940 if (event == kbd_buffer + KBD_BUFFER_SIZE)
@@ -11946,10 +11943,10 @@ mark_kboards (void)
11946 if (event->kind != SELECTION_REQUEST_EVENT 11943 if (event->kind != SELECTION_REQUEST_EVENT
11947 && event->kind != SELECTION_CLEAR_EVENT) 11944 && event->kind != SELECTION_CLEAR_EVENT)
11948 { 11945 {
11949 mark_object (event->x); 11946 mark_object (event->ie.x);
11950 mark_object (event->y); 11947 mark_object (event->ie.y);
11951 mark_object (event->frame_or_window); 11948 mark_object (event->ie.frame_or_window);
11952 mark_object (event->arg); 11949 mark_object (event->ie.arg);
11953 } 11950 }
11954 } 11951 }
11955 } 11952 }
diff --git a/src/keyboard.h b/src/keyboard.h
index bcdeaf62165..52780516340 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -21,6 +21,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21#include "coding.h" /* for ENCODE_UTF_8 and ENCODE_SYSTEM */ 21#include "coding.h" /* for ENCODE_UTF_8 and ENCODE_SYSTEM */
22#include "termhooks.h" 22#include "termhooks.h"
23 23
24#ifdef HAVE_X11
25# include "xterm.h" /* for struct selection_input_event */
26#endif
27
24INLINE_HEADER_BEGIN 28INLINE_HEADER_BEGIN
25 29
26/* Most code should use this macro to access Lisp fields in struct kboard. */ 30/* Most code should use this macro to access Lisp fields in struct kboard. */
@@ -217,6 +221,15 @@ kset_window_system (struct kboard *kb, Lisp_Object val)
217 kb->Vwindow_system_ = val; 221 kb->Vwindow_system_ = val;
218} 222}
219 223
224union buffered_input_event
225{
226 ENUM_BF (event_kind) kind : EVENT_KIND_WIDTH;
227 struct input_event ie;
228#ifdef HAVE_X11
229 struct selection_input_event sie;
230#endif
231};
232
220/* Temporarily used before a frame has been opened. */ 233/* Temporarily used before a frame has been opened. */
221extern KBOARD *initial_kboard; 234extern KBOARD *initial_kboard;
222 235
@@ -438,9 +451,20 @@ extern void clear_waiting_for_input (void);
438extern void swallow_events (bool); 451extern void swallow_events (bool);
439extern bool lucid_event_type_list_p (Lisp_Object); 452extern bool lucid_event_type_list_p (Lisp_Object);
440extern void kbd_buffer_store_event (struct input_event *); 453extern void kbd_buffer_store_event (struct input_event *);
441extern void kbd_buffer_store_event_hold (struct input_event *, 454extern void kbd_buffer_store_buffered_event (union buffered_input_event *,
442 struct input_event *); 455 struct input_event *);
443extern void kbd_buffer_unget_event (struct input_event *); 456INLINE void
457kbd_buffer_store_event_hold (struct input_event *event,
458 struct input_event *hold_quit)
459{
460 union buffered_input_event *ev = (union buffered_input_event *) event;
461 verify (sizeof *event == sizeof *ev && alignof (*event) == alignof (*ev));
462 return kbd_buffer_store_buffered_event ((union buffered_input_event *) event,
463 hold_quit);
464}
465#ifdef HAVE_X11
466extern void kbd_buffer_unget_event (struct selection_input_event *);
467#endif
444extern void poll_for_input_1 (void); 468extern void poll_for_input_1 (void);
445extern void show_help_echo (Lisp_Object, Lisp_Object, Lisp_Object, 469extern void show_help_echo (Lisp_Object, Lisp_Object, Lisp_Object,
446 Lisp_Object); 470 Lisp_Object);
diff --git a/src/termhooks.h b/src/termhooks.h
index 3cafc437e59..168bc3510fa 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -243,6 +243,9 @@ enum event_kind
243 243
244}; 244};
245 245
246/* Bit width of an enum event_kind tag at the start of structs and unions. */
247enum { EVENT_KIND_WIDTH = 16 };
248
246/* If a struct input_event has a kind which is SELECTION_REQUEST_EVENT 249/* If a struct input_event has a kind which is SELECTION_REQUEST_EVENT
247 or SELECTION_CLEAR_EVENT, then its contents are really described 250 or SELECTION_CLEAR_EVENT, then its contents are really described
248 by `struct selection_input_event'; see xterm.h. */ 251 by `struct selection_input_event'; see xterm.h. */
@@ -255,7 +258,7 @@ enum event_kind
255struct input_event 258struct input_event
256{ 259{
257 /* What kind of event was this? */ 260 /* What kind of event was this? */
258 ENUM_BF (event_kind) kind : 16; 261 ENUM_BF (event_kind) kind : EVENT_KIND_WIDTH;
259 262
260 /* Used in scroll back click events. */ 263 /* Used in scroll back click events. */
261 ENUM_BF (scroll_bar_part) part : 16; 264 ENUM_BF (scroll_bar_part) part : 16;
diff --git a/src/xselect.c b/src/xselect.c
index 19ace065698..bd2d65e795f 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -45,9 +45,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
45struct prop_location; 45struct prop_location;
46struct selection_data; 46struct selection_data;
47 47
48static void x_decline_selection_request (struct input_event *); 48static void x_decline_selection_request (struct selection_input_event *);
49static bool x_convert_selection (struct input_event *, Lisp_Object, 49static bool x_convert_selection (Lisp_Object, Lisp_Object, Atom, bool,
50 Lisp_Object, Atom, bool,
51 struct x_display_info *); 50 struct x_display_info *);
52static bool waiting_for_other_props_on_window (Display *, Window); 51static bool waiting_for_other_props_on_window (Display *, Window);
53static struct prop_location *expect_property_change (Display *, Window, 52static struct prop_location *expect_property_change (Display *, Window,
@@ -117,7 +116,7 @@ selection_quantum (Display *display)
117 116
118struct selection_event_queue 117struct selection_event_queue
119 { 118 {
120 struct input_event event; 119 struct selection_input_event event;
121 struct selection_event_queue *next; 120 struct selection_event_queue *next;
122 }; 121 };
123 122
@@ -127,10 +126,22 @@ static struct selection_event_queue *selection_queue;
127 126
128static int x_queue_selection_requests; 127static int x_queue_selection_requests;
129 128
129/* True if the input events are duplicates. */
130
131static bool
132selection_input_event_equal (struct selection_input_event *a,
133 struct selection_input_event *b)
134{
135 return (a->kind == b->kind && a->dpyinfo == b->dpyinfo
136 && a->requestor == b->requestor && a->selection == b->selection
137 && a->target == b->target && a->property == b->property
138 && a->time == b->time);
139}
140
130/* Queue up an SELECTION_REQUEST_EVENT *EVENT, to be processed later. */ 141/* Queue up an SELECTION_REQUEST_EVENT *EVENT, to be processed later. */
131 142
132static void 143static void
133x_queue_event (struct input_event *event) 144x_queue_event (struct selection_input_event *event)
134{ 145{
135 struct selection_event_queue *queue_tmp; 146 struct selection_event_queue *queue_tmp;
136 147
@@ -138,7 +149,7 @@ x_queue_event (struct input_event *event)
138 This only happens for large requests which uses the incremental protocol. */ 149 This only happens for large requests which uses the incremental protocol. */
139 for (queue_tmp = selection_queue; queue_tmp; queue_tmp = queue_tmp->next) 150 for (queue_tmp = selection_queue; queue_tmp; queue_tmp = queue_tmp->next)
140 { 151 {
141 if (!memcmp (&queue_tmp->event, event, sizeof (*event))) 152 if (selection_input_event_equal (event, &queue_tmp->event))
142 { 153 {
143 TRACE1 ("DECLINE DUP SELECTION EVENT %p", queue_tmp); 154 TRACE1 ("DECLINE DUP SELECTION EVENT %p", queue_tmp);
144 x_decline_selection_request (event); 155 x_decline_selection_request (event);
@@ -419,7 +430,7 @@ x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type,
419 meaning we were unable to do what they wanted. */ 430 meaning we were unable to do what they wanted. */
420 431
421static void 432static void
422x_decline_selection_request (struct input_event *event) 433x_decline_selection_request (struct selection_input_event *event)
423{ 434{
424 XEvent reply_base; 435 XEvent reply_base;
425 XSelectionEvent *reply = &(reply_base.xselection); 436 XSelectionEvent *reply = &(reply_base.xselection);
@@ -444,7 +455,7 @@ x_decline_selection_request (struct input_event *event)
444 455
445/* This is the selection request currently being processed. 456/* This is the selection request currently being processed.
446 It is set to zero when the request is fully processed. */ 457 It is set to zero when the request is fully processed. */
447static struct input_event *x_selection_current_request; 458static struct selection_input_event *x_selection_current_request;
448 459
449/* Display info in x_selection_request. */ 460/* Display info in x_selection_request. */
450 461
@@ -549,7 +560,7 @@ static int x_reply_selection_request_cnt;
549#endif /* TRACE_SELECTION */ 560#endif /* TRACE_SELECTION */
550 561
551static void 562static void
552x_reply_selection_request (struct input_event *event, 563x_reply_selection_request (struct selection_input_event *event,
553 struct x_display_info *dpyinfo) 564 struct x_display_info *dpyinfo)
554{ 565{
555 XEvent reply_base; 566 XEvent reply_base;
@@ -740,7 +751,7 @@ x_reply_selection_request (struct input_event *event,
740 This is called from keyboard.c when such an event is found in the queue. */ 751 This is called from keyboard.c when such an event is found in the queue. */
741 752
742static void 753static void
743x_handle_selection_request (struct input_event *event) 754x_handle_selection_request (struct selection_input_event *event)
744{ 755{
745 struct gcpro gcpro1, gcpro2; 756 struct gcpro gcpro1, gcpro2;
746 Time local_selection_time; 757 Time local_selection_time;
@@ -809,7 +820,7 @@ x_handle_selection_request (struct input_event *event)
809 AREF (multprop, 2*j+1)); 820 AREF (multprop, 2*j+1));
810 821
811 if (subproperty != None) 822 if (subproperty != None)
812 x_convert_selection (event, selection_symbol, subtarget, 823 x_convert_selection (selection_symbol, subtarget,
813 subproperty, true, dpyinfo); 824 subproperty, true, dpyinfo);
814 } 825 }
815 success = true; 826 success = true;
@@ -818,7 +829,7 @@ x_handle_selection_request (struct input_event *event)
818 { 829 {
819 if (property == None) 830 if (property == None)
820 property = SELECTION_EVENT_TARGET (event); 831 property = SELECTION_EVENT_TARGET (event);
821 success = x_convert_selection (event, selection_symbol, 832 success = x_convert_selection (selection_symbol,
822 target_symbol, property, 833 target_symbol, property,
823 false, dpyinfo); 834 false, dpyinfo);
824 } 835 }
@@ -849,7 +860,7 @@ x_handle_selection_request (struct input_event *event)
849 Return true iff successful. */ 860 Return true iff successful. */
850 861
851static bool 862static bool
852x_convert_selection (struct input_event *event, Lisp_Object selection_symbol, 863x_convert_selection (Lisp_Object selection_symbol,
853 Lisp_Object target_symbol, Atom property, 864 Lisp_Object target_symbol, Atom property,
854 bool for_multiple, struct x_display_info *dpyinfo) 865 bool for_multiple, struct x_display_info *dpyinfo)
855{ 866{
@@ -902,7 +913,7 @@ x_convert_selection (struct input_event *event, Lisp_Object selection_symbol,
902 This is called from keyboard.c when such an event is found in the queue. */ 913 This is called from keyboard.c when such an event is found in the queue. */
903 914
904static void 915static void
905x_handle_selection_clear (struct input_event *event) 916x_handle_selection_clear (struct selection_input_event *event)
906{ 917{
907 Atom selection = SELECTION_EVENT_SELECTION (event); 918 Atom selection = SELECTION_EVENT_SELECTION (event);
908 Time changed_owner_time = SELECTION_EVENT_TIME (event); 919 Time changed_owner_time = SELECTION_EVENT_TIME (event);
@@ -954,7 +965,7 @@ x_handle_selection_clear (struct input_event *event)
954} 965}
955 966
956void 967void
957x_handle_selection_event (struct input_event *event) 968x_handle_selection_event (struct selection_input_event *event)
958{ 969{
959 TRACE0 ("x_handle_selection_event"); 970 TRACE0 ("x_handle_selection_event");
960 if (event->kind != SELECTION_REQUEST_EVENT) 971 if (event->kind != SELECTION_REQUEST_EVENT)
@@ -2006,10 +2017,7 @@ On MS-DOS, all this does is return non-nil if we own the selection. */)
2006{ 2017{
2007 Time timestamp; 2018 Time timestamp;
2008 Atom selection_atom; 2019 Atom selection_atom;
2009 union { 2020 struct selection_input_event event;
2010 struct selection_input_event sie;
2011 struct input_event ie;
2012 } event;
2013 struct frame *f = frame_for_x_selection (terminal); 2021 struct frame *f = frame_for_x_selection (terminal);
2014 struct x_display_info *dpyinfo; 2022 struct x_display_info *dpyinfo;
2015 2023
@@ -2038,10 +2046,10 @@ On MS-DOS, all this does is return non-nil if we own the selection. */)
2038 the selection owner to None. The NCD server does, the MIT Sun4 server 2046 the selection owner to None. The NCD server does, the MIT Sun4 server
2039 doesn't. So we synthesize one; this means we might get two, but 2047 doesn't. So we synthesize one; this means we might get two, but
2040 that's ok, because the second one won't have any effect. */ 2048 that's ok, because the second one won't have any effect. */
2041 SELECTION_EVENT_DPYINFO (&event.sie) = dpyinfo; 2049 SELECTION_EVENT_DPYINFO (&event) = dpyinfo;
2042 SELECTION_EVENT_SELECTION (&event.sie) = selection_atom; 2050 SELECTION_EVENT_SELECTION (&event) = selection_atom;
2043 SELECTION_EVENT_TIME (&event.sie) = timestamp; 2051 SELECTION_EVENT_TIME (&event) = timestamp;
2044 x_handle_selection_clear (&event.ie); 2052 x_handle_selection_clear (&event);
2045 2053
2046 return Qt; 2054 return Qt;
2047} 2055}
diff --git a/src/xterm.c b/src/xterm.c
index 4d7945059fe..d573738754a 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -7358,10 +7358,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
7358 const XEvent *event, 7358 const XEvent *event,
7359 int *finish, struct input_event *hold_quit) 7359 int *finish, struct input_event *hold_quit)
7360{ 7360{
7361 union { 7361 union buffered_input_event inev;
7362 struct input_event ie;
7363 struct selection_input_event sie;
7364 } inev;
7365 int count = 0; 7362 int count = 0;
7366 int do_help = 0; 7363 int do_help = 0;
7367 ptrdiff_t nbytes = 0; 7364 ptrdiff_t nbytes = 0;
@@ -7589,7 +7586,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
7589 { 7586 {
7590 const XSelectionClearEvent *eventp = &event->xselectionclear; 7587 const XSelectionClearEvent *eventp = &event->xselectionclear;
7591 7588
7592 inev.ie.kind = SELECTION_CLEAR_EVENT; 7589 inev.sie.kind = SELECTION_CLEAR_EVENT;
7593 SELECTION_EVENT_DPYINFO (&inev.sie) = dpyinfo; 7590 SELECTION_EVENT_DPYINFO (&inev.sie) = dpyinfo;
7594 SELECTION_EVENT_SELECTION (&inev.sie) = eventp->selection; 7591 SELECTION_EVENT_SELECTION (&inev.sie) = eventp->selection;
7595 SELECTION_EVENT_TIME (&inev.sie) = eventp->time; 7592 SELECTION_EVENT_TIME (&inev.sie) = eventp->time;
@@ -7605,7 +7602,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
7605 { 7602 {
7606 const XSelectionRequestEvent *eventp = &event->xselectionrequest; 7603 const XSelectionRequestEvent *eventp = &event->xselectionrequest;
7607 7604
7608 inev.ie.kind = SELECTION_REQUEST_EVENT; 7605 inev.sie.kind = SELECTION_REQUEST_EVENT;
7609 SELECTION_EVENT_DPYINFO (&inev.sie) = dpyinfo; 7606 SELECTION_EVENT_DPYINFO (&inev.sie) = dpyinfo;
7610 SELECTION_EVENT_REQUESTOR (&inev.sie) = eventp->requestor; 7607 SELECTION_EVENT_REQUESTOR (&inev.sie) = eventp->requestor;
7611 SELECTION_EVENT_SELECTION (&inev.sie) = eventp->selection; 7608 SELECTION_EVENT_SELECTION (&inev.sie) = eventp->selection;
@@ -8116,7 +8113,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
8116 ? ASCII_KEYSTROKE_EVENT 8113 ? ASCII_KEYSTROKE_EVENT
8117 : MULTIBYTE_CHAR_KEYSTROKE_EVENT); 8114 : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
8118 inev.ie.code = ch; 8115 inev.ie.code = ch;
8119 kbd_buffer_store_event_hold (&inev.ie, hold_quit); 8116 kbd_buffer_store_buffered_event (&inev, hold_quit);
8120 } 8117 }
8121 8118
8122 count += nchars; 8119 count += nchars;
@@ -8533,7 +8530,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
8533 done: 8530 done:
8534 if (inev.ie.kind != NO_EVENT) 8531 if (inev.ie.kind != NO_EVENT)
8535 { 8532 {
8536 kbd_buffer_store_event_hold (&inev.ie, hold_quit); 8533 kbd_buffer_store_buffered_event (&inev, hold_quit);
8537 count++; 8534 count++;
8538 } 8535 }
8539 8536
diff --git a/src/xterm.h b/src/xterm.h
index 3081c1653e3..5622344d97c 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -960,7 +960,7 @@ struct scroll_bar
960 960
961struct selection_input_event 961struct selection_input_event
962{ 962{
963 int kind; 963 ENUM_BF (event_kind) kind : EVENT_KIND_WIDTH;
964 struct x_display_info *dpyinfo; 964 struct x_display_info *dpyinfo;
965 /* We spell it with an "o" here because X does. */ 965 /* We spell it with an "o" here because X does. */
966 Window requestor; 966 Window requestor;
@@ -970,23 +970,23 @@ struct selection_input_event
970 970
971/* Unlike macros below, this can't be used as an lvalue. */ 971/* Unlike macros below, this can't be used as an lvalue. */
972INLINE Display * 972INLINE Display *
973SELECTION_EVENT_DISPLAY (struct input_event *ev) 973SELECTION_EVENT_DISPLAY (struct selection_input_event *ev)
974{ 974{
975 return ((struct selection_input_event *) ev)->dpyinfo->display; 975 return ev->dpyinfo->display;
976} 976}
977#define SELECTION_EVENT_DPYINFO(eventp) \ 977#define SELECTION_EVENT_DPYINFO(eventp) \
978 (((struct selection_input_event *) (eventp))->dpyinfo) 978 ((eventp)->dpyinfo)
979/* We spell it with an "o" here because X does. */ 979/* We spell it with an "o" here because X does. */
980#define SELECTION_EVENT_REQUESTOR(eventp) \ 980#define SELECTION_EVENT_REQUESTOR(eventp) \
981 (((struct selection_input_event *) (eventp))->requestor) 981 ((eventp)->requestor)
982#define SELECTION_EVENT_SELECTION(eventp) \ 982#define SELECTION_EVENT_SELECTION(eventp) \
983 (((struct selection_input_event *) (eventp))->selection) 983 ((eventp)->selection)
984#define SELECTION_EVENT_TARGET(eventp) \ 984#define SELECTION_EVENT_TARGET(eventp) \
985 (((struct selection_input_event *) (eventp))->target) 985 ((eventp)->target)
986#define SELECTION_EVENT_PROPERTY(eventp) \ 986#define SELECTION_EVENT_PROPERTY(eventp) \
987 (((struct selection_input_event *) (eventp))->property) 987 ((eventp)->property)
988#define SELECTION_EVENT_TIME(eventp) \ 988#define SELECTION_EVENT_TIME(eventp) \
989 (((struct selection_input_event *) (eventp))->time) 989 ((eventp)->time)
990 990
991/* From xfns.c. */ 991/* From xfns.c. */
992 992
@@ -1079,7 +1079,7 @@ extern void x_clear_under_internal_border (struct frame *f);
1079 1079
1080extern void x_handle_property_notify (const XPropertyEvent *); 1080extern void x_handle_property_notify (const XPropertyEvent *);
1081extern void x_handle_selection_notify (const XSelectionEvent *); 1081extern void x_handle_selection_notify (const XSelectionEvent *);
1082extern void x_handle_selection_event (struct input_event *); 1082extern void x_handle_selection_event (struct selection_input_event *);
1083extern void x_clear_frame_selections (struct frame *); 1083extern void x_clear_frame_selections (struct frame *);
1084 1084
1085extern void x_send_client_event (Lisp_Object display, 1085extern void x_send_client_event (Lisp_Object display,