diff options
| author | Po Lu | 2022-04-02 11:44:15 +0800 |
|---|---|---|
| committer | Po Lu | 2022-04-02 11:44:15 +0800 |
| commit | 35ad6bc2acf1c5a76c9f46cd0c7b64e72a88e2ea (patch) | |
| tree | 685071cfb48e7510186a2ccecaeb4bf2d1af3ca0 /src | |
| parent | 59fb6783e6ee2d99cd8f58ac10130313f4b51927 (diff) | |
| download | emacs-35ad6bc2acf1c5a76c9f46cd0c7b64e72a88e2ea.tar.gz emacs-35ad6bc2acf1c5a76c9f46cd0c7b64e72a88e2ea.zip | |
Work around dynamic drag bugs in modern Motif
* src/xterm.c (xm_send_top_level_leave_message): Send a motion
event with impossible coordinates by default.
(handle_one_xevent): Slightly update drop motion message
parameters.
(syms_of_xterm): New variable `x-dnd-fix-motif-leave'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/src/xterm.c b/src/xterm.c index 7c41122ca16..48c054c478e 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -1077,7 +1077,7 @@ typedef struct xm_top_level_leave_message | |||
| 1077 | 1077 | ||
| 1078 | #define XM_DROP_SITE_VALID 3 | 1078 | #define XM_DROP_SITE_VALID 3 |
| 1079 | /* #define XM_DROP_SITE_INVALID 2 */ | 1079 | /* #define XM_DROP_SITE_INVALID 2 */ |
| 1080 | /* #define XM_DROP_SITE_NONE 1 */ | 1080 | #define XM_DROP_SITE_NONE 1 |
| 1081 | 1081 | ||
| 1082 | static uint8_t | 1082 | static uint8_t |
| 1083 | xm_side_effect_from_action (struct x_display_info *dpyinfo, Atom action) | 1083 | xm_side_effect_from_action (struct x_display_info *dpyinfo, Atom action) |
| @@ -1589,6 +1589,29 @@ xm_send_top_level_leave_message (struct x_display_info *dpyinfo, Window source, | |||
| 1589 | Window target, xm_top_level_leave_message *dmsg) | 1589 | Window target, xm_top_level_leave_message *dmsg) |
| 1590 | { | 1590 | { |
| 1591 | XEvent msg; | 1591 | XEvent msg; |
| 1592 | xm_drag_motion_message mmsg; | ||
| 1593 | |||
| 1594 | /* Motif support for TOP_LEVEL_LEAVE has bitrotted, since these days | ||
| 1595 | it assumes every client supports the preregister protocol style, | ||
| 1596 | but we only support drop-only and dynamic. (Interestingly enough | ||
| 1597 | LessTif works fine.) Sending an event with impossible | ||
| 1598 | coordinates serves to get rid of any active drop site that might | ||
| 1599 | still be around in the target drag context. */ | ||
| 1600 | |||
| 1601 | if (x_dnd_fix_motif_leave) | ||
| 1602 | { | ||
| 1603 | mmsg.reason = XM_DRAG_REASON (XM_DRAG_ORIGINATOR_INITIATOR, | ||
| 1604 | XM_DRAG_REASON_DRAG_MOTION); | ||
| 1605 | mmsg.byteorder = XM_TARGETS_TABLE_CUR; | ||
| 1606 | mmsg.side_effects = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo, | ||
| 1607 | x_dnd_wanted_action), | ||
| 1608 | XM_DROP_SITE_NONE, 0, 0); | ||
| 1609 | mmsg.timestamp = dmsg->timestamp; | ||
| 1610 | mmsg.x = 65535; | ||
| 1611 | mmsg.y = 65535; | ||
| 1612 | |||
| 1613 | xm_send_drag_motion_message (dpyinfo, source, target, &mmsg); | ||
| 1614 | } | ||
| 1592 | 1615 | ||
| 1593 | msg.xclient.type = ClientMessage; | 1616 | msg.xclient.type = ClientMessage; |
| 1594 | msg.xclient.message_type | 1617 | msg.xclient.message_type |
| @@ -14384,10 +14407,12 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 14384 | dmsg.reason = XM_DRAG_REASON (XM_DRAG_ORIGINATOR_INITIATOR, | 14407 | dmsg.reason = XM_DRAG_REASON (XM_DRAG_ORIGINATOR_INITIATOR, |
| 14385 | XM_DRAG_REASON_DRAG_MOTION); | 14408 | XM_DRAG_REASON_DRAG_MOTION); |
| 14386 | dmsg.byteorder = XM_TARGETS_TABLE_CUR; | 14409 | dmsg.byteorder = XM_TARGETS_TABLE_CUR; |
| 14387 | dmsg.side_effects = 0; | 14410 | dmsg.side_effects = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo, |
| 14388 | dmsg.timestamp = event->xbutton.time; | 14411 | x_dnd_wanted_action), |
| 14389 | dmsg.x = event->xbutton.x_root; | 14412 | XM_DROP_SITE_NONE, 0, 0); |
| 14390 | dmsg.y = event->xbutton.y_root; | 14413 | dmsg.timestamp = event->xmotion.time; |
| 14414 | dmsg.x = event->xmotion.x_root; | ||
| 14415 | dmsg.y = event->xmotion.y_root; | ||
| 14391 | 14416 | ||
| 14392 | lmsg.reason = XM_DRAG_REASON (XM_DRAG_ORIGINATOR_INITIATOR, | 14417 | lmsg.reason = XM_DRAG_REASON (XM_DRAG_ORIGINATOR_INITIATOR, |
| 14393 | XM_DRAG_REASON_TOP_LEVEL_LEAVE); | 14418 | XM_DRAG_REASON_TOP_LEVEL_LEAVE); |
| @@ -15832,7 +15857,10 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 15832 | dmsg.reason = XM_DRAG_REASON (XM_DRAG_ORIGINATOR_INITIATOR, | 15857 | dmsg.reason = XM_DRAG_REASON (XM_DRAG_ORIGINATOR_INITIATOR, |
| 15833 | XM_DRAG_REASON_DRAG_MOTION); | 15858 | XM_DRAG_REASON_DRAG_MOTION); |
| 15834 | dmsg.byteorder = XM_TARGETS_TABLE_CUR; | 15859 | dmsg.byteorder = XM_TARGETS_TABLE_CUR; |
| 15835 | dmsg.side_effects = 0; | 15860 | dmsg.side_effects |
| 15861 | = XM_DRAG_SIDE_EFFECT (xm_side_effect_from_action (dpyinfo, | ||
| 15862 | x_dnd_wanted_action), | ||
| 15863 | XM_DROP_SITE_NONE, 0, 0); | ||
| 15836 | dmsg.timestamp = xev->time; | 15864 | dmsg.timestamp = xev->time; |
| 15837 | dmsg.x = lrint (xev->root_x); | 15865 | dmsg.x = lrint (xev->root_x); |
| 15838 | dmsg.y = lrint (xev->root_y); | 15866 | dmsg.y = lrint (xev->root_y); |
| @@ -22742,4 +22770,12 @@ reliably continue to receive updates even if the finger moves off the | |||
| 22742 | frame, but may cause crashes with some window managers and/or external | 22770 | frame, but may cause crashes with some window managers and/or external |
| 22743 | programs. */); | 22771 | programs. */); |
| 22744 | x_input_grab_touch_events = true; | 22772 | x_input_grab_touch_events = true; |
| 22773 | |||
| 22774 | DEFVAR_BOOL ("x-dnd-fix-motif-leave", x_dnd_fix_motif_leave, | ||
| 22775 | doc: /* Work around Motif bug during drag-and-drop. | ||
| 22776 | When non-nil, Emacs will send a motion event containing impossible | ||
| 22777 | coordinates to a Motif drop receiver when the mouse moves outside it | ||
| 22778 | during a drag-and-drop session, to work around broken implementations | ||
| 22779 | of Motif. */); | ||
| 22780 | x_dnd_fix_motif_leave = true; | ||
| 22745 | } | 22781 | } |