From 36f96c351a97bb2d068e8541167d94803dde6ab8 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 15 Jun 2022 14:46:21 +0800 Subject: [PATCH] Handle coordinates for the old KDE drop protocol * 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 | 21 +++++++++++++++++++++ src/xterm.h | 7 +++++++ 2 files changed, 28 insertions(+) diff --git a/src/xterm.c b/src/xterm.c index bf8a33f70c9..b1e7ee578a1 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -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; } diff --git a/src/xterm.h b/src/xterm.h index 82b4308041a..d710069fadd 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -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 -- 2.39.2