aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2025-03-03 09:32:08 -0800
committerPaul Eggert2025-03-03 09:44:42 -0800
commit29a9fd4f4ba17822eca0f00c2037da3868bd874e (patch)
tree94f69a89281045884f84a10c3767ed0bb8f570d4 /src
parent96d26b493618f59bbdd4de86be65e784735541c8 (diff)
downloademacs-29a9fd4f4ba17822eca0f00c2037da3868bd874e.tar.gz
emacs-29a9fd4f4ba17822eca0f00c2037da3868bd874e.zip
Avoid some union buffered_input_event uses
Simplify by using separate local vars for struct input_event and struct selection_input_event, rather than a single local var that is the union of the two. This makes the code easier to follow by the human reader, and should help avoid GCC bug 117423 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117423> and therefore work around Emacs bug 76559 <https://bugs.gnu.org/76559>. * src/androidterm.c (handle_one_android_event): * src/gtkutil.c (xg_widget_key_press_event_cb): * src/pgtkterm.c (evq_flush): * src/xterm.c (handle_one_xevent): Use struct input_event and kbd_buffer_store_event_hold, or struct selection_input_event and kbd_buffer_store_selection_event_hold, rather than union buffered_input_event and union buffered_input_event. * src/keyboard.c (beware_long_paste, maybe_quit_while_no_input): New functions, broken out from kbd_buffer_store_buffered_event. (kbd_buffer_store_event_hold): Define here, with a simplified version of the body of the old kbd_buffer_store_buffered_event, rather than defining in keyboard.h. Specialize to struct input_event. (kbd_buffer_store_selection_event_hold): New function; it is a simplified version of the old kbd_buffer_store_buffered_event, specialized to struct selection_input_event. (is_ignored_event_kind): Accept enum event_kind instead of union buffered_input_event. All callers changed. * src/keyboard.h (kbd_buffer_store_event_hold): Remove definition, as keyboard.c now defines it. * src/pgtkterm.c (evq_grow_if_needed): New function. (evq_enqueue, evq_selection_enqueue): Two functions now, not one. Args are now struct input_event const * or struct selection_input_event const *, not union buffered_input_event *. All callers changed. This lets us simplify the callers so that they need not use the union.
Diffstat (limited to 'src')
-rw-r--r--src/androidterm.c171
-rw-r--r--src/gtkutil.c42
-rw-r--r--src/keyboard.c104
-rw-r--r--src/keyboard.h15
-rw-r--r--src/pgtkterm.c582
-rw-r--r--src/xterm.c402
6 files changed, 686 insertions, 630 deletions
diff --git a/src/androidterm.c b/src/androidterm.c
index 3cb9eab3606..79ee374f2ca 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -827,7 +827,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
827 union android_event configureEvent; 827 union android_event configureEvent;
828 struct frame *f, *any, *mouse_frame; 828 struct frame *f, *any, *mouse_frame;
829 Mouse_HLInfo *hlinfo; 829 Mouse_HLInfo *hlinfo;
830 union buffered_input_event inev; 830 struct input_event inev;
831 int modifiers, count, do_help; 831 int modifiers, count, do_help;
832 struct android_touch_point *touchpoint, **last; 832 struct android_touch_point *touchpoint, **last;
833 Lisp_Object window; 833 Lisp_Object window;
@@ -851,7 +851,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
851 if (any && any->wait_event_type == event->type) 851 if (any && any->wait_event_type == event->type)
852 any->wait_event_type = 0; /* Indicates we got it. */ 852 any->wait_event_type = 0; /* Indicates we got it. */
853 853
854 EVENT_INIT (inev.ie); 854 EVENT_INIT (inev);
855 855
856 switch (event->type) 856 switch (event->type)
857 { 857 {
@@ -922,8 +922,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
922 if (!FRAME_TOOLTIP_P (f) 922 if (!FRAME_TOOLTIP_P (f)
923 && (old_left != f->left_pos || old_top != f->top_pos)) 923 && (old_left != f->left_pos || old_top != f->top_pos))
924 { 924 {
925 inev.ie.kind = MOVE_FRAME_EVENT; 925 inev.kind = MOVE_FRAME_EVENT;
926 XSETFRAME (inev.ie.frame_or_window, f); 926 XSETFRAME (inev.frame_or_window, f);
927 } 927 }
928 928
929 if (f && FRAME_OUTPUT_DATA (f)->need_cursor_updates) 929 if (f && FRAME_OUTPUT_DATA (f)->need_cursor_updates)
@@ -982,10 +982,10 @@ handle_one_android_event (struct android_display_info *dpyinfo,
982 memset (&compose_status, 0, sizeof (compose_status)); 982 memset (&compose_status, 0, sizeof (compose_status));
983 983
984 /* Common for all keysym input events. */ 984 /* Common for all keysym input events. */
985 XSETFRAME (inev.ie.frame_or_window, any); 985 XSETFRAME (inev.frame_or_window, any);
986 inev.ie.modifiers 986 inev.modifiers
987 = android_android_to_emacs_modifiers (dpyinfo, modifiers); 987 = android_android_to_emacs_modifiers (dpyinfo, modifiers);
988 inev.ie.timestamp = event->xkey.time; 988 inev.timestamp = event->xkey.time;
989 989
990 keysym = event->xkey.keycode; 990 keysym = event->xkey.keycode;
991 991
@@ -1019,8 +1019,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1019 1019
1020 if (event->xkey.keycode == (uint32_t) -1) 1020 if (event->xkey.keycode == (uint32_t) -1)
1021 { 1021 {
1022 inev.ie.kind = PREEDIT_TEXT_EVENT; 1022 inev.kind = PREEDIT_TEXT_EVENT;
1023 inev.ie.arg = Qnil; 1023 inev.arg = Qnil;
1024 1024
1025 /* If text was looked up, decode it and make it the 1025 /* If text was looked up, decode it and make it the
1026 preedit text. */ 1026 preedit text. */
@@ -1028,7 +1028,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1028 if (status_return == ANDROID_LOOKUP_CHARS && nchars) 1028 if (status_return == ANDROID_LOOKUP_CHARS && nchars)
1029 { 1029 {
1030 copy_bufptr[nchars] = 0; 1030 copy_bufptr[nchars] = 0;
1031 inev.ie.arg = from_unicode_buffer (copy_bufptr); 1031 inev.arg = from_unicode_buffer (copy_bufptr);
1032 } 1032 }
1033 1033
1034 goto done_keysym; 1034 goto done_keysym;
@@ -1047,11 +1047,11 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1047 /* Deal with characters. */ 1047 /* Deal with characters. */
1048 1048
1049 if (copy_bufptr[0] < 128) 1049 if (copy_bufptr[0] < 128)
1050 inev.ie.kind = ASCII_KEYSTROKE_EVENT; 1050 inev.kind = ASCII_KEYSTROKE_EVENT;
1051 else 1051 else
1052 inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT; 1052 inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
1053 1053
1054 inev.ie.code = copy_bufptr[0]; 1054 inev.code = copy_bufptr[0];
1055 } 1055 }
1056 else if (nchars < 2 && keysym) 1056 else if (nchars < 2 && keysym)
1057 { 1057 {
@@ -1061,8 +1061,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1061 1061
1062 /* Next, deal with special ``characters'' by giving the 1062 /* Next, deal with special ``characters'' by giving the
1063 keycode to keyboard.c. */ 1063 keycode to keyboard.c. */
1064 inev.ie.kind = NON_ASCII_KEYSTROKE_EVENT; 1064 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
1065 inev.ie.code = keysym; 1065 inev.code = keysym;
1066 } 1066 }
1067 else 1067 else
1068 { 1068 {
@@ -1070,25 +1070,25 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1070 1070
1071 for (i = 0; i < nchars; ++i) 1071 for (i = 0; i < nchars; ++i)
1072 { 1072 {
1073 inev.ie.kind = (SINGLE_BYTE_CHAR_P (copy_bufptr[i]) 1073 inev.kind = (SINGLE_BYTE_CHAR_P (copy_bufptr[i])
1074 ? ASCII_KEYSTROKE_EVENT 1074 ? ASCII_KEYSTROKE_EVENT
1075 : MULTIBYTE_CHAR_KEYSTROKE_EVENT); 1075 : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
1076 inev.ie.code = copy_bufptr[i]; 1076 inev.code = copy_bufptr[i];
1077 1077
1078 /* If the character is actually '\n', then change this 1078 /* If the character is actually '\n', then change this
1079 to RET. */ 1079 to RET. */
1080 1080
1081 if (copy_bufptr[i] == '\n') 1081 if (copy_bufptr[i] == '\n')
1082 { 1082 {
1083 inev.ie.kind = NON_ASCII_KEYSTROKE_EVENT; 1083 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
1084 inev.ie.code = 66; 1084 inev.code = 66;
1085 } 1085 }
1086 1086
1087 kbd_buffer_store_buffered_event (&inev, hold_quit); 1087 kbd_buffer_store_event_hold (&inev, hold_quit);
1088 } 1088 }
1089 1089
1090 count += nchars; 1090 count += nchars;
1091 inev.ie.kind = NO_EVENT; /* Already stored above. */ 1091 inev.kind = NO_EVENT; /* Already stored above. */
1092 } 1092 }
1093 1093
1094 goto done_keysym; 1094 goto done_keysym;
@@ -1108,7 +1108,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1108 1108
1109 case ANDROID_FOCUS_IN: 1109 case ANDROID_FOCUS_IN:
1110 case ANDROID_FOCUS_OUT: 1110 case ANDROID_FOCUS_OUT:
1111 android_detect_focus_change (dpyinfo, any, event, &inev.ie); 1111 android_detect_focus_change (dpyinfo, any, event, &inev);
1112 goto OTHER; 1112 goto OTHER;
1113 1113
1114 case ANDROID_WINDOW_ACTION: 1114 case ANDROID_WINDOW_ACTION:
@@ -1136,8 +1136,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1136 if (!f) 1136 if (!f)
1137 goto OTHER; 1137 goto OTHER;
1138 1138
1139 inev.ie.kind = DELETE_WINDOW_EVENT; 1139 inev.kind = DELETE_WINDOW_EVENT;
1140 XSETFRAME (inev.ie.frame_or_window, f); 1140 XSETFRAME (inev.frame_or_window, f);
1141 } 1141 }
1142 } 1142 }
1143 1143
@@ -1196,8 +1196,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1196 && !EQ (window, last_mouse_window) 1196 && !EQ (window, last_mouse_window)
1197 && !EQ (window, selected_window)) 1197 && !EQ (window, selected_window))
1198 { 1198 {
1199 inev.ie.kind = SELECT_WINDOW_EVENT; 1199 inev.kind = SELECT_WINDOW_EVENT;
1200 inev.ie.frame_or_window = window; 1200 inev.frame_or_window = window;
1201 } 1201 }
1202 1202
1203 /* Remember the last window where we saw the mouse. */ 1203 /* Remember the last window where we saw the mouse. */
@@ -1378,10 +1378,10 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1378 if (!(tab_bar_p && NILP (tab_bar_arg)) && !tool_bar_p) 1378 if (!(tab_bar_p && NILP (tab_bar_arg)) && !tool_bar_p)
1379 if (! popup_activated ()) 1379 if (! popup_activated ())
1380 { 1380 {
1381 android_construct_mouse_click (&inev.ie, &event->xbutton, f); 1381 android_construct_mouse_click (&inev, &event->xbutton, f);
1382 1382
1383 if (!NILP (tab_bar_arg)) 1383 if (!NILP (tab_bar_arg))
1384 inev.ie.arg = tab_bar_arg; 1384 inev.arg = tab_bar_arg;
1385 } 1385 }
1386 } 1386 }
1387 1387
@@ -1424,8 +1424,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1424 /* Simply update the tool position and send an update. */ 1424 /* Simply update the tool position and send an update. */
1425 touchpoint->x = event->touch.x; 1425 touchpoint->x = event->touch.x;
1426 touchpoint->y = event->touch.y; 1426 touchpoint->y = event->touch.y;
1427 android_update_tools (any, &inev.ie); 1427 android_update_tools (any, &inev);
1428 inev.ie.timestamp = event->touch.time; 1428 inev.timestamp = event->touch.time;
1429 1429
1430 goto OTHER; 1430 goto OTHER;
1431 } 1431 }
@@ -1498,12 +1498,12 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1498 } 1498 }
1499 1499
1500 /* Now generate the Emacs event. */ 1500 /* Now generate the Emacs event. */
1501 inev.ie.kind = TOUCHSCREEN_BEGIN_EVENT; 1501 inev.kind = TOUCHSCREEN_BEGIN_EVENT;
1502 inev.ie.timestamp = event->touch.time; 1502 inev.timestamp = event->touch.time;
1503 XSETFRAME (inev.ie.frame_or_window, any); 1503 XSETFRAME (inev.frame_or_window, any);
1504 XSETINT (inev.ie.x, event->touch.x); 1504 XSETINT (inev.x, event->touch.x);
1505 XSETINT (inev.ie.y, event->touch.y); 1505 XSETINT (inev.y, event->touch.y);
1506 XSETINT (inev.ie.arg, event->touch.pointer_id); 1506 XSETINT (inev.arg, event->touch.pointer_id);
1507 1507
1508 goto OTHER; 1508 goto OTHER;
1509 1509
@@ -1526,8 +1526,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1526 1526
1527 touchpoint->x = event->touch.x; 1527 touchpoint->x = event->touch.x;
1528 touchpoint->y = event->touch.y; 1528 touchpoint->y = event->touch.y;
1529 android_update_tools (any, &inev.ie); 1529 android_update_tools (any, &inev);
1530 inev.ie.timestamp = event->touch.time; 1530 inev.timestamp = event->touch.time;
1531 1531
1532 goto OTHER; 1532 goto OTHER;
1533 1533
@@ -1569,18 +1569,18 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1569 grabbed by the tool bar). */ 1569 grabbed by the tool bar). */
1570 xfree (touchpoint); 1570 xfree (touchpoint);
1571 1571
1572 inev.ie.kind = TOUCHSCREEN_END_EVENT; 1572 inev.kind = TOUCHSCREEN_END_EVENT;
1573 inev.ie.timestamp = event->touch.time; 1573 inev.timestamp = event->touch.time;
1574 1574
1575 /* Report whether the sequence has been canceled. */ 1575 /* Report whether the sequence has been canceled. */
1576 1576
1577 if (event->touch.flags & ANDROID_TOUCH_SEQUENCE_CANCELED) 1577 if (event->touch.flags & ANDROID_TOUCH_SEQUENCE_CANCELED)
1578 inev.ie.modifiers = 1; 1578 inev.modifiers = 1;
1579 1579
1580 XSETFRAME (inev.ie.frame_or_window, any); 1580 XSETFRAME (inev.frame_or_window, any);
1581 XSETINT (inev.ie.x, event->touch.x); 1581 XSETINT (inev.x, event->touch.x);
1582 XSETINT (inev.ie.y, event->touch.y); 1582 XSETINT (inev.y, event->touch.y);
1583 XSETINT (inev.ie.arg, event->touch.pointer_id); 1583 XSETINT (inev.arg, event->touch.pointer_id);
1584 1584
1585 /* Break out of the loop. */ 1585 /* Break out of the loop. */
1586 goto OTHER; 1586 goto OTHER;
@@ -1629,24 +1629,24 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1629 } 1629 }
1630 1630
1631 /* Determine what kind of event to send. */ 1631 /* Determine what kind of event to send. */
1632 inev.ie.kind = ((fabs (wheel_event_y) 1632 inev.kind = ((fabs (wheel_event_y)
1633 >= fabs (wheel_event_x)) 1633 >= fabs (wheel_event_x))
1634 ? WHEEL_EVENT : HORIZ_WHEEL_EVENT); 1634 ? WHEEL_EVENT : HORIZ_WHEEL_EVENT);
1635 inev.ie.timestamp = event->wheel.time; 1635 inev.timestamp = event->wheel.time;
1636 1636
1637 /* Set the event coordinates. */ 1637 /* Set the event coordinates. */
1638 XSETINT (inev.ie.x, event->wheel.x); 1638 XSETINT (inev.x, event->wheel.x);
1639 XSETINT (inev.ie.y, event->wheel.y); 1639 XSETINT (inev.y, event->wheel.y);
1640 1640
1641 /* Set the frame. */ 1641 /* Set the frame. */
1642 XSETFRAME (inev.ie.frame_or_window, any); 1642 XSETFRAME (inev.frame_or_window, any);
1643 1643
1644 /* Figure out the scroll direction. */ 1644 /* Figure out the scroll direction. */
1645 inev.ie.modifiers = (signbit ((fabs (wheel_event_x) 1645 inev.modifiers = (signbit ((fabs (wheel_event_x)
1646 >= fabs (wheel_event_y)) 1646 >= fabs (wheel_event_y))
1647 ? wheel_event_x 1647 ? wheel_event_x
1648 : wheel_event_y) 1648 : wheel_event_y)
1649 ? down_modifier : up_modifier); 1649 ? down_modifier : up_modifier);
1650 1650
1651 /* Figure out how much to scale the deltas by. */ 1651 /* Figure out how much to scale the deltas by. */
1652 window = window_from_coordinates (any, event->wheel.x, 1652 window = window_from_coordinates (any, event->wheel.x,
@@ -1664,16 +1664,14 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1664 scroll_unit = pow (scroll_height, 2.0 / 3.0); 1664 scroll_unit = pow (scroll_height, 2.0 / 3.0);
1665 1665
1666 /* Add the keyboard modifiers. */ 1666 /* Add the keyboard modifiers. */
1667 inev.ie.modifiers 1667 inev.modifiers
1668 |= android_android_to_emacs_modifiers (dpyinfo, 1668 |= android_android_to_emacs_modifiers (dpyinfo,
1669 event->wheel.state); 1669 event->wheel.state);
1670 1670
1671 /* Finally include the scroll deltas. */ 1671 /* Finally include the scroll deltas. */
1672 inev.ie.arg = list3 (Qnil, 1672 inev.arg = list3 (Qnil,
1673 make_float (wheel_event_x 1673 make_float (wheel_event_x * scroll_unit),
1674 * scroll_unit), 1674 make_float (wheel_event_y * scroll_unit));
1675 make_float (wheel_event_y
1676 * scroll_unit));
1677 1675
1678 wheel_event_x = 0.0; 1676 wheel_event_x = 0.0;
1679 wheel_event_y = 0.0; 1677 wheel_event_y = 0.0;
@@ -1693,8 +1691,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1693 SET_FRAME_VISIBLE (any, false); 1691 SET_FRAME_VISIBLE (any, false);
1694 SET_FRAME_ICONIFIED (any, true); 1692 SET_FRAME_ICONIFIED (any, true);
1695 1693
1696 inev.ie.kind = ICONIFY_EVENT; 1694 inev.kind = ICONIFY_EVENT;
1697 XSETFRAME (inev.ie.frame_or_window, any); 1695 XSETFRAME (inev.frame_or_window, any);
1698 goto OTHER; 1696 goto OTHER;
1699 1697
1700 case ANDROID_DEICONIFIED: 1698 case ANDROID_DEICONIFIED:
@@ -1708,8 +1706,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1708 SET_FRAME_VISIBLE (any, true); 1706 SET_FRAME_VISIBLE (any, true);
1709 SET_FRAME_ICONIFIED (any, false); 1707 SET_FRAME_ICONIFIED (any, false);
1710 1708
1711 inev.ie.kind = DEICONIFY_EVENT; 1709 inev.kind = DEICONIFY_EVENT;
1712 XSETFRAME (inev.ie.frame_or_window, any); 1710 XSETFRAME (inev.frame_or_window, any);
1713 goto OTHER; 1711 goto OTHER;
1714 1712
1715 /* Context menu handling. */ 1713 /* Context menu handling. */
@@ -1757,12 +1755,12 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1757 goto OTHER; 1755 goto OTHER;
1758 1756
1759 /* Generate a drag and drop event to convey its position. */ 1757 /* Generate a drag and drop event to convey its position. */
1760 inev.ie.kind = DRAG_N_DROP_EVENT; 1758 inev.kind = DRAG_N_DROP_EVENT;
1761 XSETFRAME (inev.ie.frame_or_window, any); 1759 XSETFRAME (inev.frame_or_window, any);
1762 inev.ie.timestamp = ANDROID_CURRENT_TIME; 1760 inev.timestamp = ANDROID_CURRENT_TIME;
1763 XSETINT (inev.ie.x, event->dnd.x); 1761 XSETINT (inev.x, event->dnd.x);
1764 XSETINT (inev.ie.y, event->dnd.y); 1762 XSETINT (inev.y, event->dnd.y);
1765 inev.ie.arg = Fcons (inev.ie.x, inev.ie.y); 1763 inev.arg = Fcons (inev.x, inev.y);
1766 goto OTHER; 1764 goto OTHER;
1767 1765
1768 case ANDROID_DND_URI_EVENT: 1766 case ANDROID_DND_URI_EVENT:
@@ -1778,15 +1776,15 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1778 content or file URI or a string to be inserted. Generate an 1776 content or file URI or a string to be inserted. Generate an
1779 event with this information. */ 1777 event with this information. */
1780 1778
1781 inev.ie.kind = DRAG_N_DROP_EVENT; 1779 inev.kind = DRAG_N_DROP_EVENT;
1782 XSETFRAME (inev.ie.frame_or_window, any); 1780 XSETFRAME (inev.frame_or_window, any);
1783 inev.ie.timestamp = ANDROID_CURRENT_TIME; 1781 inev.timestamp = ANDROID_CURRENT_TIME;
1784 XSETINT (inev.ie.x, event->dnd.x); 1782 XSETINT (inev.x, event->dnd.x);
1785 XSETINT (inev.ie.y, event->dnd.y); 1783 XSETINT (inev.y, event->dnd.y);
1786 inev.ie.arg = Fcons ((event->type == ANDROID_DND_TEXT_EVENT 1784 inev.arg = Fcons ((event->type == ANDROID_DND_TEXT_EVENT
1787 ? Qtext : Quri), 1785 ? Qtext : Quri),
1788 android_decode_utf16 (event->dnd.uri_or_string, 1786 android_decode_utf16 (event->dnd.uri_or_string,
1789 event->dnd.length)); 1787 event->dnd.length));
1790 free (event->dnd.uri_or_string); 1788 free (event->dnd.uri_or_string);
1791 goto OTHER; 1789 goto OTHER;
1792 1790
@@ -1794,15 +1792,14 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1794 case ANDROID_NOTIFICATION_ACTION: 1792 case ANDROID_NOTIFICATION_ACTION:
1795 1793
1796 if (event->notification.type == ANDROID_NOTIFICATION_DELETED) 1794 if (event->notification.type == ANDROID_NOTIFICATION_DELETED)
1797 android_notification_deleted (&event->notification, &inev.ie); 1795 android_notification_deleted (&event->notification, &inev);
1798 else 1796 else
1799 { 1797 {
1800 Lisp_Object action; 1798 Lisp_Object action;
1801 1799
1802 action = android_decode_utf16 (event->notification.action, 1800 action = android_decode_utf16 (event->notification.action,
1803 event->notification.length); 1801 event->notification.length);
1804 android_notification_action (&event->notification, &inev.ie, 1802 android_notification_action (&event->notification, &inev, action);
1805 action);
1806 } 1803 }
1807 1804
1808 /* Free dynamically allocated data. */ 1805 /* Free dynamically allocated data. */
@@ -1815,9 +1812,9 @@ handle_one_android_event (struct android_display_info *dpyinfo,
1815 } 1812 }
1816 1813
1817 OTHER: 1814 OTHER:
1818 if (inev.ie.kind != NO_EVENT) 1815 if (inev.kind != NO_EVENT)
1819 { 1816 {
1820 kbd_buffer_store_buffered_event (&inev, hold_quit); 1817 kbd_buffer_store_event_hold (&inev, hold_quit);
1821 count++; 1818 count++;
1822 } 1819 }
1823 1820
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 0770874eb40..164531aaeb3 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -6382,7 +6382,7 @@ xg_widget_key_press_event_cb (GtkWidget *widget, GdkEvent *event,
6382{ 6382{
6383 Lisp_Object tail, tem; 6383 Lisp_Object tail, tem;
6384 struct frame *f = NULL; 6384 struct frame *f = NULL;
6385 union buffered_input_event inev; 6385 struct input_event inev;
6386 guint keysym = event->key.keyval; 6386 guint keysym = event->key.keyval;
6387 unsigned int xstate; 6387 unsigned int xstate;
6388 gunichar uc; 6388 gunichar uc;
@@ -6419,15 +6419,15 @@ xg_widget_key_press_event_cb (GtkWidget *widget, GdkEvent *event,
6419 && !FRAME_DISPLAY_INFO (f)->prefer_native_input) 6419 && !FRAME_DISPLAY_INFO (f)->prefer_native_input)
6420 return true; 6420 return true;
6421 6421
6422 EVENT_INIT (inev.ie); 6422 EVENT_INIT (inev);
6423 XSETFRAME (inev.ie.frame_or_window, f); 6423 XSETFRAME (inev.frame_or_window, f);
6424 6424
6425 xstate = xg_virtual_mods_to_x (FRAME_DISPLAY_INFO (f), 6425 xstate = xg_virtual_mods_to_x (FRAME_DISPLAY_INFO (f),
6426 event->key.state); 6426 event->key.state);
6427 6427
6428 inev.ie.modifiers 6428 inev.modifiers
6429 |= x_x_to_emacs_modifiers (FRAME_DISPLAY_INFO (f), xstate); 6429 |= x_x_to_emacs_modifiers (FRAME_DISPLAY_INFO (f), xstate);
6430 inev.ie.timestamp = event->key.time; 6430 inev.timestamp = event->key.time;
6431 6431
6432#ifdef HAVE_XINPUT2 6432#ifdef HAVE_XINPUT2
6433 if (event->key.time == pending_keystroke_time) 6433 if (event->key.time == pending_keystroke_time)
@@ -6436,7 +6436,7 @@ xg_widget_key_press_event_cb (GtkWidget *widget, GdkEvent *event,
6436 FRAME_DISPLAY_INFO (f)->pending_keystroke_source); 6436 FRAME_DISPLAY_INFO (f)->pending_keystroke_source);
6437 6437
6438 if (source) 6438 if (source)
6439 inev.ie.device = source->name; 6439 inev.device = source->name;
6440 } 6440 }
6441#endif 6441#endif
6442 6442
@@ -6455,8 +6455,8 @@ xg_widget_key_press_event_cb (GtkWidget *widget, GdkEvent *event,
6455 if (keysym >= 32 && keysym < 128) 6455 if (keysym >= 32 && keysym < 128)
6456 /* Avoid explicitly decoding each ASCII character. */ 6456 /* Avoid explicitly decoding each ASCII character. */
6457 { 6457 {
6458 inev.ie.kind = ASCII_KEYSTROKE_EVENT; 6458 inev.kind = ASCII_KEYSTROKE_EVENT;
6459 inev.ie.code = keysym; 6459 inev.code = keysym;
6460 goto done; 6460 goto done;
6461 } 6461 }
6462 6462
@@ -6464,10 +6464,10 @@ xg_widget_key_press_event_cb (GtkWidget *widget, GdkEvent *event,
6464 if (keysym >= 0x01000000 && keysym <= 0x0110FFFF) 6464 if (keysym >= 0x01000000 && keysym <= 0x0110FFFF)
6465 { 6465 {
6466 if (keysym < 0x01000080) 6466 if (keysym < 0x01000080)
6467 inev.ie.kind = ASCII_KEYSTROKE_EVENT; 6467 inev.kind = ASCII_KEYSTROKE_EVENT;
6468 else 6468 else
6469 inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT; 6469 inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
6470 inev.ie.code = keysym & 0xFFFFFF; 6470 inev.code = keysym & 0xFFFFFF;
6471 goto done; 6471 goto done;
6472 } 6472 }
6473 6473
@@ -6523,8 +6523,8 @@ xg_widget_key_press_event_cb (GtkWidget *widget, GdkEvent *event,
6523 /* Any "vendor-specific" key is ok. */ 6523 /* Any "vendor-specific" key is ok. */
6524 || (keysym & (1 << 28)))) 6524 || (keysym & (1 << 28))))
6525 { 6525 {
6526 inev.ie.kind = NON_ASCII_KEYSTROKE_EVENT; 6526 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
6527 inev.ie.code = keysym; 6527 inev.code = keysym;
6528 goto done; 6528 goto done;
6529 } 6529 }
6530 6530
@@ -6532,22 +6532,22 @@ xg_widget_key_press_event_cb (GtkWidget *widget, GdkEvent *event,
6532 6532
6533 if (uc) 6533 if (uc)
6534 { 6534 {
6535 inev.ie.kind = (SINGLE_BYTE_CHAR_P (uc) 6535 inev.kind = (SINGLE_BYTE_CHAR_P (uc)
6536 ? ASCII_KEYSTROKE_EVENT 6536 ? ASCII_KEYSTROKE_EVENT
6537 : MULTIBYTE_CHAR_KEYSTROKE_EVENT); 6537 : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
6538 inev.ie.code = uc; 6538 inev.code = uc;
6539 } 6539 }
6540 else 6540 else
6541 { 6541 {
6542 inev.ie.kind = NON_ASCII_KEYSTROKE_EVENT; 6542 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
6543 inev.ie.code = keysym; 6543 inev.code = keysym;
6544 } 6544 }
6545 6545
6546 done: 6546 done:
6547 if (inev.ie.kind != NO_EVENT) 6547 if (inev.kind != NO_EVENT)
6548 { 6548 {
6549 xg_pending_quit_event.kind = NO_EVENT; 6549 xg_pending_quit_event.kind = NO_EVENT;
6550 kbd_buffer_store_buffered_event (&inev, &xg_pending_quit_event); 6550 kbd_buffer_store_event_hold (&inev, &xg_pending_quit_event);
6551 } 6551 }
6552 6552
6553 XNoOp (FRAME_X_DISPLAY (f)); 6553 XNoOp (FRAME_X_DISPLAY (f));
diff --git a/src/keyboard.c b/src/keyboard.c
index b22814d702d..fd0ac01755e 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -408,7 +408,7 @@ static void timer_resume_idle (void);
408static void deliver_user_signal (int); 408static void deliver_user_signal (int);
409static char *find_user_signal_name (int); 409static char *find_user_signal_name (int);
410static void store_user_signal_events (void); 410static void store_user_signal_events (void);
411static bool is_ignored_event (union buffered_input_event *); 411static bool is_ignored_event_kind (enum event_kind);
412 412
413/* Advance or retreat a buffered input event pointer. */ 413/* Advance or retreat a buffered input event pointer. */
414 414
@@ -3629,7 +3629,7 @@ readable_events (int flags)
3629 && (event->kind == FOCUS_IN_EVENT 3629 && (event->kind == FOCUS_IN_EVENT
3630 || event->kind == FOCUS_OUT_EVENT)) 3630 || event->kind == FOCUS_OUT_EVENT))
3631 || (input_pending_p_filter_events 3631 || (input_pending_p_filter_events
3632 && is_ignored_event (event)))) 3632 && is_ignored_event_kind (event->kind))))
3633#ifdef USE_TOOLKIT_SCROLL_BARS 3633#ifdef USE_TOOLKIT_SCROLL_BARS
3634 && !((flags & READABLE_EVENTS_IGNORE_SQUEEZABLES) 3634 && !((flags & READABLE_EVENTS_IGNORE_SQUEEZABLES)
3635 && (event->kind == SCROLL_BAR_CLICK_EVENT 3635 && (event->kind == SCROLL_BAR_CLICK_EVENT
@@ -3714,6 +3714,31 @@ kbd_buffer_store_event (register struct input_event *event)
3714 kbd_buffer_store_event_hold (event, 0); 3714 kbd_buffer_store_event_hold (event, 0);
3715} 3715}
3716 3716
3717static void
3718beware_long_paste (void)
3719{
3720#ifdef subprocesses
3721 if (! (kbd_buffer_nr_stored () <= KBD_BUFFER_SIZE / 2
3722 && kbd_on_hold_p ()))
3723 {
3724 /* Don't read keyboard input until we have processed kbd_buffer.
3725 This happens when pasting text longer than KBD_BUFFER_SIZE/2. */
3726 hold_keyboard_input ();
3727 unrequest_sigio ();
3728 stop_polling ();
3729 }
3730#endif
3731}
3732
3733/* If we're inside while-no-input, and this event qualifies
3734 as input, set quit-flag to cause an interrupt. */
3735static void
3736maybe_quit_while_no_input (enum event_kind kind)
3737{
3738 if (!NILP (Vthrow_on_input) && !is_ignored_event_kind (kind))
3739 Vquit_flag = Vthrow_on_input;
3740}
3741
3717/* Store EVENT obtained at interrupt level into kbd_buffer, fifo. 3742/* Store EVENT obtained at interrupt level into kbd_buffer, fifo.
3718 3743
3719 If HOLD_QUIT is 0, just stuff EVENT into the fifo. 3744 If HOLD_QUIT is 0, just stuff EVENT into the fifo.
@@ -3725,8 +3750,8 @@ kbd_buffer_store_event (register struct input_event *event)
3725 subsequent input events have been parsed (and discarded). */ 3750 subsequent input events have been parsed (and discarded). */
3726 3751
3727void 3752void
3728kbd_buffer_store_buffered_event (union buffered_input_event *event, 3753kbd_buffer_store_event_hold (struct input_event *event,
3729 struct input_event *hold_quit) 3754 struct input_event *hold_quit)
3730{ 3755{
3731 if (event->kind == NO_EVENT) 3756 if (event->kind == NO_EVENT)
3732 emacs_abort (); 3757 emacs_abort ();
@@ -3736,23 +3761,23 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event,
3736 3761
3737 if (event->kind == ASCII_KEYSTROKE_EVENT) 3762 if (event->kind == ASCII_KEYSTROKE_EVENT)
3738 { 3763 {
3739 int c = event->ie.code & 0377; 3764 int c = event->code & 0377;
3740 3765
3741 if (event->ie.modifiers & ctrl_modifier) 3766 if (event->modifiers & ctrl_modifier)
3742 c = make_ctrl_char (c); 3767 c = make_ctrl_char (c);
3743 3768
3744 c |= (event->ie.modifiers 3769 c |= (event->modifiers
3745 & (meta_modifier | alt_modifier 3770 & (meta_modifier | alt_modifier
3746 | hyper_modifier | super_modifier)); 3771 | hyper_modifier | super_modifier));
3747 3772
3748 if (c == quit_char) 3773 if (c == quit_char)
3749 { 3774 {
3750 KBOARD *kb = FRAME_KBOARD (XFRAME (event->ie.frame_or_window)); 3775 KBOARD *kb = FRAME_KBOARD (XFRAME (event->frame_or_window));
3751 3776
3752 if (single_kboard && kb != current_kboard) 3777 if (single_kboard && kb != current_kboard)
3753 { 3778 {
3754 kset_kbd_queue 3779 kset_kbd_queue
3755 (kb, list2 (make_lispy_switch_frame (event->ie.frame_or_window), 3780 (kb, list2 (make_lispy_switch_frame (event->frame_or_window),
3756 make_fixnum (c))); 3781 make_fixnum (c)));
3757 kb->kbd_queue_has_data = true; 3782 kb->kbd_queue_has_data = true;
3758 3783
@@ -3771,7 +3796,7 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event,
3771 3796
3772 if (hold_quit) 3797 if (hold_quit)
3773 { 3798 {
3774 *hold_quit = event->ie; 3799 *hold_quit = *event;
3775 return; 3800 return;
3776 } 3801 }
3777 3802
@@ -3782,9 +3807,9 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event,
3782 { 3807 {
3783 Lisp_Object focus; 3808 Lisp_Object focus;
3784 3809
3785 focus = FRAME_FOCUS_FRAME (XFRAME (event->ie.frame_or_window)); 3810 focus = FRAME_FOCUS_FRAME (XFRAME (event->frame_or_window));
3786 if (NILP (focus)) 3811 if (NILP (focus))
3787 focus = event->ie.frame_or_window; 3812 focus = event->frame_or_window;
3788 internal_last_event_frame = focus; 3813 internal_last_event_frame = focus;
3789 Vlast_event_frame = focus; 3814 Vlast_event_frame = focus;
3790 } 3815 }
@@ -3807,26 +3832,43 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event,
3807 union buffered_input_event *next_slot = next_kbd_event (kbd_store_ptr); 3832 union buffered_input_event *next_slot = next_kbd_event (kbd_store_ptr);
3808 if (kbd_fetch_ptr != next_slot) 3833 if (kbd_fetch_ptr != next_slot)
3809 { 3834 {
3810 *kbd_store_ptr = *event; 3835 kbd_store_ptr->ie = *event;
3811 kbd_store_ptr = next_slot; 3836 kbd_store_ptr = next_slot;
3812#ifdef subprocesses 3837 beware_long_paste ();
3813 if (kbd_buffer_nr_stored () > KBD_BUFFER_SIZE / 2
3814 && ! kbd_on_hold_p ())
3815 {
3816 /* Don't read keyboard input until we have processed kbd_buffer.
3817 This happens when pasting text longer than KBD_BUFFER_SIZE/2. */
3818 hold_keyboard_input ();
3819 unrequest_sigio ();
3820 stop_polling ();
3821 }
3822#endif /* subprocesses */
3823 } 3838 }
3824 3839
3825 /* If we're inside while-no-input, and this event qualifies 3840 maybe_quit_while_no_input (event->kind);
3826 as input, set quit-flag to cause an interrupt. */ 3841}
3827 if (!NILP (Vthrow_on_input) 3842
3828 && !is_ignored_event (event)) 3843/* Store EVENT obtained at interrupt level into kbd_buffer, fifo.
3829 Vquit_flag = Vthrow_on_input; 3844 This is like kbd_buffer_store_event_hold, but for struct
3845 selection_input_event instead of struct input_event.
3846
3847 If HOLD_QUIT && HOLD_QUIT->kind != NO_EVENT, discard EVENT.
3848
3849 This is used to postpone the processing of the quit event until all
3850 subsequent input events have been parsed (and discarded). */
3851
3852void
3853kbd_buffer_store_selection_event_hold (struct selection_input_event *event,
3854 struct input_event *hold_quit)
3855{
3856 if (hold_quit && hold_quit->kind != NO_EVENT)
3857 return;
3858
3859 /* Don't let the very last slot in the buffer become full,
3860 since that would make the two pointers equal,
3861 and that is indistinguishable from an empty buffer.
3862 Discard the event if it would fill the last slot. */
3863 union buffered_input_event *next_slot = next_kbd_event (kbd_store_ptr);
3864 if (kbd_fetch_ptr != next_slot)
3865 {
3866 kbd_store_ptr->sie = *event;
3867 kbd_store_ptr = next_slot;
3868 beware_long_paste ();
3869 }
3870
3871 maybe_quit_while_no_input (event->kind);
3830} 3872}
3831 3873
3832/* Limit help event positions to this range, to avoid overflow problems. */ 3874/* Limit help event positions to this range, to avoid overflow problems. */
@@ -12877,11 +12919,11 @@ init_while_no_input_ignore_events (void)
12877} 12919}
12878 12920
12879static bool 12921static bool
12880is_ignored_event (union buffered_input_event *event) 12922is_ignored_event_kind (enum event_kind kind)
12881{ 12923{
12882 Lisp_Object ignore_event; 12924 Lisp_Object ignore_event;
12883 12925
12884 switch (event->kind) 12926 switch (kind)
12885 { 12927 {
12886 case FOCUS_IN_EVENT: ignore_event = Qfocus_in; break; 12928 case FOCUS_IN_EVENT: ignore_event = Qfocus_in; break;
12887 case FOCUS_OUT_EVENT: ignore_event = Qfocus_out; break; 12929 case FOCUS_OUT_EVENT: ignore_event = Qfocus_out; break;
diff --git a/src/keyboard.h b/src/keyboard.h
index 5e04b54eb74..ddbb1c3729e 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -499,17 +499,10 @@ extern void clear_waiting_for_input (void);
499extern void swallow_events (bool); 499extern void swallow_events (bool);
500extern bool lucid_event_type_list_p (Lisp_Object); 500extern bool lucid_event_type_list_p (Lisp_Object);
501extern void kbd_buffer_store_event (struct input_event *); 501extern void kbd_buffer_store_event (struct input_event *);
502extern void kbd_buffer_store_buffered_event (union buffered_input_event *, 502extern void kbd_buffer_store_event_hold (struct input_event *,
503 struct input_event *); 503 struct input_event *);
504INLINE void 504extern void kbd_buffer_store_selection_event_hold (struct selection_input_event *,
505kbd_buffer_store_event_hold (struct input_event *event, 505 struct input_event *);
506 struct input_event *hold_quit)
507{
508 static_assert (alignof (struct input_event) == alignof (union buffered_input_event)
509 && sizeof (struct input_event) == sizeof (union buffered_input_event));
510 kbd_buffer_store_buffered_event ((union buffered_input_event *) event,
511 hold_quit);
512}
513extern void poll_for_input_1 (void); 506extern void poll_for_input_1 (void);
514extern void show_help_echo (Lisp_Object, Lisp_Object, Lisp_Object, 507extern void show_help_echo (Lisp_Object, Lisp_Object, Lisp_Object,
515 Lisp_Object); 508 Lisp_Object);
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index 00377ff73a0..0ef6084d2f4 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -286,12 +286,8 @@ flip_cr_context (struct frame *f)
286 286
287 287
288static void 288static void
289evq_enqueue (union buffered_input_event *ev) 289evq_grow_if_needed (struct event_queue_t *evq)
290{ 290{
291 struct event_queue_t *evq = &event_q;
292 struct frame *frame;
293 struct pgtk_display_info *dpyinfo;
294
295 if (evq->cap == 0) 291 if (evq->cap == 0)
296 { 292 {
297 evq->cap = 4; 293 evq->cap = 4;
@@ -303,32 +299,48 @@ evq_enqueue (union buffered_input_event *ev)
303 evq->cap += evq->cap / 2; 299 evq->cap += evq->cap / 2;
304 evq->q = xrealloc (evq->q, sizeof *evq->q * evq->cap); 300 evq->q = xrealloc (evq->q, sizeof *evq->q * evq->cap);
305 } 301 }
302}
303
304static void
305evq_enqueue (struct input_event const *ev)
306{
307 struct event_queue_t *evq = &event_q;
308 struct frame *frame;
309 struct pgtk_display_info *dpyinfo;
306 310
307 evq->q[evq->nr++] = *ev; 311 evq_grow_if_needed (evq);
312 evq->q[evq->nr++].ie = *ev;
308 313
309 if (ev->ie.kind != SELECTION_REQUEST_EVENT 314 frame = NULL;
310 && ev->ie.kind != SELECTION_CLEAR_EVENT)
311 {
312 frame = NULL;
313 315
314 if (WINDOWP (ev->ie.frame_or_window)) 316 if (WINDOWP (ev->frame_or_window))
315 frame = WINDOW_XFRAME (XWINDOW (ev->ie.frame_or_window)); 317 frame = WINDOW_XFRAME (XWINDOW (ev->frame_or_window));
316 318
317 if (FRAMEP (ev->ie.frame_or_window)) 319 if (FRAMEP (ev->frame_or_window))
318 frame = XFRAME (ev->ie.frame_or_window); 320 frame = XFRAME (ev->frame_or_window);
319 321
320 if (frame) 322 if (frame)
321 { 323 {
322 dpyinfo = FRAME_DISPLAY_INFO (frame); 324 dpyinfo = FRAME_DISPLAY_INFO (frame);
323 325
324 if (dpyinfo->last_user_time < ev->ie.timestamp) 326 if (dpyinfo->last_user_time < ev->timestamp)
325 dpyinfo->last_user_time = ev->ie.timestamp; 327 dpyinfo->last_user_time = ev->timestamp;
326 }
327 } 328 }
328 329
329 raise (SIGIO); 330 raise (SIGIO);
330} 331}
331 332
333static void
334evq_selection_enqueue (struct selection_input_event const *ev)
335{
336 struct event_queue_t *evq = &event_q;
337
338 evq_grow_if_needed (evq);
339 evq->q[evq->nr++].sie = *ev;
340
341 raise (SIGIO);
342}
343
332static int 344static int
333evq_flush (struct input_event *hold_quit) 345evq_flush (struct input_event *hold_quit)
334{ 346{
@@ -337,17 +349,27 @@ evq_flush (struct input_event *hold_quit)
337 349
338 while (evq->nr > 0) 350 while (evq->nr > 0)
339 { 351 {
340 /* kbd_buffer_store_buffered_event may do longjmp, so 352 /* Because kbd_buffer_store_event_hold and
341 we need to shift event queue first and pass the event 353 kbd_buffer_store_selection_event_hold may do longjmp,
342 to kbd_buffer_store_buffered_event so that events in 354 we need to shift event queue before passing a pointer
355 to a copy of the event, so that events in
343 queue are not processed twice. Bug#52941 */ 356 queue are not processed twice. Bug#52941 */
344 union buffered_input_event ev = evq->q[0];
345 int i;
346 for (i = 1; i < evq->nr; i++)
347 evq->q[i - 1] = evq->q[i];
348 evq->nr--; 357 evq->nr--;
349 358
350 kbd_buffer_store_buffered_event (&ev, hold_quit); 359 if (evq->q[0].kind == SELECTION_REQUEST_EVENT
360 || evq->q[0].kind == SELECTION_CLEAR_EVENT)
361 {
362 struct selection_input_event sinev = evq->q[0].sie;
363 memmove (&evq->q[0], &evq->q[1], evq->nr * sizeof evq->q[0]);
364 kbd_buffer_store_selection_event_hold (&sinev, hold_quit);
365 }
366 else
367 {
368 struct input_event inev = evq->q[0].ie;
369 memmove (&evq->q[0], &evq->q[1], evq->nr * sizeof evq->q[0]);
370 kbd_buffer_store_event_hold (&inev, hold_quit);
371 }
372
351 n++; 373 n++;
352 } 374 }
353 375
@@ -3928,21 +3950,21 @@ static void
3928pgtk_send_scroll_bar_event (Lisp_Object window, enum scroll_bar_part part, 3950pgtk_send_scroll_bar_event (Lisp_Object window, enum scroll_bar_part part,
3929 int portion, int whole, bool horizontal) 3951 int portion, int whole, bool horizontal)
3930{ 3952{
3931 union buffered_input_event inev; 3953 struct input_event inev;
3932 3954
3933 EVENT_INIT (inev.ie); 3955 EVENT_INIT (inev);
3934 3956
3935 inev.ie.kind = (horizontal 3957 inev.kind = (horizontal
3936 ? HORIZONTAL_SCROLL_BAR_CLICK_EVENT 3958 ? HORIZONTAL_SCROLL_BAR_CLICK_EVENT
3937 : SCROLL_BAR_CLICK_EVENT); 3959 : SCROLL_BAR_CLICK_EVENT);
3938 inev.ie.frame_or_window = window; 3960 inev.frame_or_window = window;
3939 inev.ie.arg = Qnil; 3961 inev.arg = Qnil;
3940 inev.ie.timestamp = 0; 3962 inev.timestamp = 0;
3941 inev.ie.code = 0; 3963 inev.code = 0;
3942 inev.ie.part = part; 3964 inev.part = part;
3943 inev.ie.x = make_fixnum (portion); 3965 inev.x = make_fixnum (portion);
3944 inev.ie.y = make_fixnum (whole); 3966 inev.y = make_fixnum (whole);
3945 inev.ie.modifiers = 0; 3967 inev.modifiers = 0;
3946 3968
3947 evq_enqueue (&inev); 3969 evq_enqueue (&inev);
3948} 3970}
@@ -4942,7 +4964,6 @@ static gboolean
4942pgtk_handle_event (GtkWidget *widget, GdkEvent *event, gpointer *data) 4964pgtk_handle_event (GtkWidget *widget, GdkEvent *event, gpointer *data)
4943{ 4965{
4944 struct frame *f; 4966 struct frame *f;
4945 union buffered_input_event inev;
4946 GtkWidget *frame_widget; 4967 GtkWidget *frame_widget;
4947 gint x, y; 4968 gint x, y;
4948 4969
@@ -4959,18 +4980,18 @@ pgtk_handle_event (GtkWidget *widget, GdkEvent *event, gpointer *data)
4959 &x, &y); 4980 &x, &y);
4960 if (f) 4981 if (f)
4961 { 4982 {
4962 4983 struct input_event inev;
4963 inev.ie.kind = PINCH_EVENT; 4984 inev.kind = PINCH_EVENT;
4964 XSETFRAME (inev.ie.frame_or_window, f); 4985 XSETFRAME (inev.frame_or_window, f);
4965 XSETINT (inev.ie.x, x); 4986 XSETINT (inev.x, x);
4966 XSETINT (inev.ie.y, y); 4987 XSETINT (inev.y, y);
4967 inev.ie.arg = list4 (make_float (event->touchpad_pinch.dx), 4988 inev.arg = list4 (make_float (event->touchpad_pinch.dx),
4968 make_float (event->touchpad_pinch.dy), 4989 make_float (event->touchpad_pinch.dy),
4969 make_float (event->touchpad_pinch.scale), 4990 make_float (event->touchpad_pinch.scale),
4970 make_float (event->touchpad_pinch.angle_delta)); 4991 make_float (event->touchpad_pinch.angle_delta));
4971 inev.ie.modifiers = pgtk_gtk_to_emacs_modifiers (FRAME_DISPLAY_INFO (f), 4992 inev.modifiers = pgtk_gtk_to_emacs_modifiers (FRAME_DISPLAY_INFO (f),
4972 event->touchpad_pinch.state); 4993 event->touchpad_pinch.state);
4973 inev.ie.device 4994 inev.device
4974 = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event); 4995 = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event);
4975 evq_enqueue (&inev); 4996 evq_enqueue (&inev);
4976 } 4997 }
@@ -5188,17 +5209,17 @@ pgtk_enqueue_string (struct frame *f, gchar *str)
5188 return; 5209 return;
5189 for (; *ustr != 0; ustr++) 5210 for (; *ustr != 0; ustr++)
5190 { 5211 {
5191 union buffered_input_event inev; 5212 struct input_event inev;
5192 Lisp_Object c = make_fixnum (*ustr); 5213 Lisp_Object c = make_fixnum (*ustr);
5193 EVENT_INIT (inev.ie); 5214 EVENT_INIT (inev);
5194 inev.ie.kind = (SINGLE_BYTE_CHAR_P (XFIXNAT (c)) 5215 inev.kind = (SINGLE_BYTE_CHAR_P (XFIXNAT (c))
5195 ? ASCII_KEYSTROKE_EVENT 5216 ? ASCII_KEYSTROKE_EVENT
5196 : MULTIBYTE_CHAR_KEYSTROKE_EVENT); 5217 : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
5197 inev.ie.arg = Qnil; 5218 inev.arg = Qnil;
5198 inev.ie.code = XFIXNAT (c); 5219 inev.code = XFIXNAT (c);
5199 XSETFRAME (inev.ie.frame_or_window, f); 5220 XSETFRAME (inev.frame_or_window, f);
5200 inev.ie.modifiers = 0; 5221 inev.modifiers = 0;
5201 inev.ie.timestamp = 0; 5222 inev.timestamp = 0;
5202 evq_enqueue (&inev); 5223 evq_enqueue (&inev);
5203 } 5224 }
5204 5225
@@ -5208,28 +5229,28 @@ pgtk_enqueue_string (struct frame *f, gchar *str)
5208void 5229void
5209pgtk_enqueue_preedit (struct frame *f, Lisp_Object preedit) 5230pgtk_enqueue_preedit (struct frame *f, Lisp_Object preedit)
5210{ 5231{
5211 union buffered_input_event inev; 5232 struct input_event inev;
5212 EVENT_INIT (inev.ie); 5233 EVENT_INIT (inev);
5213 inev.ie.kind = PREEDIT_TEXT_EVENT; 5234 inev.kind = PREEDIT_TEXT_EVENT;
5214 inev.ie.arg = preedit; 5235 inev.arg = preedit;
5215 inev.ie.code = 0; 5236 inev.code = 0;
5216 XSETFRAME (inev.ie.frame_or_window, f); 5237 XSETFRAME (inev.frame_or_window, f);
5217 inev.ie.modifiers = 0; 5238 inev.modifiers = 0;
5218 inev.ie.timestamp = 0; 5239 inev.timestamp = 0;
5219 evq_enqueue (&inev); 5240 evq_enqueue (&inev);
5220} 5241}
5221 5242
5222static gboolean 5243static gboolean
5223key_press_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data) 5244key_press_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
5224{ 5245{
5225 union buffered_input_event inev; 5246 struct input_event inev;
5226 ptrdiff_t nbytes; 5247 ptrdiff_t nbytes;
5227 Mouse_HLInfo *hlinfo; 5248 Mouse_HLInfo *hlinfo;
5228 struct frame *f; 5249 struct frame *f;
5229 struct pgtk_display_info *dpyinfo; 5250 struct pgtk_display_info *dpyinfo;
5230 5251
5231 f = pgtk_any_window_to_frame (gtk_widget_get_window (widget)); 5252 f = pgtk_any_window_to_frame (gtk_widget_get_window (widget));
5232 EVENT_INIT (inev.ie); 5253 EVENT_INIT (inev);
5233 hlinfo = MOUSE_HL_INFO (f); 5254 hlinfo = MOUSE_HL_INFO (f);
5234 nbytes = 0; 5255 nbytes = 0;
5235 5256
@@ -5300,20 +5321,20 @@ key_press_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
5300 orig_keysym = keysym; 5321 orig_keysym = keysym;
5301 5322
5302 /* Common for all keysym input events. */ 5323 /* Common for all keysym input events. */
5303 XSETFRAME (inev.ie.frame_or_window, f); 5324 XSETFRAME (inev.frame_or_window, f);
5304 inev.ie.modifiers 5325 inev.modifiers
5305 = pgtk_gtk_to_emacs_modifiers (FRAME_DISPLAY_INFO (f), modifiers); 5326 = pgtk_gtk_to_emacs_modifiers (FRAME_DISPLAY_INFO (f), modifiers);
5306 inev.ie.timestamp = event->key.time; 5327 inev.timestamp = event->key.time;
5307 5328
5308 /* First deal with keysyms which have defined 5329 /* First deal with keysyms which have defined
5309 translations to characters. */ 5330 translations to characters. */
5310 if (keysym >= 32 && keysym < 128) 5331 if (keysym >= 32 && keysym < 128)
5311 /* Avoid explicitly decoding each ASCII character. */ 5332 /* Avoid explicitly decoding each ASCII character. */
5312 { 5333 {
5313 inev.ie.kind = ASCII_KEYSTROKE_EVENT; 5334 inev.kind = ASCII_KEYSTROKE_EVENT;
5314 inev.ie.code = keysym; 5335 inev.code = keysym;
5315 5336
5316 inev.ie.device 5337 inev.device
5317 = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event); 5338 = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event);
5318 goto done; 5339 goto done;
5319 } 5340 }
@@ -5322,12 +5343,12 @@ key_press_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
5322 if (keysym >= 0x01000000 && keysym <= 0x0110FFFF) 5343 if (keysym >= 0x01000000 && keysym <= 0x0110FFFF)
5323 { 5344 {
5324 if (keysym < 0x01000080) 5345 if (keysym < 0x01000080)
5325 inev.ie.kind = ASCII_KEYSTROKE_EVENT; 5346 inev.kind = ASCII_KEYSTROKE_EVENT;
5326 else 5347 else
5327 inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT; 5348 inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
5328 inev.ie.code = keysym & 0xFFFFFF; 5349 inev.code = keysym & 0xFFFFFF;
5329 5350
5330 inev.ie.device 5351 inev.device
5331 = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event); 5352 = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event);
5332 goto done; 5353 goto done;
5333 } 5354 }
@@ -5337,12 +5358,12 @@ key_press_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
5337 && (c = Fgethash (make_fixnum (keysym), 5358 && (c = Fgethash (make_fixnum (keysym),
5338 Vpgtk_keysym_table, Qnil), FIXNATP (c))) 5359 Vpgtk_keysym_table, Qnil), FIXNATP (c)))
5339 { 5360 {
5340 inev.ie.kind = (SINGLE_BYTE_CHAR_P (XFIXNAT (c)) 5361 inev.kind = (SINGLE_BYTE_CHAR_P (XFIXNAT (c))
5341 ? ASCII_KEYSTROKE_EVENT 5362 ? ASCII_KEYSTROKE_EVENT
5342 : MULTIBYTE_CHAR_KEYSTROKE_EVENT); 5363 : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
5343 inev.ie.code = XFIXNAT (c); 5364 inev.code = XFIXNAT (c);
5344 5365
5345 inev.ie.device 5366 inev.device
5346 = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event); 5367 = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event);
5347 goto done; 5368 goto done;
5348 } 5369 }
@@ -5421,18 +5442,18 @@ key_press_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
5421 { 5442 {
5422 /* make_lispy_event will convert this to a symbolic 5443 /* make_lispy_event will convert this to a symbolic
5423 key. */ 5444 key. */
5424 inev.ie.kind = NON_ASCII_KEYSTROKE_EVENT; 5445 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
5425 inev.ie.code = keysym; 5446 inev.code = keysym;
5426 5447
5427 inev.ie.device 5448 inev.device
5428 = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event); 5449 = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event);
5429 goto done; 5450 goto done;
5430 } 5451 }
5431 5452
5432 { 5453 {
5433 inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT; 5454 inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
5434 inev.ie.arg = make_unibyte_string ((char *) copy_bufptr, nbytes); 5455 inev.arg = make_unibyte_string ((char *) copy_bufptr, nbytes);
5435 inev.ie.device 5456 inev.device
5436 = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event); 5457 = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event);
5437 5458
5438 if (keysym == GDK_KEY_VoidSymbol) 5459 if (keysym == GDK_KEY_VoidSymbol)
@@ -5441,9 +5462,9 @@ key_press_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
5441 } 5462 }
5442 5463
5443done: 5464done:
5444 if (inev.ie.kind != NO_EVENT) 5465 if (inev.kind != NO_EVENT)
5445 { 5466 {
5446 XSETFRAME (inev.ie.frame_or_window, f); 5467 XSETFRAME (inev.frame_or_window, f);
5447 evq_enqueue (&inev); 5468 evq_enqueue (&inev);
5448 } 5469 }
5449 5470
@@ -5522,11 +5543,11 @@ map_event (GtkWidget *widget,
5522 gpointer *user_data) 5543 gpointer *user_data)
5523{ 5544{
5524 struct frame *f = pgtk_any_window_to_frame (event->any.window); 5545 struct frame *f = pgtk_any_window_to_frame (event->any.window);
5525 union buffered_input_event inev; 5546 struct input_event inev;
5526 5547
5527 EVENT_INIT (inev.ie); 5548 EVENT_INIT (inev);
5528 inev.ie.kind = NO_EVENT; 5549 inev.kind = NO_EVENT;
5529 inev.ie.arg = Qnil; 5550 inev.arg = Qnil;
5530 5551
5531 if (f) 5552 if (f)
5532 { 5553 {
@@ -5553,12 +5574,12 @@ map_event (GtkWidget *widget,
5553 5574
5554 if (iconified) 5575 if (iconified)
5555 { 5576 {
5556 inev.ie.kind = DEICONIFY_EVENT; 5577 inev.kind = DEICONIFY_EVENT;
5557 XSETFRAME (inev.ie.frame_or_window, f); 5578 XSETFRAME (inev.frame_or_window, f);
5558 } 5579 }
5559 } 5580 }
5560 5581
5561 if (inev.ie.kind != NO_EVENT) 5582 if (inev.kind != NO_EVENT)
5562 evq_enqueue (&inev); 5583 evq_enqueue (&inev);
5563 return FALSE; 5584 return FALSE;
5564} 5585}
@@ -5570,13 +5591,13 @@ window_state_event (GtkWidget *widget,
5570{ 5591{
5571 struct frame *f = pgtk_any_window_to_frame (event->window_state.window); 5592 struct frame *f = pgtk_any_window_to_frame (event->window_state.window);
5572 GdkWindowState new_state; 5593 GdkWindowState new_state;
5573 union buffered_input_event inev; 5594 struct input_event inev;
5574 5595
5575 new_state = event->window_state.new_window_state; 5596 new_state = event->window_state.new_window_state;
5576 5597
5577 EVENT_INIT (inev.ie); 5598 EVENT_INIT (inev);
5578 inev.ie.kind = NO_EVENT; 5599 inev.kind = NO_EVENT;
5579 inev.ie.arg = Qnil; 5600 inev.arg = Qnil;
5580 5601
5581 if (new_state & GDK_WINDOW_STATE_FULLSCREEN) 5602 if (new_state & GDK_WINDOW_STATE_FULLSCREEN)
5582 store_frame_param (f, Qfullscreen, Qfullboth); 5603 store_frame_param (f, Qfullscreen, Qfullboth);
@@ -5622,8 +5643,8 @@ window_state_event (GtkWidget *widget,
5622 else 5643 else
5623 { 5644 {
5624 FRAME_X_OUTPUT (f)->has_been_visible = true; 5645 FRAME_X_OUTPUT (f)->has_been_visible = true;
5625 inev.ie.kind = DEICONIFY_EVENT; 5646 inev.kind = DEICONIFY_EVENT;
5626 XSETFRAME (inev.ie.frame_or_window, f); 5647 XSETFRAME (inev.frame_or_window, f);
5627 SET_FRAME_ICONIFIED (f, false); 5648 SET_FRAME_ICONIFIED (f, false);
5628 SET_FRAME_VISIBLE (f, true); 5649 SET_FRAME_VISIBLE (f, true);
5629 } 5650 }
@@ -5633,7 +5654,7 @@ window_state_event (GtkWidget *widget,
5633 else 5654 else
5634 store_frame_param (f, Qsticky, Qnil); 5655 store_frame_param (f, Qsticky, Qnil);
5635 5656
5636 if (inev.ie.kind != NO_EVENT) 5657 if (inev.kind != NO_EVENT)
5637 evq_enqueue (&inev); 5658 evq_enqueue (&inev);
5638 return FALSE; 5659 return FALSE;
5639} 5660}
@@ -5643,19 +5664,19 @@ delete_event (GtkWidget *widget,
5643 GdkEvent *event, gpointer *user_data) 5664 GdkEvent *event, gpointer *user_data)
5644{ 5665{
5645 struct frame *f = pgtk_any_window_to_frame (event->any.window); 5666 struct frame *f = pgtk_any_window_to_frame (event->any.window);
5646 union buffered_input_event inev; 5667 struct input_event inev;
5647 5668
5648 EVENT_INIT (inev.ie); 5669 EVENT_INIT (inev);
5649 inev.ie.kind = NO_EVENT; 5670 inev.kind = NO_EVENT;
5650 inev.ie.arg = Qnil; 5671 inev.arg = Qnil;
5651 5672
5652 if (f) 5673 if (f)
5653 { 5674 {
5654 inev.ie.kind = DELETE_WINDOW_EVENT; 5675 inev.kind = DELETE_WINDOW_EVENT;
5655 XSETFRAME (inev.ie.frame_or_window, f); 5676 XSETFRAME (inev.frame_or_window, f);
5656 } 5677 }
5657 5678
5658 if (inev.ie.kind != NO_EVENT) 5679 if (inev.kind != NO_EVENT)
5659 evq_enqueue (&inev); 5680 evq_enqueue (&inev);
5660 return TRUE; 5681 return TRUE;
5661} 5682}
@@ -5672,7 +5693,7 @@ delete_event (GtkWidget *widget,
5672static void 5693static void
5673pgtk_focus_changed (gboolean is_enter, int state, 5694pgtk_focus_changed (gboolean is_enter, int state,
5674 struct pgtk_display_info *dpyinfo, struct frame *frame, 5695 struct pgtk_display_info *dpyinfo, struct frame *frame,
5675 union buffered_input_event *bufp) 5696 struct input_event *bufp)
5676{ 5697{
5677 if (is_enter) 5698 if (is_enter)
5678 { 5699 {
@@ -5684,13 +5705,13 @@ pgtk_focus_changed (gboolean is_enter, int state,
5684 /* Don't stop displaying the initial startup message 5705 /* Don't stop displaying the initial startup message
5685 for a switch-frame event we don't need. */ 5706 for a switch-frame event we don't need. */
5686 /* When run as a daemon, Vterminal_frame is always NIL. */ 5707 /* When run as a daemon, Vterminal_frame is always NIL. */
5687 bufp->ie.arg = (((NILP (Vterminal_frame) 5708 bufp->arg = (((NILP (Vterminal_frame)
5688 || !FRAME_PGTK_P (XFRAME (Vterminal_frame)) 5709 || !FRAME_PGTK_P (XFRAME (Vterminal_frame))
5689 || EQ (Fdaemonp (), Qt)) 5710 || EQ (Fdaemonp (), Qt))
5690 && CONSP (Vframe_list) 5711 && CONSP (Vframe_list)
5691 && !NILP (XCDR (Vframe_list))) ? Qt : Qnil); 5712 && !NILP (XCDR (Vframe_list))) ? Qt : Qnil);
5692 bufp->ie.kind = FOCUS_IN_EVENT; 5713 bufp->kind = FOCUS_IN_EVENT;
5693 XSETFRAME (bufp->ie.frame_or_window, frame); 5714 XSETFRAME (bufp->frame_or_window, frame);
5694 } 5715 }
5695 5716
5696 frame->output_data.pgtk->focus_state |= state; 5717 frame->output_data.pgtk->focus_state |= state;
@@ -5705,8 +5726,8 @@ pgtk_focus_changed (gboolean is_enter, int state,
5705 dpyinfo->x_focus_event_frame = 0; 5726 dpyinfo->x_focus_event_frame = 0;
5706 pgtk_new_focus_frame (dpyinfo, NULL); 5727 pgtk_new_focus_frame (dpyinfo, NULL);
5707 5728
5708 bufp->ie.kind = FOCUS_OUT_EVENT; 5729 bufp->kind = FOCUS_OUT_EVENT;
5709 XSETFRAME (bufp->ie.frame_or_window, frame); 5730 XSETFRAME (bufp->frame_or_window, frame);
5710 } 5731 }
5711 5732
5712 if (frame->pointer_invisible) 5733 if (frame->pointer_invisible)
@@ -5718,7 +5739,7 @@ static gboolean
5718enter_notify_event (GtkWidget *widget, GdkEvent *event, 5739enter_notify_event (GtkWidget *widget, GdkEvent *event,
5719 gpointer *user_data) 5740 gpointer *user_data)
5720{ 5741{
5721 union buffered_input_event inev; 5742 struct input_event inev;
5722 struct frame *frame 5743 struct frame *frame
5723 = pgtk_any_window_to_frame (gtk_widget_get_window (widget)); 5744 = pgtk_any_window_to_frame (gtk_widget_get_window (widget));
5724 5745
@@ -5730,14 +5751,14 @@ enter_notify_event (GtkWidget *widget, GdkEvent *event,
5730 int focus_state 5751 int focus_state
5731 = focus_frame ? focus_frame->output_data.pgtk->focus_state : 0; 5752 = focus_frame ? focus_frame->output_data.pgtk->focus_state : 0;
5732 5753
5733 EVENT_INIT (inev.ie); 5754 EVENT_INIT (inev);
5734 inev.ie.kind = NO_EVENT; 5755 inev.kind = NO_EVENT;
5735 inev.ie.arg = Qnil; 5756 inev.arg = Qnil;
5736 5757
5737 if (event->crossing.detail != GDK_NOTIFY_INFERIOR 5758 if (event->crossing.detail != GDK_NOTIFY_INFERIOR
5738 && event->crossing.focus && !(focus_state & FOCUS_EXPLICIT)) 5759 && event->crossing.focus && !(focus_state & FOCUS_EXPLICIT))
5739 pgtk_focus_changed (TRUE, FOCUS_IMPLICIT, dpyinfo, frame, &inev); 5760 pgtk_focus_changed (TRUE, FOCUS_IMPLICIT, dpyinfo, frame, &inev);
5740 if (inev.ie.kind != NO_EVENT) 5761 if (inev.kind != NO_EVENT)
5741 evq_enqueue (&inev); 5762 evq_enqueue (&inev);
5742 return TRUE; 5763 return TRUE;
5743} 5764}
@@ -5746,7 +5767,7 @@ static gboolean
5746leave_notify_event (GtkWidget *widget, GdkEvent *event, 5767leave_notify_event (GtkWidget *widget, GdkEvent *event,
5747 gpointer *user_data) 5768 gpointer *user_data)
5748{ 5769{
5749 union buffered_input_event inev; 5770 struct input_event inev;
5750 struct frame *frame 5771 struct frame *frame
5751 = pgtk_any_window_to_frame (gtk_widget_get_window (widget)); 5772 = pgtk_any_window_to_frame (gtk_widget_get_window (widget));
5752 5773
@@ -5767,9 +5788,9 @@ leave_notify_event (GtkWidget *widget, GdkEvent *event,
5767 hlinfo->mouse_face_mouse_frame = 0; 5788 hlinfo->mouse_face_mouse_frame = 0;
5768 } 5789 }
5769 5790
5770 EVENT_INIT (inev.ie); 5791 EVENT_INIT (inev);
5771 inev.ie.kind = NO_EVENT; 5792 inev.kind = NO_EVENT;
5772 inev.ie.arg = Qnil; 5793 inev.arg = Qnil;
5773 5794
5774 if (event->crossing.detail != GDK_NOTIFY_INFERIOR 5795 if (event->crossing.detail != GDK_NOTIFY_INFERIOR
5775 && event->crossing.focus && !(focus_state & FOCUS_EXPLICIT)) 5796 && event->crossing.focus && !(focus_state & FOCUS_EXPLICIT))
@@ -5786,7 +5807,7 @@ leave_notify_event (GtkWidget *widget, GdkEvent *event,
5786 } 5807 }
5787 } 5808 }
5788 5809
5789 if (inev.ie.kind != NO_EVENT) 5810 if (inev.kind != NO_EVENT)
5790 evq_enqueue (&inev); 5811 evq_enqueue (&inev);
5791 return TRUE; 5812 return TRUE;
5792} 5813}
@@ -5794,20 +5815,20 @@ leave_notify_event (GtkWidget *widget, GdkEvent *event,
5794static gboolean 5815static gboolean
5795focus_in_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data) 5816focus_in_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
5796{ 5817{
5797 union buffered_input_event inev; 5818 struct input_event inev;
5798 struct frame *frame 5819 struct frame *frame
5799 = pgtk_any_window_to_frame (gtk_widget_get_window (widget)); 5820 = pgtk_any_window_to_frame (gtk_widget_get_window (widget));
5800 5821
5801 if (frame == NULL) 5822 if (frame == NULL)
5802 return TRUE; 5823 return TRUE;
5803 5824
5804 EVENT_INIT (inev.ie); 5825 EVENT_INIT (inev);
5805 inev.ie.kind = NO_EVENT; 5826 inev.kind = NO_EVENT;
5806 inev.ie.arg = Qnil; 5827 inev.arg = Qnil;
5807 5828
5808 pgtk_focus_changed (TRUE, FOCUS_EXPLICIT, 5829 pgtk_focus_changed (TRUE, FOCUS_EXPLICIT,
5809 FRAME_DISPLAY_INFO (frame), frame, &inev); 5830 FRAME_DISPLAY_INFO (frame), frame, &inev);
5810 if (inev.ie.kind != NO_EVENT) 5831 if (inev.kind != NO_EVENT)
5811 evq_enqueue (&inev); 5832 evq_enqueue (&inev);
5812 5833
5813 pgtk_im_focus_in (frame); 5834 pgtk_im_focus_in (frame);
@@ -5818,20 +5839,20 @@ focus_in_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
5818static gboolean 5839static gboolean
5819focus_out_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data) 5840focus_out_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
5820{ 5841{
5821 union buffered_input_event inev; 5842 struct input_event inev;
5822 struct frame *frame 5843 struct frame *frame
5823 = pgtk_any_window_to_frame (gtk_widget_get_window (widget)); 5844 = pgtk_any_window_to_frame (gtk_widget_get_window (widget));
5824 5845
5825 if (frame == NULL) 5846 if (frame == NULL)
5826 return TRUE; 5847 return TRUE;
5827 5848
5828 EVENT_INIT (inev.ie); 5849 EVENT_INIT (inev);
5829 inev.ie.kind = NO_EVENT; 5850 inev.kind = NO_EVENT;
5830 inev.ie.arg = Qnil; 5851 inev.arg = Qnil;
5831 5852
5832 pgtk_focus_changed (FALSE, FOCUS_EXPLICIT, 5853 pgtk_focus_changed (FALSE, FOCUS_EXPLICIT,
5833 FRAME_DISPLAY_INFO (frame), frame, &inev); 5854 FRAME_DISPLAY_INFO (frame), frame, &inev);
5834 if (inev.ie.kind != NO_EVENT) 5855 if (inev.kind != NO_EVENT)
5835 evq_enqueue (&inev); 5856 evq_enqueue (&inev);
5836 5857
5837 pgtk_im_focus_out (frame); 5858 pgtk_im_focus_out (frame);
@@ -5901,7 +5922,7 @@ static gboolean
5901motion_notify_event (GtkWidget *widget, GdkEvent *event, 5922motion_notify_event (GtkWidget *widget, GdkEvent *event,
5902 gpointer *user_data) 5923 gpointer *user_data)
5903{ 5924{
5904 union buffered_input_event inev; 5925 struct input_event inev;
5905 struct frame *f, *frame; 5926 struct frame *f, *frame;
5906 struct pgtk_display_info *dpyinfo; 5927 struct pgtk_display_info *dpyinfo;
5907 Mouse_HLInfo *hlinfo; 5928 Mouse_HLInfo *hlinfo;
@@ -5917,9 +5938,9 @@ motion_notify_event (GtkWidget *widget, GdkEvent *event,
5917 && (gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN))) 5938 && (gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN)))
5918 return FALSE; 5939 return FALSE;
5919 5940
5920 EVENT_INIT (inev.ie); 5941 EVENT_INIT (inev);
5921 inev.ie.kind = NO_EVENT; 5942 inev.kind = NO_EVENT;
5922 inev.ie.arg = Qnil; 5943 inev.arg = Qnil;
5923 5944
5924 previous_help_echo_string = help_echo_string; 5945 previous_help_echo_string = help_echo_string;
5925 help_echo_string = Qnil; 5946 help_echo_string = Qnil;
@@ -5970,8 +5991,8 @@ motion_notify_event (GtkWidget *widget, GdkEvent *event,
5970 && !EQ (window, last_mouse_window) 5991 && !EQ (window, last_mouse_window)
5971 && !EQ (window, selected_window)) 5992 && !EQ (window, selected_window))
5972 { 5993 {
5973 inev.ie.kind = SELECT_WINDOW_EVENT; 5994 inev.kind = SELECT_WINDOW_EVENT;
5974 inev.ie.frame_or_window = window; 5995 inev.frame_or_window = window;
5975 } 5996 }
5976 5997
5977 /* Remember the last window where we saw the mouse. */ 5998 /* Remember the last window where we saw the mouse. */
@@ -5992,7 +6013,7 @@ motion_notify_event (GtkWidget *widget, GdkEvent *event,
5992 if (!NILP (help_echo_string) || !NILP (previous_help_echo_string)) 6013 if (!NILP (help_echo_string) || !NILP (previous_help_echo_string))
5993 do_help = 1; 6014 do_help = 1;
5994 6015
5995 if (inev.ie.kind != NO_EVENT) 6016 if (inev.kind != NO_EVENT)
5996 evq_enqueue (&inev); 6017 evq_enqueue (&inev);
5997 6018
5998 if (do_help > 0) 6019 if (do_help > 0)
@@ -6045,7 +6066,7 @@ static gboolean
6045button_event (GtkWidget *widget, GdkEvent *event, 6066button_event (GtkWidget *widget, GdkEvent *event,
6046 gpointer *user_data) 6067 gpointer *user_data)
6047{ 6068{
6048 union buffered_input_event inev; 6069 struct input_event inev;
6049 struct frame *f, *frame; 6070 struct frame *f, *frame;
6050 struct pgtk_display_info *dpyinfo; 6071 struct pgtk_display_info *dpyinfo;
6051 6072
@@ -6066,9 +6087,9 @@ button_event (GtkWidget *widget, GdkEvent *event,
6066 && (gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN))) 6087 && (gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN)))
6067 return FALSE; 6088 return FALSE;
6068 6089
6069 EVENT_INIT (inev.ie); 6090 EVENT_INIT (inev);
6070 inev.ie.kind = NO_EVENT; 6091 inev.kind = NO_EVENT;
6071 inev.ie.arg = Qnil; 6092 inev.arg = Qnil;
6072 6093
6073 /* ignore double click and triple click. */ 6094 /* ignore double click and triple click. */
6074 if (event->type != GDK_BUTTON_PRESS && event->type != GDK_BUTTON_RELEASE) 6095 if (event->type != GDK_BUTTON_PRESS && event->type != GDK_BUTTON_RELEASE)
@@ -6137,16 +6158,16 @@ button_event (GtkWidget *widget, GdkEvent *event,
6137 && event->button.time > ignore_next_mouse_click_timeout) 6158 && event->button.time > ignore_next_mouse_click_timeout)
6138 { 6159 {
6139 ignore_next_mouse_click_timeout = 0; 6160 ignore_next_mouse_click_timeout = 0;
6140 construct_mouse_click (&inev.ie, &event->button, f); 6161 construct_mouse_click (&inev, &event->button, f);
6141 } 6162 }
6142 if (event->type == GDK_BUTTON_RELEASE) 6163 if (event->type == GDK_BUTTON_RELEASE)
6143 ignore_next_mouse_click_timeout = 0; 6164 ignore_next_mouse_click_timeout = 0;
6144 } 6165 }
6145 else 6166 else
6146 construct_mouse_click (&inev.ie, &event->button, f); 6167 construct_mouse_click (&inev, &event->button, f);
6147 6168
6148 if (!NILP (tab_bar_arg)) 6169 if (!NILP (tab_bar_arg))
6149 inev.ie.arg = tab_bar_arg; 6170 inev.arg = tab_bar_arg;
6150 } 6171 }
6151 } 6172 }
6152 6173
@@ -6168,7 +6189,7 @@ button_event (GtkWidget *widget, GdkEvent *event,
6168 if (f != 0) 6189 if (f != 0)
6169 f->mouse_moved = false; 6190 f->mouse_moved = false;
6170 6191
6171 if (inev.ie.kind != NO_EVENT) 6192 if (inev.kind != NO_EVENT)
6172 evq_enqueue (&inev); 6193 evq_enqueue (&inev);
6173 return TRUE; 6194 return TRUE;
6174} 6195}
@@ -6176,15 +6197,15 @@ button_event (GtkWidget *widget, GdkEvent *event,
6176static gboolean 6197static gboolean
6177scroll_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data) 6198scroll_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
6178{ 6199{
6179 union buffered_input_event inev; 6200 struct input_event inev;
6180 struct frame *f, *frame; 6201 struct frame *f, *frame;
6181 struct pgtk_display_info *dpyinfo; 6202 struct pgtk_display_info *dpyinfo;
6182 GdkScrollDirection dir; 6203 GdkScrollDirection dir;
6183 double delta_x, delta_y; 6204 double delta_x, delta_y;
6184 6205
6185 EVENT_INIT (inev.ie); 6206 EVENT_INIT (inev);
6186 inev.ie.kind = NO_EVENT; 6207 inev.kind = NO_EVENT;
6187 inev.ie.arg = Qnil; 6208 inev.arg = Qnil;
6188 6209
6189 frame = pgtk_any_window_to_frame (gtk_widget_get_window (widget)); 6210 frame = pgtk_any_window_to_frame (gtk_widget_get_window (widget));
6190 dpyinfo = FRAME_DISPLAY_INFO (frame); 6211 dpyinfo = FRAME_DISPLAY_INFO (frame);
@@ -6194,19 +6215,19 @@ scroll_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
6194 else 6215 else
6195 f = pgtk_any_window_to_frame (gtk_widget_get_window (widget)); 6216 f = pgtk_any_window_to_frame (gtk_widget_get_window (widget));
6196 6217
6197 inev.ie.kind = NO_EVENT; 6218 inev.kind = NO_EVENT;
6198 inev.ie.timestamp = event->scroll.time; 6219 inev.timestamp = event->scroll.time;
6199 inev.ie.modifiers 6220 inev.modifiers
6200 = pgtk_gtk_to_emacs_modifiers (FRAME_DISPLAY_INFO (f), event->scroll.state); 6221 = pgtk_gtk_to_emacs_modifiers (FRAME_DISPLAY_INFO (f), event->scroll.state);
6201 XSETINT (inev.ie.x, event->scroll.x); 6222 XSETINT (inev.x, event->scroll.x);
6202 XSETINT (inev.ie.y, event->scroll.y); 6223 XSETINT (inev.y, event->scroll.y);
6203 XSETFRAME (inev.ie.frame_or_window, f); 6224 XSETFRAME (inev.frame_or_window, f);
6204 inev.ie.arg = Qnil; 6225 inev.arg = Qnil;
6205 6226
6206 if (gdk_event_is_scroll_stop_event (event)) 6227 if (gdk_event_is_scroll_stop_event (event))
6207 { 6228 {
6208 inev.ie.kind = TOUCH_END_EVENT; 6229 inev.kind = TOUCH_END_EVENT;
6209 inev.ie.device 6230 inev.device
6210 = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event); 6231 = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event);
6211 evq_enqueue (&inev); 6232 evq_enqueue (&inev);
6212 return TRUE; 6233 return TRUE;
@@ -6217,20 +6238,20 @@ scroll_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
6217 switch (dir) 6238 switch (dir)
6218 { 6239 {
6219 case GDK_SCROLL_UP: 6240 case GDK_SCROLL_UP:
6220 inev.ie.kind = WHEEL_EVENT; 6241 inev.kind = WHEEL_EVENT;
6221 inev.ie.modifiers |= up_modifier; 6242 inev.modifiers |= up_modifier;
6222 break; 6243 break;
6223 case GDK_SCROLL_DOWN: 6244 case GDK_SCROLL_DOWN:
6224 inev.ie.kind = WHEEL_EVENT; 6245 inev.kind = WHEEL_EVENT;
6225 inev.ie.modifiers |= down_modifier; 6246 inev.modifiers |= down_modifier;
6226 break; 6247 break;
6227 case GDK_SCROLL_LEFT: 6248 case GDK_SCROLL_LEFT:
6228 inev.ie.kind = HORIZ_WHEEL_EVENT; 6249 inev.kind = HORIZ_WHEEL_EVENT;
6229 inev.ie.modifiers |= up_modifier; 6250 inev.modifiers |= up_modifier;
6230 break; 6251 break;
6231 case GDK_SCROLL_RIGHT: 6252 case GDK_SCROLL_RIGHT:
6232 inev.ie.kind = HORIZ_WHEEL_EVENT; 6253 inev.kind = HORIZ_WHEEL_EVENT;
6233 inev.ie.modifiers |= down_modifier; 6254 inev.modifiers |= down_modifier;
6234 break; 6255 break;
6235 case GDK_SCROLL_SMOOTH: /* shut up warning */ 6256 case GDK_SCROLL_SMOOTH: /* shut up warning */
6236 break; 6257 break;
@@ -6240,14 +6261,14 @@ scroll_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
6240 { 6261 {
6241 if (!mwheel_coalesce_scroll_events) 6262 if (!mwheel_coalesce_scroll_events)
6242 { 6263 {
6243 inev.ie.kind = ((fabs (delta_x) > fabs (delta_y)) 6264 inev.kind = ((fabs (delta_x) > fabs (delta_y))
6244 ? HORIZ_WHEEL_EVENT 6265 ? HORIZ_WHEEL_EVENT
6245 : WHEEL_EVENT); 6266 : WHEEL_EVENT);
6246 inev.ie.modifiers |= (inev.ie.kind == HORIZ_WHEEL_EVENT 6267 inev.modifiers |= (inev.kind == HORIZ_WHEEL_EVENT
6247 ? (delta_x >= 0 ? up_modifier : down_modifier) 6268 ? (delta_x >= 0 ? up_modifier : down_modifier)
6248 : (delta_y >= 0 ? down_modifier : up_modifier)); 6269 : (delta_y >= 0 ? down_modifier : up_modifier));
6249 inev.ie.arg = list3 (Qnil, make_float (-delta_x * 100), 6270 inev.arg = list3 (Qnil, make_float (-delta_x * 100),
6250 make_float (-delta_y * 100)); 6271 make_float (-delta_y * 100));
6251 } 6272 }
6252 else 6273 else
6253 { 6274 {
@@ -6256,21 +6277,21 @@ scroll_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
6256 if (dpyinfo->scroll.acc_y >= dpyinfo->scroll.y_per_line) 6277 if (dpyinfo->scroll.acc_y >= dpyinfo->scroll.y_per_line)
6257 { 6278 {
6258 int nlines = dpyinfo->scroll.acc_y / dpyinfo->scroll.y_per_line; 6279 int nlines = dpyinfo->scroll.acc_y / dpyinfo->scroll.y_per_line;
6259 inev.ie.kind = WHEEL_EVENT; 6280 inev.kind = WHEEL_EVENT;
6260 inev.ie.modifiers |= down_modifier; 6281 inev.modifiers |= down_modifier;
6261 inev.ie.arg = list3 (make_fixnum (nlines), 6282 inev.arg = list3 (make_fixnum (nlines),
6262 make_float (-dpyinfo->scroll.acc_x * 100), 6283 make_float (-dpyinfo->scroll.acc_x * 100),
6263 make_float (-dpyinfo->scroll.acc_y * 100)); 6284 make_float (-dpyinfo->scroll.acc_y * 100));
6264 dpyinfo->scroll.acc_y -= dpyinfo->scroll.y_per_line * nlines; 6285 dpyinfo->scroll.acc_y -= dpyinfo->scroll.y_per_line * nlines;
6265 } 6286 }
6266 else if (dpyinfo->scroll.acc_y <= -dpyinfo->scroll.y_per_line) 6287 else if (dpyinfo->scroll.acc_y <= -dpyinfo->scroll.y_per_line)
6267 { 6288 {
6268 int nlines = -dpyinfo->scroll.acc_y / dpyinfo->scroll.y_per_line; 6289 int nlines = -dpyinfo->scroll.acc_y / dpyinfo->scroll.y_per_line;
6269 inev.ie.kind = WHEEL_EVENT; 6290 inev.kind = WHEEL_EVENT;
6270 inev.ie.modifiers |= up_modifier; 6291 inev.modifiers |= up_modifier;
6271 inev.ie.arg = list3 (make_fixnum (nlines), 6292 inev.arg = list3 (make_fixnum (nlines),
6272 make_float (-dpyinfo->scroll.acc_x * 100), 6293 make_float (-dpyinfo->scroll.acc_x * 100),
6273 make_float (-dpyinfo->scroll.acc_y * 100)); 6294 make_float (-dpyinfo->scroll.acc_y * 100));
6274 6295
6275 dpyinfo->scroll.acc_y -= -dpyinfo->scroll.y_per_line * nlines; 6296 dpyinfo->scroll.acc_y -= -dpyinfo->scroll.y_per_line * nlines;
6276 } 6297 }
@@ -6278,31 +6299,31 @@ scroll_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
6278 || !mwheel_coalesce_scroll_events) 6299 || !mwheel_coalesce_scroll_events)
6279 { 6300 {
6280 int nchars = dpyinfo->scroll.acc_x / dpyinfo->scroll.x_per_char; 6301 int nchars = dpyinfo->scroll.acc_x / dpyinfo->scroll.x_per_char;
6281 inev.ie.kind = HORIZ_WHEEL_EVENT; 6302 inev.kind = HORIZ_WHEEL_EVENT;
6282 inev.ie.modifiers |= up_modifier; 6303 inev.modifiers |= up_modifier;
6283 inev.ie.arg = list3 (make_fixnum (nchars), 6304 inev.arg = list3 (make_fixnum (nchars),
6284 make_float (-dpyinfo->scroll.acc_x * 100), 6305 make_float (-dpyinfo->scroll.acc_x * 100),
6285 make_float (-dpyinfo->scroll.acc_y * 100)); 6306 make_float (-dpyinfo->scroll.acc_y * 100));
6286 6307
6287 dpyinfo->scroll.acc_x -= dpyinfo->scroll.x_per_char * nchars; 6308 dpyinfo->scroll.acc_x -= dpyinfo->scroll.x_per_char * nchars;
6288 } 6309 }
6289 else if (dpyinfo->scroll.acc_x <= -dpyinfo->scroll.x_per_char) 6310 else if (dpyinfo->scroll.acc_x <= -dpyinfo->scroll.x_per_char)
6290 { 6311 {
6291 int nchars = -dpyinfo->scroll.acc_x / dpyinfo->scroll.x_per_char; 6312 int nchars = -dpyinfo->scroll.acc_x / dpyinfo->scroll.x_per_char;
6292 inev.ie.kind = HORIZ_WHEEL_EVENT; 6313 inev.kind = HORIZ_WHEEL_EVENT;
6293 inev.ie.modifiers |= down_modifier; 6314 inev.modifiers |= down_modifier;
6294 inev.ie.arg = list3 (make_fixnum (nchars), 6315 inev.arg = list3 (make_fixnum (nchars),
6295 make_float (-dpyinfo->scroll.acc_x * 100), 6316 make_float (-dpyinfo->scroll.acc_x * 100),
6296 make_float (-dpyinfo->scroll.acc_y * 100)); 6317 make_float (-dpyinfo->scroll.acc_y * 100));
6297 6318
6298 dpyinfo->scroll.acc_x -= -dpyinfo->scroll.x_per_char * nchars; 6319 dpyinfo->scroll.acc_x -= -dpyinfo->scroll.x_per_char * nchars;
6299 } 6320 }
6300 } 6321 }
6301 } 6322 }
6302 6323
6303 if (inev.ie.kind != NO_EVENT) 6324 if (inev.kind != NO_EVENT)
6304 { 6325 {
6305 inev.ie.device 6326 inev.device
6306 = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event); 6327 = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event);
6307 evq_enqueue (&inev); 6328 evq_enqueue (&inev);
6308 } 6329 }
@@ -6397,7 +6418,7 @@ drag_leave (GtkWidget *widget, GdkDragContext *context,
6397 guint time, gpointer user_data) 6418 guint time, gpointer user_data)
6398{ 6419{
6399 struct frame *f; 6420 struct frame *f;
6400 union buffered_input_event inev; 6421 struct input_event inev;
6401 6422
6402 f = pgtk_any_window_to_frame (gtk_widget_get_window (widget)); 6423 f = pgtk_any_window_to_frame (gtk_widget_get_window (widget));
6403 6424
@@ -6411,16 +6432,16 @@ drag_leave (GtkWidget *widget, GdkDragContext *context,
6411 g_object_unref); 6432 g_object_unref);
6412 } 6433 }
6413 6434
6414 EVENT_INIT (inev.ie); 6435 EVENT_INIT (inev);
6415 6436
6416 inev.ie.kind = DRAG_N_DROP_EVENT; 6437 inev.kind = DRAG_N_DROP_EVENT;
6417 inev.ie.modifiers = 0; 6438 inev.modifiers = 0;
6418 inev.ie.arg = Qnil; 6439 inev.arg = Qnil;
6419 inev.ie.timestamp = time; 6440 inev.timestamp = time;
6420 6441
6421 XSETINT (inev.ie.x, 0); 6442 XSETINT (inev.x, 0);
6422 XSETINT (inev.ie.y, 0); 6443 XSETINT (inev.y, 0);
6423 XSETFRAME (inev.ie.frame_or_window, f); 6444 XSETFRAME (inev.frame_or_window, f);
6424 6445
6425 evq_enqueue (&inev); 6446 evq_enqueue (&inev);
6426} 6447}
@@ -6431,7 +6452,7 @@ drag_motion (GtkWidget *widget, GdkDragContext *context,
6431 6452
6432{ 6453{
6433 struct frame *f; 6454 struct frame *f;
6434 union buffered_input_event inev; 6455 struct input_event inev;
6435 GdkAtom name; 6456 GdkAtom name;
6436 GdkDragAction suggestion; 6457 GdkDragAction suggestion;
6437 6458
@@ -6457,18 +6478,18 @@ drag_motion (GtkWidget *widget, GdkDragContext *context,
6457 name = gdk_drag_get_selection (context); 6478 name = gdk_drag_get_selection (context);
6458 suggestion = gdk_drag_context_get_suggested_action (context); 6479 suggestion = gdk_drag_context_get_suggested_action (context);
6459 6480
6460 EVENT_INIT (inev.ie); 6481 EVENT_INIT (inev);
6461 6482
6462 inev.ie.kind = DRAG_N_DROP_EVENT; 6483 inev.kind = DRAG_N_DROP_EVENT;
6463 inev.ie.modifiers = 0; 6484 inev.modifiers = 0;
6464 inev.ie.arg = list4 (Qlambda, intern (gdk_atom_name (name)), 6485 inev.arg = list4 (Qlambda, intern (gdk_atom_name (name)),
6465 make_uint (time), 6486 make_uint (time),
6466 drag_action_to_symbol (suggestion)); 6487 drag_action_to_symbol (suggestion));
6467 inev.ie.timestamp = time; 6488 inev.timestamp = time;
6468 6489
6469 XSETINT (inev.ie.x, x); 6490 XSETINT (inev.x, x);
6470 XSETINT (inev.ie.y, y); 6491 XSETINT (inev.y, y);
6471 XSETFRAME (inev.ie.frame_or_window, f); 6492 XSETFRAME (inev.frame_or_window, f);
6472 6493
6473 evq_enqueue (&inev); 6494 evq_enqueue (&inev);
6474 6495
@@ -6480,7 +6501,7 @@ drag_drop (GtkWidget *widget, GdkDragContext *context,
6480 int x, int y, guint time, gpointer user_data) 6501 int x, int y, guint time, gpointer user_data)
6481{ 6502{
6482 struct frame *f; 6503 struct frame *f;
6483 union buffered_input_event inev; 6504 struct input_event inev;
6484 GdkAtom name; 6505 GdkAtom name;
6485 GdkDragAction selected_action; 6506 GdkDragAction selected_action;
6486 6507
@@ -6506,18 +6527,18 @@ drag_drop (GtkWidget *widget, GdkDragContext *context,
6506 name = gdk_drag_get_selection (context); 6527 name = gdk_drag_get_selection (context);
6507 selected_action = gdk_drag_context_get_selected_action (context); 6528 selected_action = gdk_drag_context_get_selected_action (context);
6508 6529
6509 EVENT_INIT (inev.ie); 6530 EVENT_INIT (inev);
6510 6531
6511 inev.ie.kind = DRAG_N_DROP_EVENT; 6532 inev.kind = DRAG_N_DROP_EVENT;
6512 inev.ie.modifiers = 0; 6533 inev.modifiers = 0;
6513 inev.ie.arg = list4 (Qquote, intern (gdk_atom_name (name)), 6534 inev.arg = list4 (Qquote, intern (gdk_atom_name (name)),
6514 make_uint (time), 6535 make_uint (time),
6515 drag_action_to_symbol (selected_action)); 6536 drag_action_to_symbol (selected_action));
6516 inev.ie.timestamp = time; 6537 inev.timestamp = time;
6517 6538
6518 XSETINT (inev.ie.x, x); 6539 XSETINT (inev.x, x);
6519 XSETINT (inev.ie.y, y); 6540 XSETINT (inev.y, y);
6520 XSETFRAME (inev.ie.frame_or_window, f); 6541 XSETFRAME (inev.frame_or_window, f);
6521 6542
6522 evq_enqueue (&inev); 6543 evq_enqueue (&inev);
6523 6544
@@ -6645,12 +6666,12 @@ touch_event_cb (GtkWidget *self, GdkEvent *event, gpointer user_data)
6645 struct pgtk_display_info *dpyinfo; 6666 struct pgtk_display_info *dpyinfo;
6646 struct frame *f; 6667 struct frame *f;
6647 EMACS_INT local_detail; 6668 EMACS_INT local_detail;
6648 union buffered_input_event inev; 6669 struct input_event inev;
6649 struct pgtk_touch_point *touchpoint; 6670 struct pgtk_touch_point *touchpoint;
6650 Lisp_Object arg = Qnil; 6671 Lisp_Object arg = Qnil;
6651 int state; 6672 int state;
6652 6673
6653 EVENT_INIT (inev.ie); 6674 EVENT_INIT (inev);
6654 6675
6655 f = pgtk_any_window_to_frame (gtk_widget_get_window (self)); 6676 f = pgtk_any_window_to_frame (gtk_widget_get_window (self));
6656 eassert (f); 6677 eassert (f);
@@ -6669,12 +6690,12 @@ touch_event_cb (GtkWidget *self, GdkEvent *event, gpointer user_data)
6669 event->touch.x, event->touch.y, 6690 event->touch.x, event->touch.y,
6670 f); 6691 f);
6671 /* Generate the input event. */ 6692 /* Generate the input event. */
6672 inev.ie.kind = TOUCHSCREEN_BEGIN_EVENT; 6693 inev.kind = TOUCHSCREEN_BEGIN_EVENT;
6673 inev.ie.timestamp = event->touch.time; 6694 inev.timestamp = event->touch.time;
6674 XSETFRAME (inev.ie.frame_or_window, f); 6695 XSETFRAME (inev.frame_or_window, f);
6675 XSETINT (inev.ie.x, lrint (event->touch.x)); 6696 XSETINT (inev.x, lrint (event->touch.x));
6676 XSETINT (inev.ie.y, lrint (event->touch.y)); 6697 XSETINT (inev.y, lrint (event->touch.y));
6677 XSETINT (inev.ie.arg, local_detail); 6698 XSETINT (inev.arg, local_detail);
6678 break; 6699 break;
6679 6700
6680 case GDK_TOUCH_UPDATE: 6701 case GDK_TOUCH_UPDATE:
@@ -6691,9 +6712,9 @@ touch_event_cb (GtkWidget *self, GdkEvent *event, gpointer user_data)
6691 /* Construct the input event. */ 6712 /* Construct the input event. */
6692 touchpoint->x = lrint (event->touch.x); 6713 touchpoint->x = lrint (event->touch.x);
6693 touchpoint->y = lrint (event->touch.y); 6714 touchpoint->y = lrint (event->touch.y);
6694 inev.ie.kind = TOUCHSCREEN_UPDATE_EVENT; 6715 inev.kind = TOUCHSCREEN_UPDATE_EVENT;
6695 inev.ie.timestamp = event->touch.time; 6716 inev.timestamp = event->touch.time;
6696 XSETFRAME (inev.ie.frame_or_window, f); 6717 XSETFRAME (inev.frame_or_window, f);
6697 6718
6698 for (touchpoint = dpyinfo->touchpoints; 6719 for (touchpoint = dpyinfo->touchpoints;
6699 touchpoint; touchpoint = touchpoint->next) 6720 touchpoint; touchpoint = touchpoint->next)
@@ -6704,7 +6725,7 @@ touch_event_cb (GtkWidget *self, GdkEvent *event, gpointer user_data)
6704 arg); 6725 arg);
6705 } 6726 }
6706 6727
6707 inev.ie.arg = arg; 6728 inev.arg = arg;
6708 break; 6729 break;
6709 6730
6710 case GDK_TOUCH_END: 6731 case GDK_TOUCH_END:
@@ -6717,14 +6738,14 @@ touch_event_cb (GtkWidget *self, GdkEvent *event, gpointer user_data)
6717 if (state) 6738 if (state)
6718 { 6739 {
6719 /* ... generate a suitable event. */ 6740 /* ... generate a suitable event. */
6720 inev.ie.kind = TOUCHSCREEN_END_EVENT; 6741 inev.kind = TOUCHSCREEN_END_EVENT;
6721 inev.ie.timestamp = event->touch.time; 6742 inev.timestamp = event->touch.time;
6722 inev.ie.modifiers = (event->type != GDK_TOUCH_END); 6743 inev.modifiers = (event->type != GDK_TOUCH_END);
6723 6744
6724 XSETFRAME (inev.ie.frame_or_window, f); 6745 XSETFRAME (inev.frame_or_window, f);
6725 XSETINT (inev.ie.x, lrint (event->touch.x)); 6746 XSETINT (inev.x, lrint (event->touch.x));
6726 XSETINT (inev.ie.y, lrint (event->touch.y)); 6747 XSETINT (inev.y, lrint (event->touch.y));
6727 XSETINT (inev.ie.arg, local_detail); 6748 XSETINT (inev.arg, local_detail);
6728 } 6749 }
6729 break; 6750 break;
6730 6751
@@ -6735,9 +6756,9 @@ touch_event_cb (GtkWidget *self, GdkEvent *event, gpointer user_data)
6735 /* If the above produced a workable event, report the name of the 6756 /* If the above produced a workable event, report the name of the
6736 device that gave rise to it. */ 6757 device that gave rise to it. */
6737 6758
6738 if (inev.ie.kind != NO_EVENT) 6759 if (inev.kind != NO_EVENT)
6739 { 6760 {
6740 inev.ie.device = pgtk_get_device_for_event (dpyinfo, event); 6761 inev.device = pgtk_get_device_for_event (dpyinfo, event);
6741 evq_enqueue (&inev); 6762 evq_enqueue (&inev);
6742 6763
6743 /* Next, save this event for future menu activations, unless it is 6764 /* Next, save this event for future menu activations, unless it is
@@ -6750,7 +6771,7 @@ touch_event_cb (GtkWidget *self, GdkEvent *event, gpointer user_data)
6750 } 6771 }
6751 } 6772 }
6752 6773
6753 return inev.ie.kind != NO_EVENT; 6774 return inev.kind != NO_EVENT;
6754} 6775}
6755 6776
6756 6777
@@ -6761,12 +6782,12 @@ static void
6761pgtk_monitors_changed_cb (GdkScreen *screen, gpointer user_data) 6782pgtk_monitors_changed_cb (GdkScreen *screen, gpointer user_data)
6762{ 6783{
6763 struct terminal *terminal; 6784 struct terminal *terminal;
6764 union buffered_input_event inev; 6785 struct input_event inev;
6765 6786
6766 EVENT_INIT (inev.ie); 6787 EVENT_INIT (inev);
6767 terminal = user_data; 6788 terminal = user_data;
6768 inev.ie.kind = MONITORS_CHANGED_EVENT; 6789 inev.kind = MONITORS_CHANGED_EVENT;
6769 XSETTERMINAL (inev.ie.arg, terminal); 6790 XSETTERMINAL (inev.arg, terminal);
6770 6791
6771 evq_enqueue (&inev); 6792 evq_enqueue (&inev);
6772} 6793}
@@ -6928,7 +6949,6 @@ pgtk_selection_event (GtkWidget *widget, GdkEvent *event,
6928 gpointer user_data) 6949 gpointer user_data)
6929{ 6950{
6930 struct frame *f; 6951 struct frame *f;
6931 union buffered_input_event inev;
6932 6952
6933 if (event->type == GDK_PROPERTY_NOTIFY) 6953 if (event->type == GDK_PROPERTY_NOTIFY)
6934 pgtk_handle_property_notify (&event->property); 6954 pgtk_handle_property_notify (&event->property);
@@ -6939,15 +6959,15 @@ pgtk_selection_event (GtkWidget *widget, GdkEvent *event,
6939 6959
6940 if (f) 6960 if (f)
6941 { 6961 {
6942 EVENT_INIT (inev.ie); 6962 struct selection_input_event sinev = {0};
6943 6963
6944 inev.sie.kind = (event->type == GDK_SELECTION_CLEAR 6964 sinev.kind = (event->type == GDK_SELECTION_CLEAR
6945 ? SELECTION_CLEAR_EVENT 6965 ? SELECTION_CLEAR_EVENT
6946 : SELECTION_REQUEST_EVENT); 6966 : SELECTION_REQUEST_EVENT);
6947 6967
6948 SELECTION_EVENT_DPYINFO (&inev.sie) = FRAME_DISPLAY_INFO (f); 6968 SELECTION_EVENT_DPYINFO (&sinev) = FRAME_DISPLAY_INFO (f);
6949 SELECTION_EVENT_SELECTION (&inev.sie) = event->selection.selection; 6969 SELECTION_EVENT_SELECTION (&sinev) = event->selection.selection;
6950 SELECTION_EVENT_TIME (&inev.sie) = event->selection.time; 6970 SELECTION_EVENT_TIME (&sinev) = event->selection.time;
6951 6971
6952 if (event->type == GDK_SELECTION_REQUEST) 6972 if (event->type == GDK_SELECTION_REQUEST)
6953 { 6973 {
@@ -6957,12 +6977,12 @@ pgtk_selection_event (GtkWidget *widget, GdkEvent *event,
6957 It would make sense to wait for the transfer to 6977 It would make sense to wait for the transfer to
6958 complete. But I don't know if GDK actually does 6978 complete. But I don't know if GDK actually does
6959 that. */ 6979 that. */
6960 SELECTION_EVENT_REQUESTOR (&inev.sie) = event->selection.requestor; 6980 SELECTION_EVENT_REQUESTOR (&sinev) = event->selection.requestor;
6961 SELECTION_EVENT_TARGET (&inev.sie) = event->selection.target; 6981 SELECTION_EVENT_TARGET (&sinev) = event->selection.target;
6962 SELECTION_EVENT_PROPERTY (&inev.sie) = event->selection.property; 6982 SELECTION_EVENT_PROPERTY (&sinev) = event->selection.property;
6963 } 6983 }
6964 6984
6965 evq_enqueue (&inev); 6985 evq_selection_enqueue (&sinev);
6966 return TRUE; 6986 return TRUE;
6967 } 6987 }
6968 } 6988 }
diff --git a/src/xterm.c b/src/xterm.c
index 2ccf267bbd3..aa2116a4b9f 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -18881,7 +18881,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
18881#endif 18881#endif
18882 int *finish, struct input_event *hold_quit) 18882 int *finish, struct input_event *hold_quit)
18883{ 18883{
18884 union buffered_input_event inev; 18884 struct input_event inev;
18885 int count = 0; 18885 int count = 0;
18886 int do_help = 0; 18886 int do_help = 0;
18887#ifdef HAVE_XINPUT2 18887#ifdef HAVE_XINPUT2
@@ -18924,9 +18924,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
18924 18924
18925 *finish = X_EVENT_NORMAL; 18925 *finish = X_EVENT_NORMAL;
18926 18926
18927 EVENT_INIT (inev.ie); 18927 EVENT_INIT (inev);
18928 inev.ie.kind = NO_EVENT; 18928 inev.kind = NO_EVENT;
18929 inev.ie.arg = Qnil; 18929 inev.arg = Qnil;
18930#ifdef HAVE_XINPUT2 18930#ifdef HAVE_XINPUT2
18931 gen_help_device = NULL; 18931 gen_help_device = NULL;
18932#endif 18932#endif
@@ -19257,9 +19257,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
19257 if (!f) 19257 if (!f)
19258 goto OTHER; /* May be a dialog that is to be removed */ 19258 goto OTHER; /* May be a dialog that is to be removed */
19259 19259
19260 inev.ie.kind = DELETE_WINDOW_EVENT; 19260 inev.kind = DELETE_WINDOW_EVENT;
19261 inev.ie.timestamp = event->xclient.data.l[1]; 19261 inev.timestamp = event->xclient.data.l[1];
19262 XSETFRAME (inev.ie.frame_or_window, f); 19262 XSETFRAME (inev.frame_or_window, f);
19263 goto done; 19263 goto done;
19264 } 19264 }
19265 19265
@@ -19413,7 +19413,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
19413 /* Convert the scroll bar event to an input event using 19413 /* Convert the scroll bar event to an input event using
19414 the first window entered into the scroll bar event 19414 the first window entered into the scroll bar event
19415 queue. */ 19415 queue. */
19416 x_scroll_bar_to_input_event (dpyinfo, event, &inev.ie); 19416 x_scroll_bar_to_input_event (dpyinfo, event, &inev);
19417 19417
19418 *finish = X_EVENT_GOTO_OUT; 19418 *finish = X_EVENT_GOTO_OUT;
19419 goto done; 19419 goto done;
@@ -19423,8 +19423,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
19423 /* Convert the horizontal scroll bar event to an input 19423 /* Convert the horizontal scroll bar event to an input
19424 event using the first window entered into the scroll 19424 event using the first window entered into the scroll
19425 bar event queue. */ 19425 bar event queue. */
19426 x_horizontal_scroll_bar_to_input_event (dpyinfo, event, 19426 x_horizontal_scroll_bar_to_input_event (dpyinfo, event, &inev);
19427 &inev.ie);
19428 19427
19429 *finish = X_EVENT_GOTO_OUT; 19428 *finish = X_EVENT_GOTO_OUT;
19430 goto done; 19429 goto done;
@@ -19436,7 +19435,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
19436 { 19435 {
19437 enum xembed_message msg = event->xclient.data.l[1]; 19436 enum xembed_message msg = event->xclient.data.l[1];
19438 if (msg == XEMBED_FOCUS_IN || msg == XEMBED_FOCUS_OUT) 19437 if (msg == XEMBED_FOCUS_IN || msg == XEMBED_FOCUS_OUT)
19439 x_detect_focus_change (dpyinfo, any, event, &inev.ie); 19438 x_detect_focus_change (dpyinfo, any, event, &inev);
19440 19439
19441 *finish = X_EVENT_GOTO_OUT; 19440 *finish = X_EVENT_GOTO_OUT;
19442 goto done; 19441 goto done;
@@ -19475,7 +19474,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
19475 rc = x_coords_from_dnd_message (dpyinfo, (XEvent *) event, 19474 rc = x_coords_from_dnd_message (dpyinfo, (XEvent *) event,
19476 &dx, &dy); 19475 &dx, &dy);
19477 19476
19478 if (x_handle_dnd_message (f, &event->xclient, dpyinfo, &inev.ie, 19477 if (x_handle_dnd_message (f, &event->xclient, dpyinfo, &inev,
19479 rc, dx, dy)) 19478 rc, dx, dy))
19480 *finish = X_EVENT_DROP; 19479 *finish = X_EVENT_DROP;
19481 } 19480 }
@@ -19511,15 +19510,18 @@ handle_one_xevent (struct x_display_info *dpyinfo,
19511 || dpyinfo->motif_drag_atom_time <= eventp->time)) 19510 || dpyinfo->motif_drag_atom_time <= eventp->time))
19512 dpyinfo->motif_drag_atom = None; 19511 dpyinfo->motif_drag_atom = None;
19513 19512
19514 inev.sie.kind = SELECTION_CLEAR_EVENT; 19513 struct selection_input_event sinev = {0};
19515 SELECTION_EVENT_DPYINFO (&inev.sie) = dpyinfo; 19514 sinev.kind = SELECTION_CLEAR_EVENT;
19516 SELECTION_EVENT_SELECTION (&inev.sie) = eventp->selection; 19515 SELECTION_EVENT_DPYINFO (&sinev) = dpyinfo;
19517 SELECTION_EVENT_TIME (&inev.sie) = eventp->time; 19516 SELECTION_EVENT_SELECTION (&sinev) = eventp->selection;
19517 SELECTION_EVENT_TIME (&sinev) = eventp->time;
19518 19518
19519 if (x_use_pending_selection_requests) 19519 if (x_use_pending_selection_requests)
19520 x_push_selection_request (&sinev);
19521 else
19520 { 19522 {
19521 x_push_selection_request (&inev.sie); 19523 kbd_buffer_store_selection_event_hold (&sinev, hold_quit);
19522 EVENT_INIT (inev.ie); 19524 count++;
19523 } 19525 }
19524 } 19526 }
19525 break; 19527 break;
@@ -19535,22 +19537,25 @@ handle_one_xevent (struct x_display_info *dpyinfo,
19535 { 19537 {
19536 const XSelectionRequestEvent *eventp = &event->xselectionrequest; 19538 const XSelectionRequestEvent *eventp = &event->xselectionrequest;
19537 19539
19538 inev.sie.kind = SELECTION_REQUEST_EVENT; 19540 struct selection_input_event sinev;
19539 SELECTION_EVENT_DPYINFO (&inev.sie) = dpyinfo; 19541 sinev.kind = SELECTION_REQUEST_EVENT;
19540 SELECTION_EVENT_REQUESTOR (&inev.sie) = eventp->requestor; 19542 SELECTION_EVENT_DPYINFO (&sinev) = dpyinfo;
19541 SELECTION_EVENT_SELECTION (&inev.sie) = eventp->selection; 19543 SELECTION_EVENT_REQUESTOR (&sinev) = eventp->requestor;
19542 SELECTION_EVENT_TARGET (&inev.sie) = eventp->target; 19544 SELECTION_EVENT_SELECTION (&sinev) = eventp->selection;
19543 SELECTION_EVENT_PROPERTY (&inev.sie) = eventp->property; 19545 SELECTION_EVENT_TARGET (&sinev) = eventp->target;
19544 SELECTION_EVENT_TIME (&inev.sie) = eventp->time; 19546 SELECTION_EVENT_PROPERTY (&sinev) = eventp->property;
19547 SELECTION_EVENT_TIME (&sinev) = eventp->time;
19545 19548
19546 /* If drag-and-drop or another modal dialog/menu is in 19549 /* If drag-and-drop or another modal dialog/menu is in
19547 progress, handle SelectionRequest events immediately, by 19550 progress, handle SelectionRequest events immediately, by
19548 pushing it onto the selection queue. */ 19551 pushing it onto the selection queue. */
19549 19552
19550 if (x_use_pending_selection_requests) 19553 if (x_use_pending_selection_requests)
19554 x_push_selection_request (&sinev);
19555 else
19551 { 19556 {
19552 x_push_selection_request (&inev.sie); 19557 kbd_buffer_store_selection_event_hold (&sinev, hold_quit);
19553 EVENT_INIT (inev.ie); 19558 count++;
19554 } 19559 }
19555 19560
19556 if (x_dnd_waiting_for_finish 19561 if (x_dnd_waiting_for_finish
@@ -19649,7 +19654,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
19649 SET_FRAME_ICONIFIED (f, false); 19654 SET_FRAME_ICONIFIED (f, false);
19650 19655
19651 f->output_data.x->has_been_visible = true; 19656 f->output_data.x->has_been_visible = true;
19652 inev.ie.kind = DEICONIFY_EVENT; 19657 inev.kind = DEICONIFY_EVENT;
19653#if defined USE_GTK && defined HAVE_GTK3 19658#if defined USE_GTK && defined HAVE_GTK3
19654 /* If GTK3 wants to impose some old size here (Bug#24526), 19659 /* If GTK3 wants to impose some old size here (Bug#24526),
19655 tell it that the current size is what we want. */ 19660 tell it that the current size is what we want. */
@@ -19660,7 +19665,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
19660 f->was_invisible = false; 19665 f->was_invisible = false;
19661 } 19666 }
19662#endif 19667#endif
19663 XSETFRAME (inev.ie.frame_or_window, f); 19668 XSETFRAME (inev.frame_or_window, f);
19664 } 19669 }
19665 else if (!not_hidden && !FRAME_ICONIFIED_P (f)) 19670 else if (!not_hidden && !FRAME_ICONIFIED_P (f))
19666 { 19671 {
@@ -19670,8 +19675,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
19670 19675
19671 SET_FRAME_VISIBLE (f, 0); 19676 SET_FRAME_VISIBLE (f, 0);
19672 SET_FRAME_ICONIFIED (f, true); 19677 SET_FRAME_ICONIFIED (f, true);
19673 inev.ie.kind = ICONIFY_EVENT; 19678 inev.kind = ICONIFY_EVENT;
19674 XSETFRAME (inev.ie.frame_or_window, f); 19679 XSETFRAME (inev.frame_or_window, f);
19675 } 19680 }
19676 } 19681 }
19677 19682
@@ -19686,7 +19691,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
19686 set. Handling UnmapNotify also checks for 19691 set. Handling UnmapNotify also checks for
19687 _NET_WM_STATE_HIDDEN, and thus suffers from the same 19692 _NET_WM_STATE_HIDDEN, and thus suffers from the same
19688 problem. */ 19693 problem. */
19689 x_handle_wm_state (f, &inev.ie); 19694 x_handle_wm_state (f, &inev);
19690 19695
19691 if (f && FRAME_X_OUTPUT (f)->alpha_identical_p 19696 if (f && FRAME_X_OUTPUT (f)->alpha_identical_p
19692 && (event->xproperty.atom 19697 && (event->xproperty.atom
@@ -20088,8 +20093,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20088 (f, build_string ("UnmapNotify, visible | iconified")); 20093 (f, build_string ("UnmapNotify, visible | iconified"));
20089 20094
20090 SET_FRAME_ICONIFIED (f, true); 20095 SET_FRAME_ICONIFIED (f, true);
20091 inev.ie.kind = ICONIFY_EVENT; 20096 inev.kind = ICONIFY_EVENT;
20092 XSETFRAME (inev.ie.frame_or_window, f); 20097 XSETFRAME (inev.frame_or_window, f);
20093 } 20098 }
20094 else if (CONSP (frame_size_history)) 20099 else if (CONSP (frame_size_history))
20095 frame_size_history_plain 20100 frame_size_history_plain
@@ -20198,8 +20203,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20198 20203
20199 if ((not_hidden || FRAME_X_EMBEDDED_P (f)) && iconified) 20204 if ((not_hidden || FRAME_X_EMBEDDED_P (f)) && iconified)
20200 { 20205 {
20201 inev.ie.kind = DEICONIFY_EVENT; 20206 inev.kind = DEICONIFY_EVENT;
20202 XSETFRAME (inev.ie.frame_or_window, f); 20207 XSETFRAME (inev.frame_or_window, f);
20203 } 20208 }
20204 } 20209 }
20205 goto OTHER; 20210 goto OTHER;
@@ -20465,18 +20470,17 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20465 orig_keysym = keysym; 20470 orig_keysym = keysym;
20466 20471
20467 /* Common for all keysym input events. */ 20472 /* Common for all keysym input events. */
20468 XSETFRAME (inev.ie.frame_or_window, f); 20473 XSETFRAME (inev.frame_or_window, f);
20469 inev.ie.modifiers 20474 inev.modifiers = x_x_to_emacs_modifiers (dpyinfo, modifiers);
20470 = x_x_to_emacs_modifiers (dpyinfo, modifiers); 20475 inev.timestamp = xkey.time;
20471 inev.ie.timestamp = xkey.time;
20472 20476
20473 /* First deal with keysyms which have defined 20477 /* First deal with keysyms which have defined
20474 translations to characters. */ 20478 translations to characters. */
20475 if (keysym >= 32 && keysym < 128) 20479 if (keysym >= 32 && keysym < 128)
20476 /* Avoid explicitly decoding each ASCII character. */ 20480 /* Avoid explicitly decoding each ASCII character. */
20477 { 20481 {
20478 inev.ie.kind = ASCII_KEYSTROKE_EVENT; 20482 inev.kind = ASCII_KEYSTROKE_EVENT;
20479 inev.ie.code = keysym; 20483 inev.code = keysym;
20480 20484
20481#ifdef HAVE_XINPUT2 20485#ifdef HAVE_XINPUT2
20482 if (event->xkey.time == pending_keystroke_time) 20486 if (event->xkey.time == pending_keystroke_time)
@@ -20485,7 +20489,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20485 dpyinfo->pending_keystroke_source); 20489 dpyinfo->pending_keystroke_source);
20486 20490
20487 if (source) 20491 if (source)
20488 inev.ie.device = source->name; 20492 inev.device = source->name;
20489 } 20493 }
20490#endif 20494#endif
20491 20495
@@ -20496,10 +20500,10 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20496 if (keysym >= 0x01000000 && keysym <= 0x0110FFFF) 20500 if (keysym >= 0x01000000 && keysym <= 0x0110FFFF)
20497 { 20501 {
20498 if (keysym < 0x01000080) 20502 if (keysym < 0x01000080)
20499 inev.ie.kind = ASCII_KEYSTROKE_EVENT; 20503 inev.kind = ASCII_KEYSTROKE_EVENT;
20500 else 20504 else
20501 inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT; 20505 inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
20502 inev.ie.code = keysym & 0xFFFFFF; 20506 inev.code = keysym & 0xFFFFFF;
20503 20507
20504#ifdef HAVE_XINPUT2 20508#ifdef HAVE_XINPUT2
20505 if (event->xkey.time == pending_keystroke_time) 20509 if (event->xkey.time == pending_keystroke_time)
@@ -20508,7 +20512,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20508 dpyinfo->pending_keystroke_source); 20512 dpyinfo->pending_keystroke_source);
20509 20513
20510 if (source) 20514 if (source)
20511 inev.ie.device = source->name; 20515 inev.device = source->name;
20512 } 20516 }
20513#endif 20517#endif
20514 20518
@@ -20522,10 +20526,10 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20522 Qnil), 20526 Qnil),
20523 FIXNATP (c))) 20527 FIXNATP (c)))
20524 { 20528 {
20525 inev.ie.kind = (SINGLE_BYTE_CHAR_P (XFIXNAT (c)) 20529 inev.kind = (SINGLE_BYTE_CHAR_P (XFIXNAT (c))
20526 ? ASCII_KEYSTROKE_EVENT 20530 ? ASCII_KEYSTROKE_EVENT
20527 : MULTIBYTE_CHAR_KEYSTROKE_EVENT); 20531 : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
20528 inev.ie.code = XFIXNAT (c); 20532 inev.code = XFIXNAT (c);
20529 20533
20530#ifdef HAVE_XINPUT2 20534#ifdef HAVE_XINPUT2
20531 if (event->xkey.time == pending_keystroke_time) 20535 if (event->xkey.time == pending_keystroke_time)
@@ -20534,7 +20538,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20534 dpyinfo->pending_keystroke_source); 20538 dpyinfo->pending_keystroke_source);
20535 20539
20536 if (source) 20540 if (source)
20537 inev.ie.device = source->name; 20541 inev.device = source->name;
20538 } 20542 }
20539#endif 20543#endif
20540 20544
@@ -20640,8 +20644,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20640 STORE_KEYSYM_FOR_DEBUG (keysym); 20644 STORE_KEYSYM_FOR_DEBUG (keysym);
20641 /* make_lispy_event will convert this to a symbolic 20645 /* make_lispy_event will convert this to a symbolic
20642 key. */ 20646 key. */
20643 inev.ie.kind = NON_ASCII_KEYSTROKE_EVENT; 20647 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
20644 inev.ie.code = keysym; 20648 inev.code = keysym;
20645 20649
20646#ifdef HAVE_XINPUT2 20650#ifdef HAVE_XINPUT2
20647 if (event->xkey.time == pending_keystroke_time) 20651 if (event->xkey.time == pending_keystroke_time)
@@ -20650,7 +20654,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20650 dpyinfo->pending_keystroke_source); 20654 dpyinfo->pending_keystroke_source);
20651 20655
20652 if (source) 20656 if (source)
20653 inev.ie.device = source->name; 20657 inev.device = source->name;
20654 } 20658 }
20655#endif 20659#endif
20656 20660
@@ -20667,11 +20671,11 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20667 20671
20668 if (nbytes) 20672 if (nbytes)
20669 { 20673 {
20670 inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT; 20674 inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
20671 inev.ie.arg = make_unibyte_string ((char *) copy_bufptr, nbytes); 20675 inev.arg = make_unibyte_string ((char *) copy_bufptr, nbytes);
20672 20676
20673 Fput_text_property (make_fixnum (0), make_fixnum (nbytes), 20677 Fput_text_property (make_fixnum (0), make_fixnum (nbytes),
20674 Qcoding, coding, inev.ie.arg); 20678 Qcoding, coding, inev.arg);
20675 20679
20676#ifdef HAVE_XINPUT2 20680#ifdef HAVE_XINPUT2
20677 if (event->xkey.time == pending_keystroke_time 20681 if (event->xkey.time == pending_keystroke_time
@@ -20685,7 +20689,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20685 dpyinfo->pending_keystroke_source); 20689 dpyinfo->pending_keystroke_source);
20686 20690
20687 if (source) 20691 if (source)
20688 inev.ie.device = source->name; 20692 inev.device = source->name;
20689 } 20693 }
20690#endif 20694#endif
20691 } 20695 }
@@ -20760,7 +20764,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20760 to treat implicit focus correctly. (bug#65919) */ 20764 to treat implicit focus correctly. (bug#65919) */
20761#if defined USE_X_TOOLKIT || (defined USE_GTK && !defined HAVE_GTK3) 20765#if defined USE_X_TOOLKIT || (defined USE_GTK && !defined HAVE_GTK3)
20762 if (x_top_window_to_frame (dpyinfo, event->xcrossing.window)) 20766 if (x_top_window_to_frame (dpyinfo, event->xcrossing.window))
20763 x_detect_focus_change (dpyinfo, any, event, &inev.ie); 20767 x_detect_focus_change (dpyinfo, any, event, &inev);
20764#endif /* defined USE_X_TOOLKIT || (defined USE_GTK && !defined HAVE_GTK3) */ 20768#endif /* defined USE_X_TOOLKIT || (defined USE_GTK && !defined HAVE_GTK3) */
20765 20769
20766#ifdef HAVE_XINPUT2 20770#ifdef HAVE_XINPUT2
@@ -20779,7 +20783,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20779 builds. */ 20783 builds. */
20780#if !defined USE_X_TOOLKIT || (!defined USE_GTK || defined HAVE_GTK3) 20784#if !defined USE_X_TOOLKIT || (!defined USE_GTK || defined HAVE_GTK3)
20781 if (x_top_window_to_frame (dpyinfo, event->xcrossing.window)) 20785 if (x_top_window_to_frame (dpyinfo, event->xcrossing.window))
20782 x_detect_focus_change (dpyinfo, any, event, &inev.ie); 20786 x_detect_focus_change (dpyinfo, any, event, &inev);
20783#endif /* !defined USE_X_TOOLKIT || (!defined USE_GTK || defined HAVE_GTK3) */ 20787#endif /* !defined USE_X_TOOLKIT || (!defined USE_GTK || defined HAVE_GTK3) */
20784 20788
20785 f = any; 20789 f = any;
@@ -20853,12 +20857,12 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20853 SET_FRAME_VISIBLE (f, 1); 20857 SET_FRAME_VISIBLE (f, 1);
20854 SET_FRAME_ICONIFIED (f, false); 20858 SET_FRAME_ICONIFIED (f, false);
20855 f->output_data.x->has_been_visible = true; 20859 f->output_data.x->has_been_visible = true;
20856 inev.ie.kind = DEICONIFY_EVENT; 20860 inev.kind = DEICONIFY_EVENT;
20857 XSETFRAME (inev.ie.frame_or_window, f); 20861 XSETFRAME (inev.frame_or_window, f);
20858 } 20862 }
20859 } 20863 }
20860 20864
20861 x_detect_focus_change (dpyinfo, any, event, &inev.ie); 20865 x_detect_focus_change (dpyinfo, any, event, &inev);
20862 goto OTHER; 20866 goto OTHER;
20863 20867
20864 case LeaveNotify: 20868 case LeaveNotify:
@@ -20870,7 +20874,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20870 to treat implicit focus correctly. */ 20874 to treat implicit focus correctly. */
20871#if defined USE_X_TOOLKIT || (defined USE_GTK && !defined HAVE_GTK3) 20875#if defined USE_X_TOOLKIT || (defined USE_GTK && !defined HAVE_GTK3)
20872 if (x_top_window_to_frame (dpyinfo, event->xcrossing.window)) 20876 if (x_top_window_to_frame (dpyinfo, event->xcrossing.window))
20873 x_detect_focus_change (dpyinfo, any, event, &inev.ie); 20877 x_detect_focus_change (dpyinfo, any, event, &inev);
20874#endif /* defined USE_X_TOOLKIT || (defined USE_GTK && !defined HAVE_GTK3) */ 20878#endif /* defined USE_X_TOOLKIT || (defined USE_GTK && !defined HAVE_GTK3) */
20875 20879
20876#ifdef HAVE_XINPUT2 20880#ifdef HAVE_XINPUT2
@@ -20902,7 +20906,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20902 builds. */ 20906 builds. */
20903#if !defined USE_X_TOOLKIT || (!defined USE_GTK || defined HAVE_GTK3) 20907#if !defined USE_X_TOOLKIT || (!defined USE_GTK || defined HAVE_GTK3)
20904 if (x_top_window_to_frame (dpyinfo, event->xcrossing.window)) 20908 if (x_top_window_to_frame (dpyinfo, event->xcrossing.window))
20905 x_detect_focus_change (dpyinfo, any, event, &inev.ie); 20909 x_detect_focus_change (dpyinfo, any, event, &inev);
20906#endif /* !defined USE_X_TOOLKIT || (!defined USE_GTK || defined HAVE_GTK3) */ 20910#endif /* !defined USE_X_TOOLKIT || (!defined USE_GTK || defined HAVE_GTK3) */
20907 20911
20908#ifdef HAVE_XWIDGETS 20912#ifdef HAVE_XWIDGETS
@@ -21003,7 +21007,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
21003 if (dpyinfo->supports_xi2) 21007 if (dpyinfo->supports_xi2)
21004 goto OTHER; 21008 goto OTHER;
21005#endif 21009#endif
21006 x_detect_focus_change (dpyinfo, any, event, &inev.ie); 21010 x_detect_focus_change (dpyinfo, any, event, &inev);
21007 goto OTHER; 21011 goto OTHER;
21008 21012
21009 case MotionNotify: 21013 case MotionNotify:
@@ -21313,8 +21317,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
21313 && !EQ (window, last_mouse_window) 21317 && !EQ (window, last_mouse_window)
21314 && !EQ (window, selected_window)) 21318 && !EQ (window, selected_window))
21315 { 21319 {
21316 inev.ie.kind = SELECT_WINDOW_EVENT; 21320 inev.kind = SELECT_WINDOW_EVENT;
21317 inev.ie.frame_or_window = window; 21321 inev.frame_or_window = window;
21318 } 21322 }
21319 21323
21320 /* Remember the last window where we saw the mouse. */ 21324 /* Remember the last window where we saw the mouse. */
@@ -21405,13 +21409,13 @@ handle_one_xevent (struct x_display_info *dpyinfo,
21405 hook. */ 21409 hook. */
21406 if (!x_find_monitors_changed_event (dpyinfo)) 21410 if (!x_find_monitors_changed_event (dpyinfo))
21407 { 21411 {
21408 inev.ie.kind = MONITORS_CHANGED_EVENT; 21412 inev.kind = MONITORS_CHANGED_EVENT;
21409 XSETTERMINAL (inev.ie.arg, dpyinfo->terminal); 21413 XSETTERMINAL (inev.arg, dpyinfo->terminal);
21410 21414
21411 /* Store this event now since inev.ie.type could be set to 21415 /* Store this event now since inev.type could be set to
21412 MOVE_FRAME_EVENT later. */ 21416 MOVE_FRAME_EVENT later. */
21413 kbd_buffer_store_event (&inev.ie); 21417 kbd_buffer_store_event (&inev);
21414 inev.ie.kind = NO_EVENT; 21418 inev.kind = NO_EVENT;
21415 } 21419 }
21416 21420
21417 /* Also update the position of the drag-and-drop 21421 /* Also update the position of the drag-and-drop
@@ -21678,8 +21682,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
21678 if (!FRAME_TOOLTIP_P (f) 21682 if (!FRAME_TOOLTIP_P (f)
21679 && (old_left != f->left_pos || old_top != f->top_pos)) 21683 && (old_left != f->left_pos || old_top != f->top_pos))
21680 { 21684 {
21681 inev.ie.kind = MOVE_FRAME_EVENT; 21685 inev.kind = MOVE_FRAME_EVENT;
21682 XSETFRAME (inev.ie.frame_or_window, f); 21686 XSETFRAME (inev.frame_or_window, f);
21683 } 21687 }
21684 } 21688 }
21685 21689
@@ -21745,8 +21749,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
21745 21749
21746 if (!EQ (selected_window, xvw->w) && (event->xbutton.button < 4)) 21750 if (!EQ (selected_window, xvw->w) && (event->xbutton.button < 4))
21747 { 21751 {
21748 inev.ie.kind = SELECT_WINDOW_EVENT; 21752 inev.kind = SELECT_WINDOW_EVENT;
21749 inev.ie.frame_or_window = xvw->w; 21753 inev.frame_or_window = xvw->w;
21750 } 21754 }
21751 21755
21752 *finish = X_EVENT_DROP; 21756 *finish = X_EVENT_DROP;
@@ -22002,14 +22006,14 @@ handle_one_xevent (struct x_display_info *dpyinfo,
22002 && event->xbutton.time > ignore_next_mouse_click_timeout) 22006 && event->xbutton.time > ignore_next_mouse_click_timeout)
22003 { 22007 {
22004 ignore_next_mouse_click_timeout = 0; 22008 ignore_next_mouse_click_timeout = 0;
22005 x_construct_mouse_click (&inev.ie, &event->xbutton, 22009 x_construct_mouse_click (&inev, &event->xbutton,
22006 f, false); 22010 f, false);
22007 } 22011 }
22008 if (event->type == ButtonRelease) 22012 if (event->type == ButtonRelease)
22009 ignore_next_mouse_click_timeout = 0; 22013 ignore_next_mouse_click_timeout = 0;
22010 } 22014 }
22011 else 22015 else
22012 x_construct_mouse_click (&inev.ie, &event->xbutton, f, false); 22016 x_construct_mouse_click (&inev, &event->xbutton, f, false);
22013 22017
22014 *finish = X_EVENT_DROP; 22018 *finish = X_EVENT_DROP;
22015 goto OTHER; 22019 goto OTHER;
@@ -22079,18 +22083,18 @@ handle_one_xevent (struct x_display_info *dpyinfo,
22079 && event->xbutton.time > ignore_next_mouse_click_timeout) 22083 && event->xbutton.time > ignore_next_mouse_click_timeout)
22080 { 22084 {
22081 ignore_next_mouse_click_timeout = 0; 22085 ignore_next_mouse_click_timeout = 0;
22082 x_construct_mouse_click (&inev.ie, &event->xbutton, 22086 x_construct_mouse_click (&inev, &event->xbutton,
22083 f, false); 22087 f, false);
22084 } 22088 }
22085 if (event->type == ButtonRelease) 22089 if (event->type == ButtonRelease)
22086 ignore_next_mouse_click_timeout = 0; 22090 ignore_next_mouse_click_timeout = 0;
22087 } 22091 }
22088 else 22092 else
22089 x_construct_mouse_click (&inev.ie, &event->xbutton, 22093 x_construct_mouse_click (&inev, &event->xbutton,
22090 f, false); 22094 f, false);
22091 22095
22092 if (!NILP (tab_bar_arg)) 22096 if (!NILP (tab_bar_arg))
22093 inev.ie.arg = tab_bar_arg; 22097 inev.arg = tab_bar_arg;
22094 } 22098 }
22095 22099
22096 if (FRAME_X_EMBEDDED_P (f) 22100 if (FRAME_X_EMBEDDED_P (f)
@@ -22109,12 +22113,12 @@ handle_one_xevent (struct x_display_info *dpyinfo,
22109 scroll bars. */ 22113 scroll bars. */
22110 if (bar && event->xbutton.state & ControlMask) 22114 if (bar && event->xbutton.state & ControlMask)
22111 { 22115 {
22112 x_scroll_bar_handle_click (bar, event, &inev.ie, Qnil); 22116 x_scroll_bar_handle_click (bar, event, &inev, Qnil);
22113 *finish = X_EVENT_DROP; 22117 *finish = X_EVENT_DROP;
22114 } 22118 }
22115#else /* not USE_TOOLKIT_SCROLL_BARS */ 22119#else /* not USE_TOOLKIT_SCROLL_BARS */
22116 if (bar) 22120 if (bar)
22117 x_scroll_bar_handle_click (bar, event, &inev.ie, Qnil); 22121 x_scroll_bar_handle_click (bar, event, &inev, Qnil);
22118#endif /* not USE_TOOLKIT_SCROLL_BARS */ 22122#endif /* not USE_TOOLKIT_SCROLL_BARS */
22119 } 22123 }
22120 22124
@@ -22171,8 +22175,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
22171 if (!f->output_data.x->saved_menu_event) 22175 if (!f->output_data.x->saved_menu_event)
22172 f->output_data.x->saved_menu_event = xmalloc (sizeof *event); 22176 f->output_data.x->saved_menu_event = xmalloc (sizeof *event);
22173 *f->output_data.x->saved_menu_event = *event; 22177 *f->output_data.x->saved_menu_event = *event;
22174 inev.ie.kind = MENU_BAR_ACTIVATE_EVENT; 22178 inev.kind = MENU_BAR_ACTIVATE_EVENT;
22175 XSETFRAME (inev.ie.frame_or_window, f); 22179 XSETFRAME (inev.frame_or_window, f);
22176 *finish = X_EVENT_DROP; 22180 *finish = X_EVENT_DROP;
22177#ifdef USE_MOTIF 22181#ifdef USE_MOTIF
22178 } 22182 }
@@ -22323,8 +22327,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
22323 SET_FRAME_VISIBLE (f, 1); 22327 SET_FRAME_VISIBLE (f, 1);
22324 SET_FRAME_ICONIFIED (f, false); 22328 SET_FRAME_ICONIFIED (f, false);
22325 f->output_data.x->has_been_visible = true; 22329 f->output_data.x->has_been_visible = true;
22326 inev.ie.kind = DEICONIFY_EVENT; 22330 inev.kind = DEICONIFY_EVENT;
22327 XSETFRAME (inev.ie.frame_or_window, f); 22331 XSETFRAME (inev.frame_or_window, f);
22328 } 22332 }
22329 } 22333 }
22330 22334
@@ -22874,36 +22878,36 @@ handle_one_xevent (struct x_display_info *dpyinfo,
22874 22878
22875 if (fabs (total_x) > 0 || fabs (total_y) > 0) 22879 if (fabs (total_x) > 0 || fabs (total_y) > 0)
22876 { 22880 {
22877 inev.ie.kind = (fabs (total_y) >= fabs (total_x) 22881 inev.kind = (fabs (total_y) >= fabs (total_x)
22878 ? WHEEL_EVENT : HORIZ_WHEEL_EVENT); 22882 ? WHEEL_EVENT : HORIZ_WHEEL_EVENT);
22879 inev.ie.timestamp = xev->time; 22883 inev.timestamp = xev->time;
22880 22884
22881 XSETINT (inev.ie.x, lrint (real_x)); 22885 XSETINT (inev.x, lrint (real_x));
22882 XSETINT (inev.ie.y, lrint (real_y)); 22886 XSETINT (inev.y, lrint (real_y));
22883 XSETFRAME (inev.ie.frame_or_window, f); 22887 XSETFRAME (inev.frame_or_window, f);
22884 22888
22885 inev.ie.modifiers = (signbit (fabs (total_y) >= fabs (total_x) 22889 inev.modifiers = (signbit (fabs (total_y) >= fabs (total_x)
22886 ? total_y : total_x) 22890 ? total_y : total_x)
22887 ? down_modifier : up_modifier); 22891 ? down_modifier : up_modifier);
22888 inev.ie.modifiers 22892 inev.modifiers
22889 |= x_x_to_emacs_modifiers (dpyinfo, 22893 |= x_x_to_emacs_modifiers (dpyinfo,
22890 xev->mods.effective); 22894 xev->mods.effective);
22891 inev.ie.arg = list3 (Qnil, 22895 inev.arg = list3 (Qnil,
22892 make_float (total_x), 22896 make_float (total_x),
22893 make_float (total_y)); 22897 make_float (total_y));
22894 } 22898 }
22895 else 22899 else
22896 { 22900 {
22897 inev.ie.kind = TOUCH_END_EVENT; 22901 inev.kind = TOUCH_END_EVENT;
22898 inev.ie.timestamp = xev->time; 22902 inev.timestamp = xev->time;
22899 22903
22900 XSETINT (inev.ie.x, lrint (real_x)); 22904 XSETINT (inev.x, lrint (real_x));
22901 XSETINT (inev.ie.y, lrint (real_y)); 22905 XSETINT (inev.y, lrint (real_y));
22902 XSETFRAME (inev.ie.frame_or_window, f); 22906 XSETFRAME (inev.frame_or_window, f);
22903 } 22907 }
22904 22908
22905 if (source && !NILP (source->name)) 22909 if (source && !NILP (source->name))
22906 inev.ie.device = source->name; 22910 inev.device = source->name;
22907 22911
22908 if (!other_valuators_found) 22912 if (!other_valuators_found)
22909 goto XI_OTHER; 22913 goto XI_OTHER;
@@ -23244,11 +23248,11 @@ handle_one_xevent (struct x_display_info *dpyinfo,
23244 && !EQ (window, last_mouse_window) 23248 && !EQ (window, last_mouse_window)
23245 && !EQ (window, selected_window)) 23249 && !EQ (window, selected_window))
23246 { 23250 {
23247 inev.ie.kind = SELECT_WINDOW_EVENT; 23251 inev.kind = SELECT_WINDOW_EVENT;
23248 inev.ie.frame_or_window = window; 23252 inev.frame_or_window = window;
23249 23253
23250 if (source) 23254 if (source)
23251 inev.ie.device = source->name; 23255 inev.device = source->name;
23252 } 23256 }
23253 23257
23254 /* Remember the last window where we saw the mouse. */ 23258 /* Remember the last window where we saw the mouse. */
@@ -23636,11 +23640,11 @@ handle_one_xevent (struct x_display_info *dpyinfo,
23636 23640
23637 if (!EQ (selected_window, xvw->w) && (xev->detail < 4)) 23641 if (!EQ (selected_window, xvw->w) && (xev->detail < 4))
23638 { 23642 {
23639 inev.ie.kind = SELECT_WINDOW_EVENT; 23643 inev.kind = SELECT_WINDOW_EVENT;
23640 inev.ie.frame_or_window = xvw->w; 23644 inev.frame_or_window = xvw->w;
23641 23645
23642 if (source) 23646 if (source)
23643 inev.ie.device = source->name; 23647 inev.device = source->name;
23644 } 23648 }
23645 23649
23646 *finish = X_EVENT_DROP; 23650 *finish = X_EVENT_DROP;
@@ -23739,24 +23743,24 @@ handle_one_xevent (struct x_display_info *dpyinfo,
23739 &real_x, &real_y); 23743 &real_x, &real_y);
23740 23744
23741 if (xev->detail <= 5) 23745 if (xev->detail <= 5)
23742 inev.ie.kind = WHEEL_EVENT; 23746 inev.kind = WHEEL_EVENT;
23743 else 23747 else
23744 inev.ie.kind = HORIZ_WHEEL_EVENT; 23748 inev.kind = HORIZ_WHEEL_EVENT;
23745 23749
23746 if (source) 23750 if (source)
23747 inev.ie.device = source->name; 23751 inev.device = source->name;
23748 23752
23749 inev.ie.timestamp = xev->time; 23753 inev.timestamp = xev->time;
23750 23754
23751 XSETINT (inev.ie.x, real_x); 23755 XSETINT (inev.x, real_x);
23752 XSETINT (inev.ie.y, real_y); 23756 XSETINT (inev.y, real_y);
23753 XSETFRAME (inev.ie.frame_or_window, f); 23757 XSETFRAME (inev.frame_or_window, f);
23754 23758
23755 inev.ie.modifiers 23759 inev.modifiers
23756 |= x_x_to_emacs_modifiers (dpyinfo, 23760 |= x_x_to_emacs_modifiers (dpyinfo,
23757 xev->mods.effective); 23761 xev->mods.effective);
23758 23762
23759 inev.ie.modifiers |= xev->detail % 2 ? down_modifier : up_modifier; 23763 inev.modifiers |= xev->detail % 2 ? down_modifier : up_modifier;
23760 } 23764 }
23761 23765
23762 *finish = X_EVENT_DROP; 23766 *finish = X_EVENT_DROP;
@@ -23777,24 +23781,24 @@ handle_one_xevent (struct x_display_info *dpyinfo,
23777 if (xev->evtype == XI_ButtonRelease) 23781 if (xev->evtype == XI_ButtonRelease)
23778 { 23782 {
23779 if (xev->detail <= 5) 23783 if (xev->detail <= 5)
23780 inev.ie.kind = WHEEL_EVENT; 23784 inev.kind = WHEEL_EVENT;
23781 else 23785 else
23782 inev.ie.kind = HORIZ_WHEEL_EVENT; 23786 inev.kind = HORIZ_WHEEL_EVENT;
23783 23787
23784 if (source) 23788 if (source)
23785 inev.ie.device = source->name; 23789 inev.device = source->name;
23786 23790
23787 inev.ie.timestamp = xev->time; 23791 inev.timestamp = xev->time;
23788 23792
23789 XSETINT (inev.ie.x, lrint (xev->event_x)); 23793 XSETINT (inev.x, lrint (xev->event_x));
23790 XSETINT (inev.ie.y, lrint (xev->event_y)); 23794 XSETINT (inev.y, lrint (xev->event_y));
23791 XSETFRAME (inev.ie.frame_or_window, f); 23795 XSETFRAME (inev.frame_or_window, f);
23792 23796
23793 inev.ie.modifiers 23797 inev.modifiers
23794 |= x_x_to_emacs_modifiers (dpyinfo, 23798 |= x_x_to_emacs_modifiers (dpyinfo,
23795 xev->mods.effective); 23799 xev->mods.effective);
23796 23800
23797 inev.ie.modifiers |= xev->detail % 2 ? down_modifier : up_modifier; 23801 inev.modifiers |= xev->detail % 2 ? down_modifier : up_modifier;
23798 } 23802 }
23799 23803
23800 goto XI_OTHER; 23804 goto XI_OTHER;
@@ -23863,16 +23867,16 @@ handle_one_xevent (struct x_display_info *dpyinfo,
23863 && xev->time > ignore_next_mouse_click_timeout) 23867 && xev->time > ignore_next_mouse_click_timeout)
23864 { 23868 {
23865 ignore_next_mouse_click_timeout = 0; 23869 ignore_next_mouse_click_timeout = 0;
23866 x_construct_mouse_click (&inev.ie, &bv, f, true); 23870 x_construct_mouse_click (&inev, &bv, f, true);
23867 } 23871 }
23868 if (xev->evtype == XI_ButtonRelease) 23872 if (xev->evtype == XI_ButtonRelease)
23869 ignore_next_mouse_click_timeout = 0; 23873 ignore_next_mouse_click_timeout = 0;
23870 } 23874 }
23871 else 23875 else
23872 x_construct_mouse_click (&inev.ie, &bv, f, true); 23876 x_construct_mouse_click (&inev, &bv, f, true);
23873 23877
23874 if (!NILP (tab_bar_arg)) 23878 if (!NILP (tab_bar_arg))
23875 inev.ie.arg = tab_bar_arg; 23879 inev.arg = tab_bar_arg;
23876 } 23880 }
23877 23881
23878 if (FRAME_X_EMBEDDED_P (f) 23882 if (FRAME_X_EMBEDDED_P (f)
@@ -23888,14 +23892,14 @@ handle_one_xevent (struct x_display_info *dpyinfo,
23888 23892
23889#ifndef USE_TOOLKIT_SCROLL_BARS 23893#ifndef USE_TOOLKIT_SCROLL_BARS
23890 if (bar) 23894 if (bar)
23891 x_scroll_bar_handle_click (bar, (XEvent *) &bv, &inev.ie, 23895 x_scroll_bar_handle_click (bar, (XEvent *) &bv, &inev,
23892 source ? source->name : Qnil); 23896 source ? source->name : Qnil);
23893#else 23897#else
23894 /* Make the "Ctrl-Mouse-2 splits window" work for toolkit 23898 /* Make the "Ctrl-Mouse-2 splits window" work for toolkit
23895 scroll bars. */ 23899 scroll bars. */
23896 if (bar && xev->mods.effective & ControlMask) 23900 if (bar && xev->mods.effective & ControlMask)
23897 { 23901 {
23898 x_scroll_bar_handle_click (bar, (XEvent *) &bv, &inev.ie, 23902 x_scroll_bar_handle_click (bar, (XEvent *) &bv, &inev,
23899 source ? source->name : Qnil); 23903 source ? source->name : Qnil);
23900 *finish = X_EVENT_DROP; 23904 *finish = X_EVENT_DROP;
23901 } 23905 }
@@ -23921,8 +23925,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
23921 device->grab &= ~(1 << xev->detail); 23925 device->grab &= ~(1 << xev->detail);
23922 } 23926 }
23923 23927
23924 if (source && inev.ie.kind != NO_EVENT) 23928 if (source && inev.kind != NO_EVENT)
23925 inev.ie.device = source->name; 23929 inev.device = source->name;
23926 23930
23927 if (f) 23931 if (f)
23928 f->mouse_moved = false; 23932 f->mouse_moved = false;
@@ -24243,8 +24247,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
24243 *finish = X_EVENT_DROP; 24247 *finish = X_EVENT_DROP;
24244#endif /* USE_GTK */ 24248#endif /* USE_GTK */
24245 24249
24246 XSETFRAME (inev.ie.frame_or_window, f); 24250 XSETFRAME (inev.frame_or_window, f);
24247 inev.ie.timestamp = xev->time; 24251 inev.timestamp = xev->time;
24248 24252
24249#ifdef HAVE_X_I18N 24253#ifdef HAVE_X_I18N
24250 if (FRAME_XIC (f)) 24254 if (FRAME_XIC (f))
@@ -24356,7 +24360,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
24356 } 24360 }
24357 } 24361 }
24358 24362
24359 inev.ie.modifiers = x_x_to_emacs_modifiers (dpyinfo, state); 24363 inev.modifiers = x_x_to_emacs_modifiers (dpyinfo, state);
24360 24364
24361#ifdef XK_F1 24365#ifdef XK_F1
24362 if (x_dnd_in_progress 24366 if (x_dnd_in_progress
@@ -24394,11 +24398,11 @@ handle_one_xevent (struct x_display_info *dpyinfo,
24394 if (keysym >= 32 && keysym < 128) 24398 if (keysym >= 32 && keysym < 128)
24395 /* Avoid explicitly decoding each ASCII character. */ 24399 /* Avoid explicitly decoding each ASCII character. */
24396 { 24400 {
24397 inev.ie.kind = ASCII_KEYSTROKE_EVENT; 24401 inev.kind = ASCII_KEYSTROKE_EVENT;
24398 inev.ie.code = keysym; 24402 inev.code = keysym;
24399 24403
24400 if (source) 24404 if (source)
24401 inev.ie.device = source->name; 24405 inev.device = source->name;
24402 24406
24403 goto xi_done_keysym; 24407 goto xi_done_keysym;
24404 } 24408 }
@@ -24407,14 +24411,14 @@ handle_one_xevent (struct x_display_info *dpyinfo,
24407 if (keysym >= 0x01000000 && keysym <= 0x0110FFFF) 24411 if (keysym >= 0x01000000 && keysym <= 0x0110FFFF)
24408 { 24412 {
24409 if (keysym < 0x01000080) 24413 if (keysym < 0x01000080)
24410 inev.ie.kind = ASCII_KEYSTROKE_EVENT; 24414 inev.kind = ASCII_KEYSTROKE_EVENT;
24411 else 24415 else
24412 inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT; 24416 inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
24413 24417
24414 if (source) 24418 if (source)
24415 inev.ie.device = source->name; 24419 inev.device = source->name;
24416 24420
24417 inev.ie.code = keysym & 0xFFFFFF; 24421 inev.code = keysym & 0xFFFFFF;
24418 goto xi_done_keysym; 24422 goto xi_done_keysym;
24419 } 24423 }
24420 24424
@@ -24425,13 +24429,13 @@ handle_one_xevent (struct x_display_info *dpyinfo,
24425 Qnil), 24429 Qnil),
24426 FIXNATP (c))) 24430 FIXNATP (c)))
24427 { 24431 {
24428 inev.ie.kind = (SINGLE_BYTE_CHAR_P (XFIXNAT (c)) 24432 inev.kind = (SINGLE_BYTE_CHAR_P (XFIXNAT (c))
24429 ? ASCII_KEYSTROKE_EVENT 24433 ? ASCII_KEYSTROKE_EVENT
24430 : MULTIBYTE_CHAR_KEYSTROKE_EVENT); 24434 : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
24431 inev.ie.code = XFIXNAT (c); 24435 inev.code = XFIXNAT (c);
24432 24436
24433 if (source) 24437 if (source)
24434 inev.ie.device = source->name; 24438 inev.device = source->name;
24435 24439
24436 goto xi_done_keysym; 24440 goto xi_done_keysym;
24437 } 24441 }
@@ -24535,11 +24539,11 @@ handle_one_xevent (struct x_display_info *dpyinfo,
24535 STORE_KEYSYM_FOR_DEBUG (keysym); 24539 STORE_KEYSYM_FOR_DEBUG (keysym);
24536 /* make_lispy_event will convert this to a symbolic 24540 /* make_lispy_event will convert this to a symbolic
24537 key. */ 24541 key. */
24538 inev.ie.kind = NON_ASCII_KEYSTROKE_EVENT; 24542 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
24539 inev.ie.code = keysym; 24543 inev.code = keysym;
24540 24544
24541 if (source) 24545 if (source)
24542 inev.ie.device = source->name; 24546 inev.device = source->name;
24543 24547
24544 goto xi_done_keysym; 24548 goto xi_done_keysym;
24545 } 24549 }
@@ -24551,14 +24555,14 @@ handle_one_xevent (struct x_display_info *dpyinfo,
24551 24555
24552 if (nbytes) 24556 if (nbytes)
24553 { 24557 {
24554 inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT; 24558 inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
24555 inev.ie.arg = make_unibyte_string (copy_bufptr, nbytes); 24559 inev.arg = make_unibyte_string (copy_bufptr, nbytes);
24556 24560
24557 Fput_text_property (make_fixnum (0), make_fixnum (nbytes), 24561 Fput_text_property (make_fixnum (0), make_fixnum (nbytes),
24558 Qcoding, coding, inev.ie.arg); 24562 Qcoding, coding, inev.arg);
24559 24563
24560 if (source) 24564 if (source)
24561 inev.ie.device = source->name; 24565 inev.device = source->name;
24562 } 24566 }
24563 goto xi_done_keysym; 24567 goto xi_done_keysym;
24564 } 24568 }
@@ -24912,15 +24916,15 @@ handle_one_xevent (struct x_display_info *dpyinfo,
24912 xev->event_x, 24916 xev->event_x,
24913 xev->event_y, f); 24917 xev->event_y, f);
24914 24918
24915 inev.ie.kind = TOUCHSCREEN_BEGIN_EVENT; 24919 inev.kind = TOUCHSCREEN_BEGIN_EVENT;
24916 inev.ie.timestamp = xev->time; 24920 inev.timestamp = xev->time;
24917 XSETFRAME (inev.ie.frame_or_window, f); 24921 XSETFRAME (inev.frame_or_window, f);
24918 XSETINT (inev.ie.x, lrint (xev->event_x)); 24922 XSETINT (inev.x, lrint (xev->event_x));
24919 XSETINT (inev.ie.y, lrint (xev->event_y)); 24923 XSETINT (inev.y, lrint (xev->event_y));
24920 XSETINT (inev.ie.arg, local_detail); 24924 XSETINT (inev.arg, local_detail);
24921 24925
24922 if (source) 24926 if (source)
24923 inev.ie.device = source->name; 24927 inev.device = source->name;
24924 } 24928 }
24925 24929
24926 x_uncatch_errors (); 24930 x_uncatch_errors ();
@@ -25026,9 +25030,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
25026 25030
25027 if (f && device->direct_p) 25031 if (f && device->direct_p)
25028 { 25032 {
25029 inev.ie.kind = TOUCHSCREEN_UPDATE_EVENT; 25033 inev.kind = TOUCHSCREEN_UPDATE_EVENT;
25030 inev.ie.timestamp = xev->time; 25034 inev.timestamp = xev->time;
25031 XSETFRAME (inev.ie.frame_or_window, f); 25035 XSETFRAME (inev.frame_or_window, f);
25032 25036
25033 for (touchpoint = device->touchpoints; 25037 for (touchpoint = device->touchpoints;
25034 touchpoint; touchpoint = touchpoint->next) 25038 touchpoint; touchpoint = touchpoint->next)
@@ -25040,9 +25044,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
25040 } 25044 }
25041 25045
25042 if (source) 25046 if (source)
25043 inev.ie.device = source->name; 25047 inev.device = source->name;
25044 25048
25045 inev.ie.arg = arg; 25049 inev.arg = arg;
25046 } 25050 }
25047 25051
25048 goto XI_OTHER; 25052 goto XI_OTHER;
@@ -25077,17 +25081,17 @@ handle_one_xevent (struct x_display_info *dpyinfo,
25077 25081
25078 if (f && device->direct_p) 25082 if (f && device->direct_p)
25079 { 25083 {
25080 inev.ie.kind = TOUCHSCREEN_END_EVENT; 25084 inev.kind = TOUCHSCREEN_END_EVENT;
25081 inev.ie.timestamp = xev->time; 25085 inev.timestamp = xev->time;
25082 inev.ie.modifiers = state != 2; 25086 inev.modifiers = state != 2;
25083 25087
25084 XSETFRAME (inev.ie.frame_or_window, f); 25088 XSETFRAME (inev.frame_or_window, f);
25085 XSETINT (inev.ie.x, lrint (xev->event_x)); 25089 XSETINT (inev.x, lrint (xev->event_x));
25086 XSETINT (inev.ie.y, lrint (xev->event_y)); 25090 XSETINT (inev.y, lrint (xev->event_y));
25087 XSETINT (inev.ie.arg, local_detail); 25091 XSETINT (inev.arg, local_detail);
25088 25092
25089 if (source) 25093 if (source)
25090 inev.ie.device = source->name; 25094 inev.device = source->name;
25091 } 25095 }
25092 } 25096 }
25093 25097
@@ -25156,20 +25160,20 @@ handle_one_xevent (struct x_display_info *dpyinfo,
25156 if (pev->event == FRAME_X_WINDOW (any)) 25160 if (pev->event == FRAME_X_WINDOW (any))
25157 xi_compute_root_window_offset_pinch (any, pev); 25161 xi_compute_root_window_offset_pinch (any, pev);
25158 25162
25159 inev.ie.kind = PINCH_EVENT; 25163 inev.kind = PINCH_EVENT;
25160 inev.ie.modifiers 25164 inev.modifiers
25161 = x_x_to_emacs_modifiers (dpyinfo, pev->mods.effective); 25165 = x_x_to_emacs_modifiers (dpyinfo, pev->mods.effective);
25162 25166
25163 XSETINT (inev.ie.x, lrint (pev->event_x)); 25167 XSETINT (inev.x, lrint (pev->event_x));
25164 XSETINT (inev.ie.y, lrint (pev->event_y)); 25168 XSETINT (inev.y, lrint (pev->event_y));
25165 XSETFRAME (inev.ie.frame_or_window, any); 25169 XSETFRAME (inev.frame_or_window, any);
25166 inev.ie.arg = list4 (make_float (pev->delta_x), 25170 inev.arg = list4 (make_float (pev->delta_x),
25167 make_float (pev->delta_y), 25171 make_float (pev->delta_y),
25168 make_float (pev->scale), 25172 make_float (pev->scale),
25169 make_float (pev->delta_angle)); 25173 make_float (pev->delta_angle));
25170 25174
25171 if (source) 25175 if (source)
25172 inev.ie.device = source->name; 25176 inev.device = source->name;
25173 } 25177 }
25174 25178
25175 /* Once again GTK seems to crash when confronted by 25179 /* Once again GTK seems to crash when confronted by
@@ -25524,26 +25528,26 @@ handle_one_xevent (struct x_display_info *dpyinfo,
25524 already an undelivered event on the queue. */ 25528 already an undelivered event on the queue. */
25525 goto OTHER; 25529 goto OTHER;
25526 25530
25527 inev.ie.kind = MONITORS_CHANGED_EVENT; 25531 inev.kind = MONITORS_CHANGED_EVENT;
25528 inev.ie.timestamp = timestamp; 25532 inev.timestamp = timestamp;
25529 XSETTERMINAL (inev.ie.arg, dpyinfo->terminal); 25533 XSETTERMINAL (inev.arg, dpyinfo->terminal);
25530 25534
25531 /* Also don't do anything if the monitor configuration 25535 /* Also don't do anything if the monitor configuration
25532 didn't really change. */ 25536 didn't really change. */
25533 25537
25534 current_monitors 25538 current_monitors
25535 = Fx_display_monitor_attributes_list (inev.ie.arg); 25539 = Fx_display_monitor_attributes_list (inev.arg);
25536 25540
25537 if (!NILP (Fequal (current_monitors, 25541 if (!NILP (Fequal (current_monitors,
25538 dpyinfo->last_monitor_attributes_list))) 25542 dpyinfo->last_monitor_attributes_list)))
25539 inev.ie.kind = NO_EVENT; 25543 inev.kind = NO_EVENT;
25540 25544
25541 dpyinfo->last_monitor_attributes_list = current_monitors; 25545 dpyinfo->last_monitor_attributes_list = current_monitors;
25542 25546
25543 if (x_dnd_in_progress && x_dnd_update_tooltip) 25547 if (x_dnd_in_progress && x_dnd_update_tooltip)
25544 x_dnd_monitors = current_monitors; 25548 x_dnd_monitors = current_monitors;
25545 25549
25546 if (inev.ie.kind != NO_EVENT) 25550 if (inev.kind != NO_EVENT)
25547 x_dnd_update_tooltip_now (); 25551 x_dnd_update_tooltip_now ();
25548 } 25552 }
25549#endif 25553#endif
@@ -25591,9 +25595,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
25591 } 25595 }
25592 25596
25593 done: 25597 done:
25594 if (inev.ie.kind != NO_EVENT) 25598 if (inev.kind != NO_EVENT)
25595 { 25599 {
25596 kbd_buffer_store_buffered_event (&inev, hold_quit); 25600 kbd_buffer_store_event_hold (&inev, hold_quit);
25597 count++; 25601 count++;
25598 } 25602 }
25599 25603