aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-05-26 21:00:17 +0800
committerPo Lu2022-05-26 21:00:35 +0800
commite490b80a105b82870e5571eaa3cfa5bc3ad936b0 (patch)
tree3c6d9a439405148837343f1312625aeaa21dbb28 /src
parentef6059cb8325dfa2467bb83b2fd2b2d376e360c2 (diff)
downloademacs-e490b80a105b82870e5571eaa3cfa5bc3ad936b0.tar.gz
emacs-e490b80a105b82870e5571eaa3cfa5bc3ad936b0.zip
Handle alternate actions for Motif drop targets
* src/xterm.c (xm_side_effect_from_action): Handle `XdndActionAsk'. (xm_operations_from_actions): New function. (xm_send_top_level_leave_message, x_dnd_cleanup_drag_and_drop) (x_dnd_update_state, handle_one_xevent, x_connection_closed): Use those actions when building a side effect. (x_dnd_begin_drag_and_drop): Keep track of the set of alternative drag-and-drop actions.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c91
1 files changed, 58 insertions, 33 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 9826f2fbd85..d949439d188 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1119,6 +1119,14 @@ static Atom x_dnd_action;
1119 in `x_dnd_action' upon completion of a drop. */ 1119 in `x_dnd_action' upon completion of a drop. */
1120static Atom x_dnd_wanted_action; 1120static Atom x_dnd_wanted_action;
1121 1121
1122/* The set of optional actions available to a Motif drop target
1123 computed at the start of the drag-and-drop operation. */
1124static uint8_t x_dnd_motif_operations;
1125
1126/* The preferred optional action out of that set. Only takes effect
1127 if `x_dnd_action' is XdndAsk. */
1128static uint8_t x_dnd_first_motif_operation;
1129
1122/* Array of selection targets available to the drop target. */ 1130/* Array of selection targets available to the drop target. */
1123static Atom *x_dnd_targets = NULL; 1131static Atom *x_dnd_targets = NULL;
1124 1132
@@ -1405,10 +1413,34 @@ xm_side_effect_from_action (struct x_display_info *dpyinfo, Atom action)
1405 return XM_DRAG_MOVE; 1413 return XM_DRAG_MOVE;
1406 else if (action == dpyinfo->Xatom_XdndActionLink) 1414 else if (action == dpyinfo->Xatom_XdndActionLink)
1407 return XM_DRAG_LINK; 1415 return XM_DRAG_LINK;
1416 else if (action == dpyinfo->Xatom_XdndActionAsk)
1417 return x_dnd_first_motif_operation;
1408 1418
1409 return XM_DRAG_NOOP; 1419 return XM_DRAG_NOOP;
1410} 1420}
1411 1421
1422static uint8_t
1423xm_operations_from_actions (struct x_display_info *dpyinfo,
1424 Atom *ask_actions, int n_ask_actions)
1425{
1426 int i;
1427 uint8_t flags;
1428
1429 flags = 0;
1430
1431 for (i = 0; i < n_ask_actions; ++i)
1432 {
1433 if (ask_actions[i] == dpyinfo->Xatom_XdndActionCopy)
1434 flags |= XM_DRAG_COPY;
1435 else if (ask_actions[i] == dpyinfo->Xatom_XdndActionMove)
1436 flags |= XM_DRAG_MOVE;
1437 else if (ask_actions[i] == dpyinfo->Xatom_XdndActionLink)
1438 flags |= XM_DRAG_LINK;
1439 }
1440
1441 return flags;
1442}
1443
1412static int 1444static int
1413xm_read_targets_table_header (uint8_t *bytes, ptrdiff_t length, 1445xm_read_targets_table_header (uint8_t *bytes, ptrdiff_t length,
1414 xm_targets_table_header *header_return, 1446 xm_targets_table_header *header_return,
@@ -2038,7 +2070,7 @@ xm_send_top_level_leave_message (struct x_display_info *dpyinfo, Window source,
2038 mmsg.byteorder = XM_BYTE_ORDER_CUR_FIRST; 2070 mmsg.byteorder = XM_BYTE_ORDER_CUR_FIRST;
2039 mmsg.side_effects = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo, 2071 mmsg.side_effects = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
2040 x_dnd_wanted_action), 2072 x_dnd_wanted_action),
2041 XM_DROP_SITE_NONE, XM_DRAG_NOOP, 2073 XM_DROP_SITE_NONE, x_dnd_motif_operations,
2042 XM_DROP_ACTION_DROP_CANCEL); 2074 XM_DROP_ACTION_DROP_CANCEL);
2043 mmsg.timestamp = dmsg->timestamp; 2075 mmsg.timestamp = dmsg->timestamp;
2044 mmsg.x = 65535; 2076 mmsg.x = 65535;
@@ -3904,9 +3936,7 @@ x_dnd_cleanup_drag_and_drop (void *frame)
3904 dmsg.side_effects 3936 dmsg.side_effects
3905 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (FRAME_DISPLAY_INFO (f), 3937 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
3906 x_dnd_wanted_action), 3938 x_dnd_wanted_action),
3907 XM_DROP_SITE_VALID, 3939 XM_DROP_SITE_VALID, x_dnd_motif_operations,
3908 xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
3909 x_dnd_wanted_action),
3910 XM_DROP_ACTION_DROP_CANCEL); 3940 XM_DROP_ACTION_DROP_CANCEL);
3911 dmsg.x = 0; 3941 dmsg.x = 0;
3912 dmsg.y = 0; 3942 dmsg.y = 0;
@@ -10361,8 +10391,21 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
10361 else 10391 else
10362 x_dnd_selection_timestamp = XFIXNUM (ltimestamp); 10392 x_dnd_selection_timestamp = XFIXNUM (ltimestamp);
10363 10393
10394 x_dnd_motif_operations
10395 = xm_side_effect_from_action (FRAME_DISPLAY_INFO (f), xaction);
10396
10397 x_dnd_first_motif_operation = XM_DRAG_NOOP;
10398
10364 if (n_ask_actions) 10399 if (n_ask_actions)
10365 { 10400 {
10401 x_dnd_motif_operations
10402 = xm_operations_from_actions (FRAME_DISPLAY_INFO (f),
10403 ask_action_list,
10404 n_ask_actions);
10405 x_dnd_first_motif_operation
10406 = xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
10407 ask_action_list[0]);
10408
10366 ask_actions = NULL; 10409 ask_actions = NULL;
10367 end = 0; 10410 end = 0;
10368 count = SPECPDL_INDEX (); 10411 count = SPECPDL_INDEX ();
@@ -10609,9 +10652,7 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
10609 dmsg.side_effects 10652 dmsg.side_effects
10610 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (FRAME_DISPLAY_INFO (f), 10653 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
10611 x_dnd_wanted_action), 10654 x_dnd_wanted_action),
10612 XM_DROP_SITE_VALID, 10655 XM_DROP_SITE_VALID, x_dnd_motif_operations,
10613 xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
10614 x_dnd_wanted_action),
10615 XM_DROP_ACTION_DROP_CANCEL); 10656 XM_DROP_ACTION_DROP_CANCEL);
10616 dmsg.x = 0; 10657 dmsg.x = 0;
10617 dmsg.y = 0; 10658 dmsg.y = 0;
@@ -10683,9 +10724,7 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
10683 dmsg.side_effects 10724 dmsg.side_effects
10684 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (FRAME_DISPLAY_INFO (f), 10725 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
10685 x_dnd_wanted_action), 10726 x_dnd_wanted_action),
10686 XM_DROP_SITE_VALID, 10727 XM_DROP_SITE_VALID, x_dnd_motif_operations,
10687 xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
10688 x_dnd_wanted_action),
10689 XM_DROP_ACTION_DROP_CANCEL); 10728 XM_DROP_ACTION_DROP_CANCEL);
10690 dmsg.x = 0; 10729 dmsg.x = 0;
10691 dmsg.y = 0; 10730 dmsg.y = 0;
@@ -14643,9 +14682,7 @@ x_dnd_update_state (struct x_display_info *dpyinfo, Time timestamp)
14643 dmsg.side_effects 14682 dmsg.side_effects
14644 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo, 14683 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
14645 x_dnd_wanted_action), 14684 x_dnd_wanted_action),
14646 XM_DROP_SITE_VALID, 14685 XM_DROP_SITE_VALID, x_dnd_motif_operations,
14647 xm_side_effect_from_action (dpyinfo,
14648 x_dnd_wanted_action),
14649 (!x_dnd_xm_use_help 14686 (!x_dnd_xm_use_help
14650 ? XM_DROP_ACTION_DROP 14687 ? XM_DROP_ACTION_DROP
14651 : XM_DROP_ACTION_DROP_HELP)); 14688 : XM_DROP_ACTION_DROP_HELP));
@@ -14677,9 +14714,7 @@ x_dnd_update_state (struct x_display_info *dpyinfo, Time timestamp)
14677 dsmsg.side_effects 14714 dsmsg.side_effects
14678 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo, 14715 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
14679 x_dnd_wanted_action), 14716 x_dnd_wanted_action),
14680 XM_DROP_SITE_VALID, 14717 XM_DROP_SITE_VALID, x_dnd_motif_operations,
14681 xm_side_effect_from_action (dpyinfo,
14682 x_dnd_wanted_action),
14683 XM_DROP_ACTION_DROP_CANCEL); 14718 XM_DROP_ACTION_DROP_CANCEL);
14684 dsmsg.x = 0; 14719 dsmsg.x = 0;
14685 dsmsg.y = 0; 14720 dsmsg.y = 0;
@@ -16579,7 +16614,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
16579 dmsg.byteorder = XM_BYTE_ORDER_CUR_FIRST; 16614 dmsg.byteorder = XM_BYTE_ORDER_CUR_FIRST;
16580 dmsg.side_effects = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo, 16615 dmsg.side_effects = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
16581 x_dnd_wanted_action), 16616 x_dnd_wanted_action),
16582 XM_DROP_SITE_NONE, XM_DRAG_NOOP, 16617 XM_DROP_SITE_NONE, x_dnd_motif_operations,
16583 XM_DROP_ACTION_DROP_CANCEL); 16618 XM_DROP_ACTION_DROP_CANCEL);
16584 dmsg.timestamp = event->xmotion.time; 16619 dmsg.timestamp = event->xmotion.time;
16585 dmsg.x = event->xmotion.x_root; 16620 dmsg.x = event->xmotion.x_root;
@@ -16648,9 +16683,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
16648 dmsg.byteorder = XM_BYTE_ORDER_CUR_FIRST; 16683 dmsg.byteorder = XM_BYTE_ORDER_CUR_FIRST;
16649 dmsg.side_effects = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo, 16684 dmsg.side_effects = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
16650 x_dnd_wanted_action), 16685 x_dnd_wanted_action),
16651 XM_DROP_SITE_VALID, 16686 XM_DROP_SITE_VALID, x_dnd_motif_operations,
16652 xm_side_effect_from_action (dpyinfo,
16653 x_dnd_wanted_action),
16654 (!x_dnd_xm_use_help 16687 (!x_dnd_xm_use_help
16655 ? XM_DROP_ACTION_DROP 16688 ? XM_DROP_ACTION_DROP
16656 : XM_DROP_ACTION_DROP_HELP)); 16689 : XM_DROP_ACTION_DROP_HELP));
@@ -17182,9 +17215,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
17182 dmsg.side_effects 17215 dmsg.side_effects
17183 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo, 17216 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
17184 x_dnd_wanted_action), 17217 x_dnd_wanted_action),
17185 XM_DROP_SITE_VALID, 17218 XM_DROP_SITE_VALID, x_dnd_motif_operations,
17186 xm_side_effect_from_action (dpyinfo,
17187 x_dnd_wanted_action),
17188 (!x_dnd_xm_use_help 17219 (!x_dnd_xm_use_help
17189 ? XM_DROP_ACTION_DROP 17220 ? XM_DROP_ACTION_DROP
17190 : XM_DROP_ACTION_DROP_HELP)); 17221 : XM_DROP_ACTION_DROP_HELP));
@@ -18204,7 +18235,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
18204 dmsg.side_effects 18235 dmsg.side_effects
18205 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo, 18236 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
18206 x_dnd_wanted_action), 18237 x_dnd_wanted_action),
18207 XM_DROP_SITE_NONE, XM_DRAG_NOOP, 18238 XM_DROP_SITE_NONE, x_dnd_motif_operations,
18208 XM_DROP_ACTION_DROP_CANCEL); 18239 XM_DROP_ACTION_DROP_CANCEL);
18209 dmsg.timestamp = xev->time; 18240 dmsg.timestamp = xev->time;
18210 dmsg.x = lrint (xev->root_x); 18241 dmsg.x = lrint (xev->root_x);
@@ -18287,9 +18318,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
18287 dmsg.side_effects 18318 dmsg.side_effects
18288 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo, 18319 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
18289 x_dnd_wanted_action), 18320 x_dnd_wanted_action),
18290 XM_DROP_SITE_VALID, 18321 XM_DROP_SITE_VALID, x_dnd_motif_operations,
18291 xm_side_effect_from_action (dpyinfo,
18292 x_dnd_wanted_action),
18293 (!x_dnd_xm_use_help 18322 (!x_dnd_xm_use_help
18294 ? XM_DROP_ACTION_DROP 18323 ? XM_DROP_ACTION_DROP
18295 : XM_DROP_ACTION_DROP_HELP)); 18324 : XM_DROP_ACTION_DROP_HELP));
@@ -18480,9 +18509,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
18480 dmsg.side_effects 18509 dmsg.side_effects
18481 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo, 18510 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo,
18482 x_dnd_wanted_action), 18511 x_dnd_wanted_action),
18483 XM_DROP_SITE_VALID, 18512 XM_DROP_SITE_VALID, x_dnd_motif_operations,
18484 xm_side_effect_from_action (dpyinfo,
18485 x_dnd_wanted_action),
18486 (!x_dnd_xm_use_help 18513 (!x_dnd_xm_use_help
18487 ? XM_DROP_ACTION_DROP 18514 ? XM_DROP_ACTION_DROP
18488 : XM_DROP_ACTION_DROP_HELP)); 18515 : XM_DROP_ACTION_DROP_HELP));
@@ -21311,9 +21338,7 @@ x_connection_closed (Display *dpy, const char *error_message, bool ioerror)
21311 dmsg.side_effects 21338 dmsg.side_effects
21312 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (FRAME_DISPLAY_INFO (f), 21339 = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
21313 x_dnd_wanted_action), 21340 x_dnd_wanted_action),
21314 XM_DROP_SITE_VALID, 21341 XM_DROP_SITE_VALID, x_dnd_motif_operations,
21315 xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
21316 x_dnd_wanted_action),
21317 XM_DROP_ACTION_DROP_CANCEL); 21342 XM_DROP_ACTION_DROP_CANCEL);
21318 dmsg.x = 0; 21343 dmsg.x = 0;
21319 dmsg.y = 0; 21344 dmsg.y = 0;