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/keyboard.h | |
parent | 8769d0fe79dda776652c3bf342263568bbd7623b (diff) | |
download | emacs-1552e6737317ea2c85e06600e178114c6b0f9fb2.tar.gz emacs-1552e6737317ea2c85e06600e178114c6b0f9fb2.tar.bz2 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/keyboard.h')
-rw-r--r-- | src/keyboard.h | 30 |
1 files changed, 27 insertions, 3 deletions
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/>. */ #include "coding.h" /* for ENCODE_UTF_8 and ENCODE_SYSTEM */ #include "termhooks.h" +#ifdef HAVE_X11 +# include "xterm.h" /* for struct selection_input_event */ +#endif + INLINE_HEADER_BEGIN /* 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) kb->Vwindow_system_ = val; } +union buffered_input_event +{ + ENUM_BF (event_kind) kind : EVENT_KIND_WIDTH; + struct input_event ie; +#ifdef HAVE_X11 + struct selection_input_event sie; +#endif +}; + /* Temporarily used before a frame has been opened. */ extern KBOARD *initial_kboard; @@ -438,9 +451,20 @@ extern void clear_waiting_for_input (void); extern void swallow_events (bool); extern bool lucid_event_type_list_p (Lisp_Object); extern void kbd_buffer_store_event (struct input_event *); -extern void kbd_buffer_store_event_hold (struct input_event *, - struct input_event *); -extern void kbd_buffer_unget_event (struct input_event *); +extern void kbd_buffer_store_buffered_event (union buffered_input_event *, + struct input_event *); +INLINE void +kbd_buffer_store_event_hold (struct input_event *event, + struct input_event *hold_quit) +{ + union buffered_input_event *ev = (union buffered_input_event *) event; + verify (sizeof *event == sizeof *ev && alignof (*event) == alignof (*ev)); + return kbd_buffer_store_buffered_event ((union buffered_input_event *) event, + hold_quit); +} +#ifdef HAVE_X11 +extern void kbd_buffer_unget_event (struct selection_input_event *); +#endif extern void poll_for_input_1 (void); extern void show_help_echo (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); |