diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2015-06-23 16:29:27 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2015-06-23 16:30:58 -0700 |
commit | 1552e6737317ea2c85e06600e178114c6b0f9fb2 (patch) | |
tree | 3b68536fbd72bcaa840cc99aff6ea427120fa4bd /src/xterm.h | |
parent | 8769d0fe79dda776652c3bf342263568bbd7623b (diff) | |
download | emacs-1552e6737317ea2c85e06600e178114c6b0f9fb2.tar.gz |
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/xterm.h')
-rw-r--r-- | src/xterm.h | 20 |
1 files changed, 10 insertions, 10 deletions
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 struct selection_input_event { - int kind; + ENUM_BF (event_kind) kind : EVENT_KIND_WIDTH; struct x_display_info *dpyinfo; /* We spell it with an "o" here because X does. */ Window requestor; @@ -970,23 +970,23 @@ struct selection_input_event /* Unlike macros below, this can't be used as an lvalue. */ INLINE Display * -SELECTION_EVENT_DISPLAY (struct input_event *ev) +SELECTION_EVENT_DISPLAY (struct selection_input_event *ev) { - return ((struct selection_input_event *) ev)->dpyinfo->display; + return ev->dpyinfo->display; } #define SELECTION_EVENT_DPYINFO(eventp) \ - (((struct selection_input_event *) (eventp))->dpyinfo) + ((eventp)->dpyinfo) /* We spell it with an "o" here because X does. */ #define SELECTION_EVENT_REQUESTOR(eventp) \ - (((struct selection_input_event *) (eventp))->requestor) + ((eventp)->requestor) #define SELECTION_EVENT_SELECTION(eventp) \ - (((struct selection_input_event *) (eventp))->selection) + ((eventp)->selection) #define SELECTION_EVENT_TARGET(eventp) \ - (((struct selection_input_event *) (eventp))->target) + ((eventp)->target) #define SELECTION_EVENT_PROPERTY(eventp) \ - (((struct selection_input_event *) (eventp))->property) + ((eventp)->property) #define SELECTION_EVENT_TIME(eventp) \ - (((struct selection_input_event *) (eventp))->time) + ((eventp)->time) /* From xfns.c. */ @@ -1079,7 +1079,7 @@ extern void x_clear_under_internal_border (struct frame *f); extern void x_handle_property_notify (const XPropertyEvent *); extern void x_handle_selection_notify (const XSelectionEvent *); -extern void x_handle_selection_event (struct input_event *); +extern void x_handle_selection_event (struct selection_input_event *); extern void x_clear_frame_selections (struct frame *); extern void x_send_client_event (Lisp_Object display, |