in `x_dnd_action' upon completion of a drop. */
static Atom x_dnd_wanted_action;
+/* The set of optional actions available to a Motif drop target
+ computed at the start of the drag-and-drop operation. */
+static uint8_t x_dnd_motif_operations;
+
+/* The preferred optional action out of that set. Only takes effect
+ if `x_dnd_action' is XdndAsk. */
+static uint8_t x_dnd_first_motif_operation;
+
/* Array of selection targets available to the drop target. */
static Atom *x_dnd_targets = NULL;
return XM_DRAG_MOVE;
else if (action == dpyinfo->Xatom_XdndActionLink)
return XM_DRAG_LINK;
+ else if (action == dpyinfo->Xatom_XdndActionAsk)
+ return x_dnd_first_motif_operation;
return XM_DRAG_NOOP;
}
+static uint8_t
+xm_operations_from_actions (struct x_display_info *dpyinfo,
+ Atom *ask_actions, int n_ask_actions)
+{
+ int i;
+ uint8_t flags;
+
+ flags = 0;
+
+ for (i = 0; i < n_ask_actions; ++i)
+ {
+ if (ask_actions[i] == dpyinfo->Xatom_XdndActionCopy)
+ flags |= XM_DRAG_COPY;
+ else if (ask_actions[i] == dpyinfo->Xatom_XdndActionMove)
+ flags |= XM_DRAG_MOVE;
+ else if (ask_actions[i] == dpyinfo->Xatom_XdndActionLink)
+ flags |= XM_DRAG_LINK;
+ }
+
+ return flags;
+}
+
static int
xm_read_targets_table_header (uint8_t *bytes, ptrdiff_t length,
xm_targets_table_header *header_return,
mmsg.byteorder = XM_BYTE_ORDER_CUR_FIRST;
mmsg.side_effects = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
x_dnd_wanted_action),
- XM_DROP_SITE_NONE, XM_DRAG_NOOP,
+ XM_DROP_SITE_NONE, x_dnd_motif_operations,
XM_DROP_ACTION_DROP_CANCEL);
mmsg.timestamp = dmsg->timestamp;
mmsg.x = 65535;
dmsg.side_effects
= XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
x_dnd_wanted_action),
- XM_DROP_SITE_VALID,
- xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
- x_dnd_wanted_action),
+ XM_DROP_SITE_VALID, x_dnd_motif_operations,
XM_DROP_ACTION_DROP_CANCEL);
dmsg.x = 0;
dmsg.y = 0;
else
x_dnd_selection_timestamp = XFIXNUM (ltimestamp);
+ x_dnd_motif_operations
+ = xm_side_effect_from_action (FRAME_DISPLAY_INFO (f), xaction);
+
+ x_dnd_first_motif_operation = XM_DRAG_NOOP;
+
if (n_ask_actions)
{
+ x_dnd_motif_operations
+ = xm_operations_from_actions (FRAME_DISPLAY_INFO (f),
+ ask_action_list,
+ n_ask_actions);
+ x_dnd_first_motif_operation
+ = xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
+ ask_action_list[0]);
+
ask_actions = NULL;
end = 0;
count = SPECPDL_INDEX ();
dmsg.side_effects
= XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
x_dnd_wanted_action),
- XM_DROP_SITE_VALID,
- xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
- x_dnd_wanted_action),
+ XM_DROP_SITE_VALID, x_dnd_motif_operations,
XM_DROP_ACTION_DROP_CANCEL);
dmsg.x = 0;
dmsg.y = 0;
dmsg.side_effects
= XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
x_dnd_wanted_action),
- XM_DROP_SITE_VALID,
- xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
- x_dnd_wanted_action),
+ XM_DROP_SITE_VALID, x_dnd_motif_operations,
XM_DROP_ACTION_DROP_CANCEL);
dmsg.x = 0;
dmsg.y = 0;
dmsg.side_effects
= XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
x_dnd_wanted_action),
- XM_DROP_SITE_VALID,
- xm_side_effect_from_action (dpyinfo,
- x_dnd_wanted_action),
+ XM_DROP_SITE_VALID, x_dnd_motif_operations,
(!x_dnd_xm_use_help
? XM_DROP_ACTION_DROP
: XM_DROP_ACTION_DROP_HELP));
dsmsg.side_effects
= XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
x_dnd_wanted_action),
- XM_DROP_SITE_VALID,
- xm_side_effect_from_action (dpyinfo,
- x_dnd_wanted_action),
+ XM_DROP_SITE_VALID, x_dnd_motif_operations,
XM_DROP_ACTION_DROP_CANCEL);
dsmsg.x = 0;
dsmsg.y = 0;
dmsg.byteorder = XM_BYTE_ORDER_CUR_FIRST;
dmsg.side_effects = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
x_dnd_wanted_action),
- XM_DROP_SITE_NONE, XM_DRAG_NOOP,
+ XM_DROP_SITE_NONE, x_dnd_motif_operations,
XM_DROP_ACTION_DROP_CANCEL);
dmsg.timestamp = event->xmotion.time;
dmsg.x = event->xmotion.x_root;
dmsg.byteorder = XM_BYTE_ORDER_CUR_FIRST;
dmsg.side_effects = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
x_dnd_wanted_action),
- XM_DROP_SITE_VALID,
- xm_side_effect_from_action (dpyinfo,
- x_dnd_wanted_action),
+ XM_DROP_SITE_VALID, x_dnd_motif_operations,
(!x_dnd_xm_use_help
? XM_DROP_ACTION_DROP
: XM_DROP_ACTION_DROP_HELP));
dmsg.side_effects
= XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
x_dnd_wanted_action),
- XM_DROP_SITE_VALID,
- xm_side_effect_from_action (dpyinfo,
- x_dnd_wanted_action),
+ XM_DROP_SITE_VALID, x_dnd_motif_operations,
(!x_dnd_xm_use_help
? XM_DROP_ACTION_DROP
: XM_DROP_ACTION_DROP_HELP));
dmsg.side_effects
= XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
x_dnd_wanted_action),
- XM_DROP_SITE_NONE, XM_DRAG_NOOP,
+ XM_DROP_SITE_NONE, x_dnd_motif_operations,
XM_DROP_ACTION_DROP_CANCEL);
dmsg.timestamp = xev->time;
dmsg.x = lrint (xev->root_x);
dmsg.side_effects
= XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
x_dnd_wanted_action),
- XM_DROP_SITE_VALID,
- xm_side_effect_from_action (dpyinfo,
- x_dnd_wanted_action),
+ XM_DROP_SITE_VALID, x_dnd_motif_operations,
(!x_dnd_xm_use_help
? XM_DROP_ACTION_DROP
: XM_DROP_ACTION_DROP_HELP));
dmsg.side_effects
= XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
x_dnd_wanted_action),
- XM_DROP_SITE_VALID,
- xm_side_effect_from_action (dpyinfo,
- x_dnd_wanted_action),
+ XM_DROP_SITE_VALID, x_dnd_motif_operations,
(!x_dnd_xm_use_help
? XM_DROP_ACTION_DROP
: XM_DROP_ACTION_DROP_HELP));
dmsg.side_effects
= XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
x_dnd_wanted_action),
- XM_DROP_SITE_VALID,
- xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
- x_dnd_wanted_action),
+ XM_DROP_SITE_VALID, x_dnd_motif_operations,
XM_DROP_ACTION_DROP_CANCEL);
dmsg.x = 0;
dmsg.y = 0;