]> git.eshelyaron.com Git - emacs.git/commitdiff
Handle coordinates for the old KDE drop protocol
authorPo Lu <luangruo@yahoo.com>
Wed, 15 Jun 2022 06:46:21 +0000 (14:46 +0800)
committerPo Lu <luangruo@yahoo.com>
Wed, 15 Jun 2022 06:47:11 +0000 (14:47 +0800)
* src/xterm.c (x_atom_refs): Add DndProtocol and _DND_PROTOCOL.
(x_coords_from_dnd_message): Handle the old KDE protocol.
* src/xterm.h (struct x_display_info): New atoms.

src/xterm.c
src/xterm.h

index bf8a33f70c93b9210f08b9176abd6b08e7a0595a..b1e7ee578a1624df6c778f8fd3ad6119b834607a 100644 (file)
@@ -1008,6 +1008,9 @@ static const struct x_atom_ref x_atom_refs[] =
                    Xatom_MOTIF_DRAG_RECEIVER_INFO)
     ATOM_REFS_INIT ("XmTRANSFER_SUCCESS", Xatom_XmTRANSFER_SUCCESS)
     ATOM_REFS_INIT ("XmTRANSFER_FAILURE", Xatom_XmTRANSFER_FAILURE)
+    /* Old OffiX (a.k.a. old KDE) drop protocol support.  */
+    ATOM_REFS_INIT ("DndProtocol", Xatom_DndProtocol)
+    ATOM_REFS_INIT ("_DND_PROTOCOL", Xatom_DND_PROTOCOL)
   };
 
 enum
@@ -15893,6 +15896,7 @@ x_coords_from_dnd_message (struct x_display_info *dpyinfo,
   xm_drag_motion_reply dreply;
   xm_drop_start_message smsg;
   xm_drop_start_reply reply;
+  unsigned long kde_data;
 
   if (event->type != ClientMessage)
     return false;
@@ -15943,6 +15947,23 @@ x_coords_from_dnd_message (struct x_display_info *dpyinfo,
        }
     }
 
+  if (((event->xclient.message_type
+       == dpyinfo->Xatom_DndProtocol)
+       || (event->xclient.message_type
+          == dpyinfo->Xatom_DND_PROTOCOL))
+      && event->xclient.format == 32
+      /* Check that the version of the old KDE protocol is new
+        enough to include coordinates.  */
+      && event->xclient.data.l[4])
+    {
+      kde_data = (unsigned long) event->xclient.data.l[3];
+
+      *x_out = (kde_data & 0xffff);
+      *y_out = (kde_data >> 16 & 0xffff);
+
+      return true;
+    }
+
   return false;
 }
 
index 82b4308041a05661ad12cff628b40e5fef4043f0..d710069fadd1fa854a4b57679bf7768738963b80 100644 (file)
@@ -443,12 +443,19 @@ struct x_display_info
   /* Atom used to determine whether or not the screen is composited.  */
   Atom Xatom_NET_WM_CM_Sn;
 
+  /* Atoms used by the Motif drag and drop protocols.  */
   Atom Xatom_MOTIF_WM_HINTS, Xatom_MOTIF_DRAG_WINDOW,
     Xatom_MOTIF_DRAG_TARGETS, Xatom_MOTIF_DRAG_AND_DROP_MESSAGE,
     Xatom_MOTIF_DRAG_INITIATOR_INFO, Xatom_MOTIF_DRAG_RECEIVER_INFO;
 
+  /* Special selections used by the Motif drop protocol to indicate
+     success or failure.  */
   Atom Xatom_XmTRANSFER_SUCCESS, Xatom_XmTRANSFER_FAILURE;
 
+  /* Atoms used by both versions of the OffiX DND protocol (the "old
+     KDE" protocol in x-dnd.el). */
+  Atom Xatom_DndProtocol, Xatom_DND_PROTOCOL;
+
   /* The frame (if any) which has the X window that has keyboard focus.
      Zero if none.  This is examined by Ffocus_frame in xfns.c.  Note
      that a mere EnterNotify event can set this; if you need to know the