aboutsummaryrefslogtreecommitdiffstats
path: root/src/xfns.c
diff options
context:
space:
mode:
authorPo Lu2022-10-25 19:50:57 +0800
committerPo Lu2022-10-25 19:51:08 +0800
commitb6097fe279b03e2fb50fc6af063d7c8f1e55fe8b (patch)
tree8d7a834c70cbb631fbdb086e9b4a2ba35a6b25c2 /src/xfns.c
parentbb95e597a9adcba0080cba85b2270fdf80696b3a (diff)
downloademacs-b6097fe279b03e2fb50fc6af063d7c8f1e55fe8b.tar.gz
emacs-b6097fe279b03e2fb50fc6af063d7c8f1e55fe8b.zip
Fix drag-and-drop bugs on Lucid build
Also, optimize Fx_translate_coordinates to avoid excessive calls to _XReply. * lisp/x-dnd.el (x-dnd-get-drop-rectangle): Return empty drop rectangle if posn-area. * src/xfns.c (Fx_translate_coordinates): Accept arg `require_child'. If not set, allow optimizations based on cached position data. * src/xselect.c (x_handle_dnd_message): Use x_translate_coordinates. * src/xterm.c (x_translate_coordinates): Export function. (x_handle_translate_coordinates): New function. (handle_one_xevent): Fix coding style. * src/xterm.h: Update prototypes.
Diffstat (limited to 'src/xfns.c')
-rw-r--r--src/xfns.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/xfns.c b/src/xfns.c
index e8732986eb9..3ff7a8c2865 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -7913,7 +7913,7 @@ Otherwise, the return value is a vector with the following fields:
7913 7913
7914DEFUN ("x-translate-coordinates", Fx_translate_coordinates, 7914DEFUN ("x-translate-coordinates", Fx_translate_coordinates,
7915 Sx_translate_coordinates, 7915 Sx_translate_coordinates,
7916 1, 5, 0, doc: /* Translate coordinates from FRAME. 7916 1, 6, 0, doc: /* Translate coordinates from FRAME.
7917Translate the given coordinates SOURCE-X and SOURCE-Y from 7917Translate the given coordinates SOURCE-X and SOURCE-Y from
7918SOURCE-WINDOW's coordinate space to that of DEST-WINDOW, on FRAME. 7918SOURCE-WINDOW's coordinate space to that of DEST-WINDOW, on FRAME.
7919 7919
@@ -7929,16 +7929,21 @@ Return a list of (X Y CHILD) if the given coordinates are on the same
7929screen, or nil otherwise, where X and Y are the coordinates in 7929screen, or nil otherwise, where X and Y are the coordinates in
7930DEST-WINDOW's coordinate space, and CHILD is the window ID of any 7930DEST-WINDOW's coordinate space, and CHILD is the window ID of any
7931mapped child in DEST-WINDOW at those coordinates, or nil if there is 7931mapped child in DEST-WINDOW at those coordinates, or nil if there is
7932no such window. */) 7932no such window. If REQUIRE-CHILD is nil, avoid fetching CHILD if it
7933would result in an avoidable request to the X server, thereby
7934improving performance when the X connection is over a slow network.
7935Otherwise, always obtain the mapped child window from the X
7936server. */)
7933 (Lisp_Object frame, Lisp_Object source_window, 7937 (Lisp_Object frame, Lisp_Object source_window,
7934 Lisp_Object dest_window, Lisp_Object source_x, 7938 Lisp_Object dest_window, Lisp_Object source_x,
7935 Lisp_Object source_y) 7939 Lisp_Object source_y, Lisp_Object require_child)
7936{ 7940{
7937 struct x_display_info *dpyinfo; 7941 struct x_display_info *dpyinfo;
7938 struct frame *source_frame; 7942 struct frame *source_frame;
7939 int dest_x, dest_y; 7943 int dest_x, dest_y;
7940 Window child_return, src, dest; 7944 Window child_return, src, dest;
7941 Bool rc; 7945 Bool rc;
7946 Lisp_Object temp_result;
7942 7947
7943 dpyinfo = check_x_display_info (frame); 7948 dpyinfo = check_x_display_info (frame);
7944 dest_x = 0; 7949 dest_x = 0;
@@ -7956,6 +7961,8 @@ no such window. */)
7956 dest_y = XFIXNUM (source_y); 7961 dest_y = XFIXNUM (source_y);
7957 } 7962 }
7958 7963
7964 source_frame = NULL;
7965
7959 if (!NILP (source_window)) 7966 if (!NILP (source_window))
7960 CONS_TO_INTEGER (source_window, Window, src); 7967 CONS_TO_INTEGER (source_window, Window, src);
7961 else 7968 else
@@ -7964,6 +7971,17 @@ no such window. */)
7964 src = FRAME_X_WINDOW (source_frame); 7971 src = FRAME_X_WINDOW (source_frame);
7965 } 7972 }
7966 7973
7974 /* If require_child is nil, try to avoid an avoidable roundtrip to
7975 the X server. */
7976 if (NILP (require_child) && source_frame)
7977 {
7978 temp_result
7979 = x_handle_translate_coordinates (source_frame, dest_window, dest_x,
7980 dest_y);
7981 if (!NILP (temp_result))
7982 return temp_result;
7983 }
7984
7967 if (!src) 7985 if (!src)
7968 src = dpyinfo->root_window; 7986 src = dpyinfo->root_window;
7969 7987