aboutsummaryrefslogtreecommitdiffstats
path: root/src/xterm.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/xterm.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/xterm.c')
-rw-r--r--src/xterm.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 205c948c461..b061383a2ea 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1143,7 +1143,6 @@ static Window x_get_window_below (Display *, Window, int, int, int *, int *);
1143#ifndef USE_TOOLKIT_SCROLL_BARS 1143#ifndef USE_TOOLKIT_SCROLL_BARS
1144static void x_scroll_bar_redraw (struct scroll_bar *); 1144static void x_scroll_bar_redraw (struct scroll_bar *);
1145#endif 1145#endif
1146static void x_translate_coordinates (struct frame *, int, int, int *, int *);
1147 1146
1148/* Global state maintained during a drag-and-drop operation. */ 1147/* Global state maintained during a drag-and-drop operation. */
1149 1148
@@ -13658,7 +13657,7 @@ x_compute_root_window_offset (struct frame *f, int root_x, int root_y,
13658 many cases while handling events, which would otherwise result in 13657 many cases while handling events, which would otherwise result in
13659 slowdowns over slow network connections. */ 13658 slowdowns over slow network connections. */
13660 13659
13661static void 13660void
13662x_translate_coordinates (struct frame *f, int root_x, int root_y, 13661x_translate_coordinates (struct frame *f, int root_x, int root_y,
13663 int *x_out, int *y_out) 13662 int *x_out, int *y_out)
13664{ 13663{
@@ -13731,6 +13730,31 @@ x_translate_coordinates_to_root (struct frame *f, int x, int y,
13731 } 13730 }
13732} 13731}
13733 13732
13733/* Do x-translate-coordinates, but try to avoid a roundtrip to the X
13734 server at the cost of not returning `child', which most callers
13735 have no reason to use. */
13736
13737Lisp_Object
13738x_handle_translate_coordinates (struct frame *f, Lisp_Object dest_window,
13739 int source_x, int source_y)
13740{
13741 if (NILP (dest_window))
13742 {
13743 /* We are translating coordinates from a frame to the root
13744 window. Avoid a roundtrip if possible by using cached
13745 coordinates. */
13746
13747 if (!FRAME_X_OUTPUT (f)->window_offset_certain_p)
13748 return Qnil;
13749
13750 return list3 (make_fixnum (source_x + FRAME_X_OUTPUT (f)->root_x),
13751 make_fixnum (source_y + FRAME_X_OUTPUT (f)->root_y),
13752 Qnil);
13753 }
13754
13755 return Qnil;
13756}
13757
13734/* The same, but for an XIDeviceEvent. */ 13758/* The same, but for an XIDeviceEvent. */
13735 13759
13736#ifdef HAVE_XINPUT2 13760#ifdef HAVE_XINPUT2
@@ -20826,7 +20850,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
20826 event->xbutton.time); 20850 event->xbutton.time);
20827 } 20851 }
20828 else if (x_dnd_last_seen_window != None 20852 else if (x_dnd_last_seen_window != None
20829 && x_dnd_last_protocol_version != -1) 20853 && x_dnd_last_protocol_version != -1)
20830 { 20854 {
20831 x_dnd_pending_finish_target = x_dnd_last_seen_toplevel; 20855 x_dnd_pending_finish_target = x_dnd_last_seen_toplevel;
20832 x_dnd_waiting_for_finish_proto = x_dnd_last_protocol_version; 20856 x_dnd_waiting_for_finish_proto = x_dnd_last_protocol_version;