diff options
| author | Po Lu | 2022-06-15 09:26:46 +0800 |
|---|---|---|
| committer | Po Lu | 2022-06-15 09:26:46 +0800 |
| commit | 2e2913654b65fea657e79705df2c1842207000cf (patch) | |
| tree | 714ae7a5d3769b75308c08294aa9b67e89f44d00 /src | |
| parent | 787c4ad8b0776280305a220d6669c956d9ed8a5d (diff) | |
| download | emacs-2e2913654b65fea657e79705df2c1842207000cf.tar.gz emacs-2e2913654b65fea657e79705df2c1842207000cf.zip | |
Handle coordinates from XM_DRAG_REASON_DRAG_MOTION replies
* src/xterm.c (struct xm_drag_motion_reply): New struct.
(xm_read_drag_motion_reply): New function.
(x_coords_from_dnd_message): Handle those messages as well.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/xterm.c b/src/xterm.c index 2cc17b455da..7f78f40bb79 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -1471,6 +1471,17 @@ typedef struct xm_drag_motion_message | |||
| 1471 | /* CARD16 */ uint16_t x, y; | 1471 | /* CARD16 */ uint16_t x, y; |
| 1472 | } xm_drag_motion_message; | 1472 | } xm_drag_motion_message; |
| 1473 | 1473 | ||
| 1474 | typedef struct xm_drag_motion_reply | ||
| 1475 | { | ||
| 1476 | /* BYTE */ uint8_t reason; | ||
| 1477 | /* BYTE */ uint8_t byte_order; | ||
| 1478 | |||
| 1479 | /* CARD16 */ uint16_t side_effects; | ||
| 1480 | /* CARD32 */ uint32_t timestamp; | ||
| 1481 | /* CARD16 */ uint16_t better_x; | ||
| 1482 | /* CARD16 */ uint16_t better_y; | ||
| 1483 | } xm_drag_motion_reply; | ||
| 1484 | |||
| 1474 | typedef struct xm_top_level_leave_message | 1485 | typedef struct xm_top_level_leave_message |
| 1475 | { | 1486 | { |
| 1476 | /* BYTE */ uint8_t reason; | 1487 | /* BYTE */ uint8_t reason; |
| @@ -2467,6 +2478,39 @@ xm_read_drag_motion_message (const XEvent *msg, | |||
| 2467 | return 0; | 2478 | return 0; |
| 2468 | } | 2479 | } |
| 2469 | 2480 | ||
| 2481 | static int | ||
| 2482 | xm_read_drag_motion_reply (const XEvent *msg, xm_drag_motion_reply *reply) | ||
| 2483 | { | ||
| 2484 | const uint8_t *data; | ||
| 2485 | |||
| 2486 | data = (const uint8_t *) &msg->xclient.data.b[0]; | ||
| 2487 | |||
| 2488 | if ((XM_DRAG_REASON_CODE (data[0]) | ||
| 2489 | != XM_DRAG_REASON_DRAG_MOTION) | ||
| 2490 | || (XM_DRAG_REASON_ORIGINATOR (data[0]) | ||
| 2491 | != XM_DRAG_ORIGINATOR_RECEIVER)) | ||
| 2492 | return 1; | ||
| 2493 | |||
| 2494 | reply->reason = *(data++); | ||
| 2495 | reply->byte_order = *(data++); | ||
| 2496 | reply->side_effects = *(uint16_t *) data; | ||
| 2497 | reply->timestamp = *(uint32_t *) (data + 2); | ||
| 2498 | reply->better_x = *(uint16_t *) (data + 6); | ||
| 2499 | reply->better_y = *(uint16_t *) (data + 8); | ||
| 2500 | |||
| 2501 | if (reply->byte_order != XM_BYTE_ORDER_CUR_FIRST) | ||
| 2502 | { | ||
| 2503 | SWAPCARD16 (reply->side_effects); | ||
| 2504 | SWAPCARD32 (reply->timestamp); | ||
| 2505 | SWAPCARD16 (reply->better_x); | ||
| 2506 | SWAPCARD16 (reply->better_y); | ||
| 2507 | } | ||
| 2508 | |||
| 2509 | reply->byte_order = XM_BYTE_ORDER_CUR_FIRST; | ||
| 2510 | |||
| 2511 | return 0; | ||
| 2512 | } | ||
| 2513 | |||
| 2470 | static void | 2514 | static void |
| 2471 | x_dnd_send_xm_leave_for_drop (struct x_display_info *dpyinfo, | 2515 | x_dnd_send_xm_leave_for_drop (struct x_display_info *dpyinfo, |
| 2472 | struct frame *f, Window wdesc, | 2516 | struct frame *f, Window wdesc, |
| @@ -15842,6 +15886,7 @@ x_coords_from_dnd_message (struct x_display_info *dpyinfo, | |||
| 15842 | XEvent *event, int *x_out, int *y_out) | 15886 | XEvent *event, int *x_out, int *y_out) |
| 15843 | { | 15887 | { |
| 15844 | xm_drag_motion_message dmsg; | 15888 | xm_drag_motion_message dmsg; |
| 15889 | xm_drag_motion_reply dreply; | ||
| 15845 | xm_drop_start_message smsg; | 15890 | xm_drop_start_message smsg; |
| 15846 | xm_drop_start_reply reply; | 15891 | xm_drop_start_reply reply; |
| 15847 | 15892 | ||
| @@ -15871,6 +15916,13 @@ x_coords_from_dnd_message (struct x_display_info *dpyinfo, | |||
| 15871 | 15916 | ||
| 15872 | return true; | 15917 | return true; |
| 15873 | } | 15918 | } |
| 15919 | else if (!xm_read_drag_motion_reply (event, &dreply)) | ||
| 15920 | { | ||
| 15921 | *x_out = dreply.better_x; | ||
| 15922 | *y_out = dreply.better_y; | ||
| 15923 | |||
| 15924 | return true; | ||
| 15925 | } | ||
| 15874 | else if (!xm_read_drop_start_message (event, &smsg)) | 15926 | else if (!xm_read_drop_start_message (event, &smsg)) |
| 15875 | { | 15927 | { |
| 15876 | *x_out = smsg.x; | 15928 | *x_out = smsg.x; |