]> git.eshelyaron.com Git - emacs.git/commitdiff
Initialize time inside motion and button events converted from XI events
authorPo Lu <luangruo@yahoo.com>
Fri, 4 Mar 2022 10:33:46 +0000 (18:33 +0800)
committerPo Lu <luangruo@yahoo.com>
Fri, 4 Mar 2022 10:34:57 +0000 (18:34 +0800)
* src/xterm.c (handle_one_xevent): Make sure time is initialized
in artificial events passed to functions that use it.

src/xterm.c

index 2c6289a9cb1114d16e3f48b4adfb1b3f40fa1049..764638d5b8c997037ede04a760dcd146c1c6810d 100644 (file)
@@ -11507,9 +11507,11 @@ handle_one_xevent (struct x_display_info *dpyinfo,
       {
        if (!dpyinfo->supports_xi2)
          goto OTHER;
+
        if (event->xgeneric.extension != dpyinfo->xi2_opcode)
          /* Not an XI2 event. */
          goto OTHER;
+
        bool must_free_data = false;
        XIEvent *xi_event = (XIEvent *) event->xcookie.data;
        /* Sometimes the event is already claimed by GTK, which
@@ -11521,16 +11523,6 @@ handle_one_xevent (struct x_display_info *dpyinfo,
          }
 
        XIDeviceEvent *xev = (XIDeviceEvent *) xi_event;
-#ifdef HAVE_XINPUT2_1
-       XIValuatorState *states;
-       double *values;
-       bool found_valuator = false;
-#endif
-
-       /* A fake XMotionEvent for x_note_mouse_movement. */
-       XMotionEvent ev;
-       /* A fake XButtonEvent for x_construct_mouse_click. */
-       XButtonEvent bv;
 
        if (!xi_event)
          {
@@ -11588,11 +11580,14 @@ handle_one_xevent (struct x_display_info *dpyinfo,
          case XI_Enter:
            {
              XIEnterEvent *enter = (XIEnterEvent *) xi_event;
+             XMotionEvent ev;
 
              any = x_top_window_to_frame (dpyinfo, enter->event);
              ev.x = lrint (enter->event_x);
              ev.y = lrint (enter->event_y);
              ev.window = enter->event;
+             ev.time = enter->time;
+
              x_display_set_last_user_time (dpyinfo, xi_event->time);
 
 #ifdef USE_MOTIF
@@ -11668,10 +11663,15 @@ handle_one_xevent (struct x_display_info *dpyinfo,
          case XI_Leave:
            {
              XILeaveEvent *leave = (XILeaveEvent *) xi_event;
+#ifdef USE_GTK
+             XMotionEvent ev;
 
              ev.x = lrint (leave->event_x);
              ev.y = lrint (leave->event_y);
              ev.window = leave->event;
+             ev.time = leave->time;
+#endif
+
              any = x_top_window_to_frame (dpyinfo, leave->event);
 
              /* This allows us to catch LeaveNotify events generated by
@@ -11784,6 +11784,13 @@ handle_one_xevent (struct x_display_info *dpyinfo,
          case XI_Motion:
            {
              struct xi_device_t *device;
+#ifdef HAVE_XINPUT2_1
+             XIValuatorState *states;
+             double *values;
+             bool found_valuator = false;
+#endif
+             /* A fake XMotionEvent for x_note_mouse_movement. */
+             XMotionEvent ev;
 
 #ifdef HAVE_XINPUT2_1
              states = &xev->valuators;
@@ -12122,6 +12129,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 #ifdef HAVE_XWIDGETS
              struct xwidget_view *xvw;
 #endif
+             /* A fake XButtonEvent for x_construct_mouse_click. */
+             XButtonEvent bv;
 
 #ifdef USE_MOTIF
 #ifdef USE_TOOLKIT_SCROLL_BARS