aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Schwab2005-02-17 12:52:35 +0000
committerAndreas Schwab2005-02-17 12:52:35 +0000
commit9b516537a9899900647d4eae5ec8778e6837ad3c (patch)
tree1b6799962af92894495948a9e7cd30890357f108 /src
parent31df61d66239245c68d85d1bb485539034782bec (diff)
downloademacs-9b516537a9899900647d4eae5ec8778e6837ad3c.tar.gz
emacs-9b516537a9899900647d4eae5ec8778e6837ad3c.zip
(handle_one_xevent): Use union of struct input_event and
struct selection_input_event to avoid aliasing issues. (SET_SAVED_MENU_EVENT): Adapt reference to inev.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog14
-rw-r--r--src/xterm.c111
2 files changed, 71 insertions, 54 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f12903d605e..400946fb4d0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,17 @@
12005-02-17 Andreas Schwab <schwab@suse.de>
2
3 * xfns.c (hack_wm_protocols): Use correct type for last parameter
4 of XGetWindowProperty to avoid aliasing issues.
5 (Fx_window_property): Likewise.
6
7 * xselect.c (Fx_disown_selection_internal): Use union of struct
8 input_event and struct selection_input_event to avoid aliasing
9 issues.
10
11 * xterm.c (handle_one_xevent): Use union of struct input_event and
12 struct selection_input_event to avoid aliasing issues.
13 (SET_SAVED_MENU_EVENT): Adapt reference to inev.
14
12005-02-17 Kim F. Storm <storm@cua.dk> 152005-02-17 Kim F. Storm <storm@cua.dk>
2 16
3 * dispextern.h (enum it_method): New enum. 17 * dispextern.h (enum it_method): New enum.
diff --git a/src/xterm.c b/src/xterm.c
index f047c255c69..609ffefcbbe 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -5619,8 +5619,8 @@ static struct x_display_info *next_noop_dpyinfo;
5619 f->output_data.x->saved_menu_event \ 5619 f->output_data.x->saved_menu_event \
5620 = (XEvent *) xmalloc (sizeof (XEvent)); \ 5620 = (XEvent *) xmalloc (sizeof (XEvent)); \
5621 bcopy (&event, f->output_data.x->saved_menu_event, size); \ 5621 bcopy (&event, f->output_data.x->saved_menu_event, size); \
5622 inev.kind = MENU_BAR_ACTIVATE_EVENT; \ 5622 inev.ie.kind = MENU_BAR_ACTIVATE_EVENT; \
5623 XSETFRAME (inev.frame_or_window, f); \ 5623 XSETFRAME (inev.ie.frame_or_window, f); \
5624 } \ 5624 } \
5625 while (0) 5625 while (0)
5626 5626
@@ -5727,7 +5727,10 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5727 int *finish; 5727 int *finish;
5728 struct input_event *hold_quit; 5728 struct input_event *hold_quit;
5729{ 5729{
5730 struct input_event inev; 5730 union {
5731 struct input_event ie;
5732 struct selection_input_event sie;
5733 } inev;
5731 int count = 0; 5734 int count = 0;
5732 int do_help = 0; 5735 int do_help = 0;
5733 int nbytes = 0; 5736 int nbytes = 0;
@@ -5737,9 +5740,9 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5737 5740
5738 *finish = X_EVENT_NORMAL; 5741 *finish = X_EVENT_NORMAL;
5739 5742
5740 EVENT_INIT (inev); 5743 EVENT_INIT (inev.ie);
5741 inev.kind = NO_EVENT; 5744 inev.ie.kind = NO_EVENT;
5742 inev.arg = Qnil; 5745 inev.ie.arg = Qnil;
5743 5746
5744 switch (event.type) 5747 switch (event.type)
5745 { 5748 {
@@ -5837,8 +5840,8 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5837 if (!f) 5840 if (!f)
5838 goto OTHER; /* May be a dialog that is to be removed */ 5841 goto OTHER; /* May be a dialog that is to be removed */
5839 5842
5840 inev.kind = DELETE_WINDOW_EVENT; 5843 inev.ie.kind = DELETE_WINDOW_EVENT;
5841 XSETFRAME (inev.frame_or_window, f); 5844 XSETFRAME (inev.ie.frame_or_window, f);
5842 goto done; 5845 goto done;
5843 } 5846 }
5844 5847
@@ -5901,7 +5904,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5901 if (event.xclient.message_type 5904 if (event.xclient.message_type
5902 == dpyinfo->Xatom_Scrollbar) 5905 == dpyinfo->Xatom_Scrollbar)
5903 { 5906 {
5904 x_scroll_bar_to_input_event (&event, &inev); 5907 x_scroll_bar_to_input_event (&event, &inev.ie);
5905 *finish = X_EVENT_GOTO_OUT; 5908 *finish = X_EVENT_GOTO_OUT;
5906 goto done; 5909 goto done;
5907 } 5910 }
@@ -5912,7 +5915,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5912 if (!f) 5915 if (!f)
5913 goto OTHER; 5916 goto OTHER;
5914 5917
5915 if (x_handle_dnd_message (f, &event.xclient, dpyinfo, &inev)) 5918 if (x_handle_dnd_message (f, &event.xclient, dpyinfo, &inev.ie))
5916 *finish = X_EVENT_DROP; 5919 *finish = X_EVENT_DROP;
5917 } 5920 }
5918 break; 5921 break;
@@ -5933,11 +5936,11 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5933 { 5936 {
5934 XSelectionClearEvent *eventp = (XSelectionClearEvent *) &event; 5937 XSelectionClearEvent *eventp = (XSelectionClearEvent *) &event;
5935 5938
5936 inev.kind = SELECTION_CLEAR_EVENT; 5939 inev.ie.kind = SELECTION_CLEAR_EVENT;
5937 SELECTION_EVENT_DISPLAY (&inev) = eventp->display; 5940 SELECTION_EVENT_DISPLAY (&inev.sie) = eventp->display;
5938 SELECTION_EVENT_SELECTION (&inev) = eventp->selection; 5941 SELECTION_EVENT_SELECTION (&inev.sie) = eventp->selection;
5939 SELECTION_EVENT_TIME (&inev) = eventp->time; 5942 SELECTION_EVENT_TIME (&inev.sie) = eventp->time;
5940 inev.frame_or_window = Qnil; 5943 inev.ie.frame_or_window = Qnil;
5941 } 5944 }
5942 break; 5945 break;
5943 5946
@@ -5950,14 +5953,14 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5950 XSelectionRequestEvent *eventp 5953 XSelectionRequestEvent *eventp
5951 = (XSelectionRequestEvent *) &event; 5954 = (XSelectionRequestEvent *) &event;
5952 5955
5953 inev.kind = SELECTION_REQUEST_EVENT; 5956 inev.ie.kind = SELECTION_REQUEST_EVENT;
5954 SELECTION_EVENT_DISPLAY (&inev) = eventp->display; 5957 SELECTION_EVENT_DISPLAY (&inev.sie) = eventp->display;
5955 SELECTION_EVENT_REQUESTOR (&inev) = eventp->requestor; 5958 SELECTION_EVENT_REQUESTOR (&inev.sie) = eventp->requestor;
5956 SELECTION_EVENT_SELECTION (&inev) = eventp->selection; 5959 SELECTION_EVENT_SELECTION (&inev.sie) = eventp->selection;
5957 SELECTION_EVENT_TARGET (&inev) = eventp->target; 5960 SELECTION_EVENT_TARGET (&inev.sie) = eventp->target;
5958 SELECTION_EVENT_PROPERTY (&inev) = eventp->property; 5961 SELECTION_EVENT_PROPERTY (&inev.sie) = eventp->property;
5959 SELECTION_EVENT_TIME (&inev) = eventp->time; 5962 SELECTION_EVENT_TIME (&inev.sie) = eventp->time;
5960 inev.frame_or_window = Qnil; 5963 inev.ie.frame_or_window = Qnil;
5961 } 5964 }
5962 break; 5965 break;
5963 5966
@@ -6096,8 +6099,8 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6096 { 6099 {
6097 f->async_iconified = 1; 6100 f->async_iconified = 1;
6098 6101
6099 inev.kind = ICONIFY_EVENT; 6102 inev.ie.kind = ICONIFY_EVENT;
6100 XSETFRAME (inev.frame_or_window, f); 6103 XSETFRAME (inev.ie.frame_or_window, f);
6101 } 6104 }
6102 } 6105 }
6103 goto OTHER; 6106 goto OTHER;
@@ -6129,8 +6132,8 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6129 6132
6130 if (f->iconified) 6133 if (f->iconified)
6131 { 6134 {
6132 inev.kind = DEICONIFY_EVENT; 6135 inev.ie.kind = DEICONIFY_EVENT;
6133 XSETFRAME (inev.frame_or_window, f); 6136 XSETFRAME (inev.ie.frame_or_window, f);
6134 } 6137 }
6135 else if (! NILP (Vframe_list) 6138 else if (! NILP (Vframe_list)
6136 && ! NILP (XCDR (Vframe_list))) 6139 && ! NILP (XCDR (Vframe_list)))
@@ -6296,18 +6299,18 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6296 orig_keysym = keysym; 6299 orig_keysym = keysym;
6297 6300
6298 /* Common for all keysym input events. */ 6301 /* Common for all keysym input events. */
6299 XSETFRAME (inev.frame_or_window, f); 6302 XSETFRAME (inev.ie.frame_or_window, f);
6300 inev.modifiers 6303 inev.ie.modifiers
6301 = x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (f), modifiers); 6304 = x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (f), modifiers);
6302 inev.timestamp = event.xkey.time; 6305 inev.ie.timestamp = event.xkey.time;
6303 6306
6304 /* First deal with keysyms which have defined 6307 /* First deal with keysyms which have defined
6305 translations to characters. */ 6308 translations to characters. */
6306 if (keysym >= 32 && keysym < 128) 6309 if (keysym >= 32 && keysym < 128)
6307 /* Avoid explicitly decoding each ASCII character. */ 6310 /* Avoid explicitly decoding each ASCII character. */
6308 { 6311 {
6309 inev.kind = ASCII_KEYSTROKE_EVENT; 6312 inev.ie.kind = ASCII_KEYSTROKE_EVENT;
6310 inev.code = keysym; 6313 inev.ie.code = keysym;
6311 goto done_keysym; 6314 goto done_keysym;
6312 } 6315 }
6313 6316
@@ -6317,10 +6320,10 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6317 Vx_keysym_table, 6320 Vx_keysym_table,
6318 Qnil)))) 6321 Qnil))))
6319 { 6322 {
6320 inev.kind = (SINGLE_BYTE_CHAR_P (XFASTINT (c)) 6323 inev.ie.kind = (SINGLE_BYTE_CHAR_P (XFASTINT (c))
6321 ? ASCII_KEYSTROKE_EVENT 6324 ? ASCII_KEYSTROKE_EVENT
6322 : MULTIBYTE_CHAR_KEYSTROKE_EVENT); 6325 : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
6323 inev.code = XFASTINT (c); 6326 inev.ie.code = XFASTINT (c);
6324 goto done_keysym; 6327 goto done_keysym;
6325 } 6328 }
6326 6329
@@ -6410,8 +6413,8 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6410 STORE_KEYSYM_FOR_DEBUG (keysym); 6413 STORE_KEYSYM_FOR_DEBUG (keysym);
6411 /* make_lispy_event will convert this to a symbolic 6414 /* make_lispy_event will convert this to a symbolic
6412 key. */ 6415 key. */
6413 inev.kind = NON_ASCII_KEYSTROKE_EVENT; 6416 inev.ie.kind = NON_ASCII_KEYSTROKE_EVENT;
6414 inev.code = keysym; 6417 inev.ie.code = keysym;
6415 goto done_keysym; 6418 goto done_keysym;
6416 } 6419 }
6417 6420
@@ -6462,18 +6465,18 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6462 else 6465 else
6463 c = STRING_CHAR_AND_LENGTH (copy_bufptr + i, 6466 c = STRING_CHAR_AND_LENGTH (copy_bufptr + i,
6464 nbytes - i, len); 6467 nbytes - i, len);
6465 inev.kind = (SINGLE_BYTE_CHAR_P (c) 6468 inev.ie.kind = (SINGLE_BYTE_CHAR_P (c)
6466 ? ASCII_KEYSTROKE_EVENT 6469 ? ASCII_KEYSTROKE_EVENT
6467 : MULTIBYTE_CHAR_KEYSTROKE_EVENT); 6470 : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
6468 inev.code = c; 6471 inev.ie.code = c;
6469 kbd_buffer_store_event_hold (&inev, hold_quit); 6472 kbd_buffer_store_event_hold (&inev.ie, hold_quit);
6470 } 6473 }
6471 6474
6472 /* Previous code updated count by nchars rather than nbytes, 6475 /* Previous code updated count by nchars rather than nbytes,
6473 but that seems bogus to me. ++kfs */ 6476 but that seems bogus to me. ++kfs */
6474 count += nbytes; 6477 count += nbytes;
6475 6478
6476 inev.kind = NO_EVENT; /* Already stored above. */ 6479 inev.ie.kind = NO_EVENT; /* Already stored above. */
6477 6480
6478 if (keysym == NoSymbol) 6481 if (keysym == NoSymbol)
6479 break; 6482 break;
@@ -6500,7 +6503,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6500#endif 6503#endif
6501 6504
6502 case EnterNotify: 6505 case EnterNotify:
6503 x_detect_focus_change (dpyinfo, &event, &inev); 6506 x_detect_focus_change (dpyinfo, &event, &inev.ie);
6504 6507
6505 f = x_any_window_to_frame (dpyinfo, event.xcrossing.window); 6508 f = x_any_window_to_frame (dpyinfo, event.xcrossing.window);
6506 6509
@@ -6530,11 +6533,11 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6530 goto OTHER; 6533 goto OTHER;
6531 6534
6532 case FocusIn: 6535 case FocusIn:
6533 x_detect_focus_change (dpyinfo, &event, &inev); 6536 x_detect_focus_change (dpyinfo, &event, &inev.ie);
6534 goto OTHER; 6537 goto OTHER;
6535 6538
6536 case LeaveNotify: 6539 case LeaveNotify:
6537 x_detect_focus_change (dpyinfo, &event, &inev); 6540 x_detect_focus_change (dpyinfo, &event, &inev.ie);
6538 6541
6539 f = x_top_window_to_frame (dpyinfo, event.xcrossing.window); 6542 f = x_top_window_to_frame (dpyinfo, event.xcrossing.window);
6540 if (f) 6543 if (f)
@@ -6557,7 +6560,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6557 goto OTHER; 6560 goto OTHER;
6558 6561
6559 case FocusOut: 6562 case FocusOut:
6560 x_detect_focus_change (dpyinfo, &event, &inev); 6563 x_detect_focus_change (dpyinfo, &event, &inev.ie);
6561 goto OTHER; 6564 goto OTHER;
6562 6565
6563 case MotionNotify: 6566 case MotionNotify:
@@ -6597,8 +6600,8 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6597 && !EQ (window, last_window) 6600 && !EQ (window, last_window)
6598 && !EQ (window, selected_window)) 6601 && !EQ (window, selected_window))
6599 { 6602 {
6600 inev.kind = SELECT_WINDOW_EVENT; 6603 inev.ie.kind = SELECT_WINDOW_EVENT;
6601 inev.frame_or_window = window; 6604 inev.ie.frame_or_window = window;
6602 } 6605 }
6603 6606
6604 last_window=window; 6607 last_window=window;
@@ -6757,13 +6760,13 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6757 && (int)(event.xbutton.time - ignore_next_mouse_click_timeout) > 0) 6760 && (int)(event.xbutton.time - ignore_next_mouse_click_timeout) > 0)
6758 { 6761 {
6759 ignore_next_mouse_click_timeout = 0; 6762 ignore_next_mouse_click_timeout = 0;
6760 construct_mouse_click (&inev, &event, f); 6763 construct_mouse_click (&inev.ie, &event, f);
6761 } 6764 }
6762 if (event.type == ButtonRelease) 6765 if (event.type == ButtonRelease)
6763 ignore_next_mouse_click_timeout = 0; 6766 ignore_next_mouse_click_timeout = 0;
6764 } 6767 }
6765 else 6768 else
6766 construct_mouse_click (&inev, &event, f); 6769 construct_mouse_click (&inev.ie, &event, f);
6767 } 6770 }
6768 } 6771 }
6769 } 6772 }
@@ -6778,12 +6781,12 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6778 scroll bars. */ 6781 scroll bars. */
6779 if (bar && event.xbutton.state & ControlMask) 6782 if (bar && event.xbutton.state & ControlMask)
6780 { 6783 {
6781 x_scroll_bar_handle_click (bar, &event, &inev); 6784 x_scroll_bar_handle_click (bar, &event, &inev.ie);
6782 *finish = X_EVENT_DROP; 6785 *finish = X_EVENT_DROP;
6783 } 6786 }
6784#else /* not USE_TOOLKIT_SCROLL_BARS */ 6787#else /* not USE_TOOLKIT_SCROLL_BARS */
6785 if (bar) 6788 if (bar)
6786 x_scroll_bar_handle_click (bar, &event, &inev); 6789 x_scroll_bar_handle_click (bar, &event, &inev.ie);
6787#endif /* not USE_TOOLKIT_SCROLL_BARS */ 6790#endif /* not USE_TOOLKIT_SCROLL_BARS */
6788 } 6791 }
6789 6792
@@ -6891,9 +6894,9 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6891 } 6894 }
6892 6895
6893 done: 6896 done:
6894 if (inev.kind != NO_EVENT) 6897 if (inev.ie.kind != NO_EVENT)
6895 { 6898 {
6896 kbd_buffer_store_event_hold (&inev, hold_quit); 6899 kbd_buffer_store_event_hold (&inev.ie, hold_quit);
6897 count++; 6900 count++;
6898 } 6901 }
6899 6902