]> git.eshelyaron.com Git - emacs.git/commitdiff
Handle coordinate extraction for more event types
authorPo Lu <luangruo@yahoo.com>
Tue, 14 Jun 2022 02:12:48 +0000 (10:12 +0800)
committerPo Lu <luangruo@yahoo.com>
Tue, 14 Jun 2022 02:12:48 +0000 (10:12 +0800)
* src/xterm.c (xm_read_drag_motion_message): New function.
(x_coords_from_dnd_message): Handle XM_DRAG_REASON_DRAG_MOTION.

src/xterm.c

index d79871e0210b019fe938ceb44a221a318e79235c..443c589e3b9af1bd6d7b11572044eac49e8c48a3 100644 (file)
@@ -2395,6 +2395,30 @@ xm_read_drag_receiver_info (struct x_display_info *dpyinfo,
   return !rc;
 }
 
+static void
+xm_read_drag_motion_message (const XEvent *msg,
+                            xm_drag_motion_message *dmsg)
+{
+  const uint8_t *data;
+
+  data = (const uint8_t *) &msg->xclient.data.b[0];
+
+  dmsg->reason = *(data++);
+  dmsg->byteorder = *(data++);
+  dmsg->side_effects = *(uint16_t *) data;
+  dmsg->timestamp = *(uint32_t *) (data + 2);
+  dmsg->x = *(uint16_t *) (data + 6);
+  dmsg->y = *(uint16_t *) (data + 8);
+
+  if (dmsg->byteorder != XM_BYTE_ORDER_CUR_FIRST)
+    {
+      SWAPCARD16 (dmsg->side_effects);
+      SWAPCARD32 (dmsg->timestamp);
+      SWAPCARD16 (dmsg->x);
+      SWAPCARD16 (dmsg->y);
+    }
+}
+
 static void
 x_dnd_send_xm_leave_for_drop (struct x_display_info *dpyinfo,
                              struct frame *f, Window wdesc,
@@ -15769,6 +15793,8 @@ static bool
 x_coords_from_dnd_message (struct x_display_info *dpyinfo,
                           XEvent *event, int *x_out, int *y_out)
 {
+  xm_drag_motion_message dmsg;
+
   if (event->type != ClientMessage)
     return false;
 
@@ -15784,6 +15810,21 @@ x_coords_from_dnd_message (struct x_display_info *dpyinfo,
       return true;
     }
 
+  if ((event->xclient.message_type
+       == dpyinfo->Xatom_MOTIF_DRAG_AND_DROP_MESSAGE)
+      && event->xclient.format == 8)
+    {
+      if (event->xclient.data.b[0]
+         == XM_DRAG_REASON_DRAG_MOTION)
+       {
+         xm_read_drag_motion_message (event, &dmsg);
+         *x_out = dmsg.x;
+         *y_out = dmsg.y;
+
+         return true;
+       }
+    }
+
   return false;
 }