summaryrefslogtreecommitdiff
path: root/src/xterm.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-09-10 18:49:53 +0800
committerPo Lu <luangruo@yahoo.com>2022-09-10 18:51:13 +0800
commit2a1608a960b56ce991050c5f87c1261e330aeca2 (patch)
treec49276a40441e397b73dd207ddfefe8bba7e0651 /src/xterm.c
parent433fc8bebfef40130bf62f17e5349560b62e566e (diff)
downloademacs-2a1608a960b56ce991050c5f87c1261e330aeca2.tar.gz
Fix compliance with the XDND specification when dropping on a proxy
* src/xterm.c (x_dnd_send_enter, x_dnd_send_position) (x_dnd_send_leave, x_dnd_send_drop, x_dnd_do_drop): New parameter `toplevel'. Use it as the window in sent client messages. (x_dnd_cancel_dnd_early, x_dnd_cleanup_drag_and_drop) (x_dnd_process_quit, x_dnd_update_state, handle_one_xevent) (x_connection_closed): Give the right toplevel to the client message sending functions.
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c79
1 files changed, 51 insertions, 28 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 6043e2ab09a..4ac42a91384 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -4455,7 +4455,8 @@ x_dnd_get_window_proto (struct x_display_info *dpyinfo, Window wdesc)
}
static void
-x_dnd_send_enter (struct frame *f, Window target, int supported)
+x_dnd_send_enter (struct frame *f, Window target, Window toplevel,
+ int supported)
{
struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
int i;
@@ -4464,7 +4465,7 @@ x_dnd_send_enter (struct frame *f, Window target, int supported)
msg.xclient.type = ClientMessage;
msg.xclient.message_type = dpyinfo->Xatom_XdndEnter;
msg.xclient.format = 32;
- msg.xclient.window = target;
+ msg.xclient.window = toplevel;
msg.xclient.data.l[0] = FRAME_X_WINDOW (f);
msg.xclient.data.l[1] = (((unsigned int) min (X_DND_SUPPORTED_VERSION,
supported) << 24)
@@ -4492,10 +4493,10 @@ x_dnd_send_enter (struct frame *f, Window target, int supported)
}
static void
-x_dnd_send_position (struct frame *f, Window target, int supported,
- unsigned short root_x, unsigned short root_y,
- Time timestamp, Atom action, int button,
- unsigned state)
+x_dnd_send_position (struct frame *f, Window target, Window toplevel,
+ int supported, unsigned short root_x,
+ unsigned short root_y, Time timestamp, Atom action,
+ int button, unsigned state)
{
struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
XEvent msg;
@@ -4503,7 +4504,7 @@ x_dnd_send_position (struct frame *f, Window target, int supported,
msg.xclient.type = ClientMessage;
msg.xclient.message_type = dpyinfo->Xatom_XdndPosition;
msg.xclient.format = 32;
- msg.xclient.window = target;
+ msg.xclient.window = toplevel;
msg.xclient.data.l[0] = FRAME_X_WINDOW (f);
msg.xclient.data.l[1] = 0;
@@ -4567,7 +4568,7 @@ x_dnd_send_position (struct frame *f, Window target, int supported,
}
static void
-x_dnd_send_leave (struct frame *f, Window target)
+x_dnd_send_leave (struct frame *f, Window target, Window toplevel)
{
struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
XEvent msg;
@@ -4575,7 +4576,7 @@ x_dnd_send_leave (struct frame *f, Window target)
msg.xclient.type = ClientMessage;
msg.xclient.message_type = dpyinfo->Xatom_XdndLeave;
msg.xclient.format = 32;
- msg.xclient.window = target;
+ msg.xclient.window = toplevel;
msg.xclient.data.l[0] = FRAME_X_WINDOW (f);
msg.xclient.data.l[1] = 0;
msg.xclient.data.l[2] = 0;
@@ -4591,15 +4592,15 @@ x_dnd_send_leave (struct frame *f, Window target)
}
static bool
-x_dnd_send_drop (struct frame *f, Window target, Time timestamp,
- int supported)
+x_dnd_send_drop (struct frame *f, Window target, Window toplevel,
+ Time timestamp, int supported)
{
struct x_display_info *dpyinfo;
XEvent msg;
if (x_dnd_action == None)
{
- x_dnd_send_leave (f, target);
+ x_dnd_send_leave (f, target, toplevel);
return false;
}
@@ -4608,7 +4609,7 @@ x_dnd_send_drop (struct frame *f, Window target, Time timestamp,
msg.xclient.type = ClientMessage;
msg.xclient.message_type = dpyinfo->Xatom_XdndDrop;
msg.xclient.format = 32;
- msg.xclient.window = target;
+ msg.xclient.window = toplevel;
msg.xclient.data.l[0] = FRAME_X_WINDOW (f);
msg.xclient.data.l[1] = 0;
msg.xclient.data.l[2] = 0;
@@ -4625,10 +4626,10 @@ x_dnd_send_drop (struct frame *f, Window target, Time timestamp,
}
static bool
-x_dnd_do_drop (Window target, int supported)
+x_dnd_do_drop (Window target, Window toplevel, int supported)
{
if (x_dnd_waiting_for_status_window != target)
- return x_dnd_send_drop (x_dnd_frame, target,
+ return x_dnd_send_drop (x_dnd_frame, target, toplevel,
x_dnd_selection_timestamp, supported);
x_dnd_need_send_drop = true;
@@ -4733,7 +4734,8 @@ x_dnd_cancel_dnd_early (void)
if (x_dnd_last_seen_window != None
&& x_dnd_last_protocol_version != -1)
x_dnd_send_leave (x_dnd_frame,
- x_dnd_last_seen_window);
+ x_dnd_last_seen_window,
+ x_dnd_last_seen_toplevel);
else if (x_dnd_last_seen_window != None
&& !XM_DRAG_STYLE_IS_DROP_ONLY (x_dnd_last_motif_style)
&& x_dnd_last_motif_style != XM_DRAG_STYLE_NONE
@@ -4791,7 +4793,8 @@ x_dnd_cleanup_drag_and_drop (void *frame)
if (x_dnd_last_seen_window != None
&& x_dnd_last_protocol_version != -1)
x_dnd_send_leave (x_dnd_frame,
- x_dnd_last_seen_window);
+ x_dnd_last_seen_window,
+ x_dnd_last_seen_toplevel);
else if (x_dnd_last_seen_window != None
&& !XM_DRAG_STYLE_IS_DROP_ONLY (x_dnd_last_motif_style)
&& x_dnd_last_motif_style != XM_DRAG_STYLE_NONE
@@ -11912,7 +11915,8 @@ x_dnd_process_quit (struct frame *f, Time timestamp)
{
if (x_dnd_last_seen_window != None
&& x_dnd_last_protocol_version != -1)
- x_dnd_send_leave (f, x_dnd_last_seen_window);
+ x_dnd_send_leave (f, x_dnd_last_seen_window,
+ x_dnd_last_seen_toplevel);
else if (x_dnd_last_seen_window != None
&& !XM_DRAG_STYLE_IS_DROP_ONLY (x_dnd_last_motif_style)
&& x_dnd_last_motif_style != XM_DRAG_STYLE_NONE
@@ -17107,7 +17111,8 @@ x_dnd_update_state (struct x_display_info *dpyinfo, Time timestamp)
if (x_dnd_last_seen_window != None
&& x_dnd_last_protocol_version != -1
&& x_dnd_last_seen_window != FRAME_OUTER_WINDOW (x_dnd_frame))
- x_dnd_send_leave (x_dnd_frame, x_dnd_last_seen_window);
+ x_dnd_send_leave (x_dnd_frame, x_dnd_last_seen_window,
+ x_dnd_last_seen_toplevel);
else if (x_dnd_last_seen_window != None
&& XM_DRAG_STYLE_IS_DYNAMIC (x_dnd_last_motif_style)
&& !x_dnd_disable_motif_drag
@@ -17147,7 +17152,8 @@ x_dnd_update_state (struct x_display_info *dpyinfo, Time timestamp)
if (x_dnd_last_seen_window != None
&& x_dnd_last_protocol_version != -1
&& x_dnd_last_seen_window != FRAME_OUTER_WINDOW (x_dnd_frame))
- x_dnd_send_leave (x_dnd_frame, x_dnd_last_seen_window);
+ x_dnd_send_leave (x_dnd_frame, x_dnd_last_seen_window,
+ x_dnd_last_seen_toplevel);
else if (x_dnd_last_seen_window != None
&& XM_DRAG_STYLE_IS_DYNAMIC (x_dnd_last_motif_style)
&& !x_dnd_disable_motif_drag
@@ -17175,7 +17181,7 @@ x_dnd_update_state (struct x_display_info *dpyinfo, Time timestamp)
x_dnd_last_window_is_frame = was_frame;
if (target != None && x_dnd_last_protocol_version != -1)
- x_dnd_send_enter (x_dnd_frame, target,
+ x_dnd_send_enter (x_dnd_frame, target, x_dnd_last_seen_toplevel,
x_dnd_last_protocol_version);
else if (target != None && XM_DRAG_STYLE_IS_DYNAMIC (x_dnd_last_motif_style)
&& !x_dnd_disable_motif_drag)
@@ -17201,6 +17207,7 @@ x_dnd_update_state (struct x_display_info *dpyinfo, Time timestamp)
x_dnd_note_self_position (dpyinfo, target, root_x, root_y);
else if (x_dnd_last_protocol_version != -1 && target != None)
x_dnd_send_position (x_dnd_frame, target,
+ x_dnd_last_seen_toplevel,
x_dnd_last_protocol_version,
root_x, root_y,
x_dnd_selection_timestamp,
@@ -17244,7 +17251,8 @@ x_dnd_update_state (struct x_display_info *dpyinfo, Time timestamp)
if (x_dnd_last_seen_window != None
&& x_dnd_last_protocol_version != -1)
x_dnd_send_leave (x_dnd_frame,
- x_dnd_last_seen_window);
+ x_dnd_last_seen_window,
+ x_dnd_last_seen_toplevel);
else if (x_dnd_last_seen_window != None
&& !XM_DRAG_STYLE_IS_DROP_ONLY (x_dnd_last_motif_style)
&& x_dnd_last_motif_style != XM_DRAG_STYLE_NONE
@@ -17756,7 +17764,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
x_dnd_waiting_for_finish
= x_dnd_send_drop (x_dnd_finish_frame,
- target, x_dnd_selection_timestamp,
+ target,
+ x_dnd_last_seen_toplevel,
+ x_dnd_selection_timestamp,
x_dnd_send_drop_proto);
}
}
@@ -19624,7 +19634,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
if (x_dnd_last_seen_window != None
&& x_dnd_last_protocol_version != -1
&& x_dnd_last_seen_window != FRAME_OUTER_WINDOW (x_dnd_frame))
- x_dnd_send_leave (x_dnd_frame, x_dnd_last_seen_window);
+ x_dnd_send_leave (x_dnd_frame, x_dnd_last_seen_window,
+ x_dnd_last_seen_toplevel);
else if (x_dnd_last_seen_window != None
&& XM_DRAG_STYLE_IS_DYNAMIC (x_dnd_last_motif_style)
&& !x_dnd_disable_motif_drag
@@ -19664,7 +19675,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
if (x_dnd_last_seen_window != None
&& x_dnd_last_protocol_version != -1
&& x_dnd_last_seen_window != FRAME_OUTER_WINDOW (x_dnd_frame))
- x_dnd_send_leave (x_dnd_frame, x_dnd_last_seen_window);
+ x_dnd_send_leave (x_dnd_frame, x_dnd_last_seen_window,
+ x_dnd_last_seen_toplevel);
else if (x_dnd_last_seen_window != None
&& XM_DRAG_STYLE_IS_DYNAMIC (x_dnd_last_motif_style)
&& x_dnd_disable_motif_drag
@@ -19714,6 +19726,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
if (target != None && x_dnd_last_protocol_version != -1)
x_dnd_send_enter (x_dnd_frame, target,
+ x_dnd_last_seen_toplevel,
x_dnd_last_protocol_version);
else if (target != None && XM_DRAG_STYLE_IS_DYNAMIC (x_dnd_last_motif_style)
&& !x_dnd_disable_motif_drag)
@@ -19741,6 +19754,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
event->xbutton.y_root);
else if (x_dnd_last_protocol_version != -1 && target != None)
x_dnd_send_position (x_dnd_frame, target,
+ x_dnd_last_seen_toplevel,
x_dnd_last_protocol_version,
event->xmotion.x_root,
event->xmotion.y_root,
@@ -20302,6 +20316,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
else if (x_dnd_last_protocol_version != -1)
x_dnd_send_position (x_dnd_frame,
x_dnd_last_seen_window,
+ x_dnd_last_seen_toplevel,
x_dnd_last_protocol_version,
event->xbutton.x_root,
event->xbutton.y_root,
@@ -20354,6 +20369,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
x_dnd_waiting_for_finish
= x_dnd_do_drop (x_dnd_last_seen_window,
+ x_dnd_last_seen_toplevel,
x_dnd_last_protocol_version);
x_dnd_finish_display = dpyinfo->display;
}
@@ -21480,7 +21496,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
if (x_dnd_last_seen_window != None
&& x_dnd_last_protocol_version != -1
&& x_dnd_last_seen_window != FRAME_OUTER_WINDOW (x_dnd_frame))
- x_dnd_send_leave (x_dnd_frame, x_dnd_last_seen_window);
+ x_dnd_send_leave (x_dnd_frame, x_dnd_last_seen_window,
+ x_dnd_last_seen_toplevel);
else if (x_dnd_last_seen_window != None
&& XM_DRAG_STYLE_IS_DYNAMIC (x_dnd_last_motif_style)
&& !x_dnd_disable_motif_drag
@@ -21520,7 +21537,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
if (x_dnd_last_seen_window != None
&& x_dnd_last_protocol_version != -1
&& x_dnd_last_seen_window != FRAME_OUTER_WINDOW (x_dnd_frame))
- x_dnd_send_leave (x_dnd_frame, x_dnd_last_seen_window);
+ x_dnd_send_leave (x_dnd_frame, x_dnd_last_seen_window,
+ x_dnd_last_seen_toplevel);
else if (x_dnd_last_seen_window != None
&& XM_DRAG_STYLE_IS_DYNAMIC (x_dnd_last_motif_style)
&& !x_dnd_disable_motif_drag
@@ -21572,6 +21590,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
if (target != None && x_dnd_last_protocol_version != -1)
x_dnd_send_enter (x_dnd_frame, target,
+ x_dnd_last_seen_toplevel,
x_dnd_last_protocol_version);
else if (target != None && XM_DRAG_STYLE_IS_DYNAMIC (x_dnd_last_motif_style)
&& !x_dnd_disable_motif_drag)
@@ -21602,6 +21621,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
dnd_state = xi_convert_event_state (xev);
x_dnd_send_position (x_dnd_frame, target,
+ x_dnd_last_seen_toplevel,
x_dnd_last_protocol_version,
lrint (xev->root_x),
lrint (xev->root_y),
@@ -21820,6 +21840,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
else
x_dnd_send_position (x_dnd_frame,
x_dnd_last_seen_window,
+ x_dnd_last_seen_toplevel,
x_dnd_last_protocol_version,
lrint (xev->root_x),
lrint (xev->root_y),
@@ -21876,6 +21897,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
x_dnd_waiting_for_finish
= x_dnd_do_drop (x_dnd_last_seen_window,
+ x_dnd_last_seen_toplevel,
x_dnd_last_protocol_version);
x_dnd_finish_display = dpyinfo->display;
}
@@ -24817,7 +24839,8 @@ x_connection_closed (Display *dpy, const char *error_message, bool ioerror)
if (x_dnd_last_seen_window != None
&& x_dnd_last_protocol_version != -1)
x_dnd_send_leave (x_dnd_frame,
- x_dnd_last_seen_window);
+ x_dnd_last_seen_window,
+ x_dnd_last_seen_toplevel);
else if (x_dnd_last_seen_window != None
&& !XM_DRAG_STYLE_IS_DROP_ONLY (x_dnd_last_motif_style)
&& x_dnd_last_motif_style != XM_DRAG_STYLE_NONE