aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2022-04-06 20:48:06 +0800
committerPo Lu2022-04-06 20:48:06 +0800
commitfc62efc563733819795441d41ce450d64c56ed48 (patch)
treec67f86665dc923b83116269fae3377f7de061e93
parentc0bb11432ee07228d8819cc98c6ce29ccd42ae97 (diff)
downloademacs-fc62efc563733819795441d41ce450d64c56ed48.tar.gz
emacs-fc62efc563733819795441d41ce450d64c56ed48.zip
Get rid of extra sync looking up window through XTranslateCoordinates
* src/xterm.c (x_dnd_get_wm_state_and_proto): Return proxy as well. (x_dnd_get_target_window): Use that proxy.
-rw-r--r--src/xterm.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/xterm.c b/src/xterm.c
index b6fe5fda0fa..3b0416722b0 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -2656,7 +2656,8 @@ x_dnd_get_target_window_1 (struct x_display_info *dpyinfo,
2656static int 2656static int
2657x_dnd_get_wm_state_and_proto (struct x_display_info *dpyinfo, 2657x_dnd_get_wm_state_and_proto (struct x_display_info *dpyinfo,
2658 Window window, int *wmstate_out, 2658 Window window, int *wmstate_out,
2659 int *proto_out, int *motif_out) 2659 int *proto_out, int *motif_out,
2660 Window *proxy_out)
2660{ 2661{
2661#ifndef USE_XCB 2662#ifndef USE_XCB
2662 Atom type; 2663 Atom type;
@@ -2667,6 +2668,7 @@ x_dnd_get_wm_state_and_proto (struct x_display_info *dpyinfo,
2667#else 2668#else
2668 xcb_get_property_cookie_t wmstate_cookie; 2669 xcb_get_property_cookie_t wmstate_cookie;
2669 xcb_get_property_cookie_t xdnd_proto_cookie; 2670 xcb_get_property_cookie_t xdnd_proto_cookie;
2671 xcb_get_property_cookie_t xdnd_proxy_cookie;
2670 xcb_get_property_cookie_t xm_style_cookie; 2672 xcb_get_property_cookie_t xm_style_cookie;
2671 xcb_get_property_reply_t *reply; 2673 xcb_get_property_reply_t *reply;
2672 xcb_generic_error_t *error; 2674 xcb_generic_error_t *error;
@@ -2696,6 +2698,8 @@ x_dnd_get_wm_state_and_proto (struct x_display_info *dpyinfo,
2696 else 2698 else
2697 *motif_out = XM_DRAG_STYLE_NONE; 2699 *motif_out = XM_DRAG_STYLE_NONE;
2698 2700
2701 *proxy_out = x_dnd_get_window_proxy (dpyinfo, window);
2702
2699 if (data) 2703 if (data)
2700 XFree (data); 2704 XFree (data);
2701#else 2705#else
@@ -2709,6 +2713,10 @@ x_dnd_get_wm_state_and_proto (struct x_display_info *dpyinfo,
2709 (xcb_window_t) window, 2713 (xcb_window_t) window,
2710 (xcb_atom_t) dpyinfo->Xatom_XdndAware, 2714 (xcb_atom_t) dpyinfo->Xatom_XdndAware,
2711 XCB_ATOM_ATOM, 0, 1); 2715 XCB_ATOM_ATOM, 0, 1);
2716 xdnd_proxy_cookie = xcb_get_property (dpyinfo->xcb_connection, 0,
2717 (xcb_window_t) window,
2718 (xcb_atom_t) dpyinfo->Xatom_XdndProxy,
2719 XCB_ATOM_WINDOW, 0, 1);
2712 xm_style_cookie = xcb_get_property (dpyinfo->xcb_connection, 0, 2720 xm_style_cookie = xcb_get_property (dpyinfo->xcb_connection, 0,
2713 (xcb_window_t) window, 2721 (xcb_window_t) window,
2714 (xcb_atom_t) dpyinfo->Xatom_MOTIF_DRAG_RECEIVER_INFO, 2722 (xcb_atom_t) dpyinfo->Xatom_MOTIF_DRAG_RECEIVER_INFO,
@@ -2746,6 +2754,22 @@ x_dnd_get_wm_state_and_proto (struct x_display_info *dpyinfo,
2746 free (reply); 2754 free (reply);
2747 } 2755 }
2748 2756
2757 *proxy_out = None;
2758 reply = xcb_get_property_reply (dpyinfo->xcb_connection,
2759 xdnd_proxy_cookie, &error);
2760
2761 if (!reply)
2762 free (error);
2763 else
2764 {
2765 if (reply->format == 32
2766 && reply->type == XCB_ATOM_WINDOW
2767 && (xcb_get_property_value_length (reply) >= 4))
2768 *proxy_out = *(xcb_window_t *) xcb_get_property_value (reply);
2769
2770 free (reply);
2771 }
2772
2749 *motif_out = XM_DRAG_STYLE_NONE; 2773 *motif_out = XM_DRAG_STYLE_NONE;
2750 2774
2751 reply = xcb_get_property_reply (dpyinfo->xcb_connection, 2775 reply = xcb_get_property_reply (dpyinfo->xcb_connection,
@@ -3062,7 +3086,8 @@ x_dnd_get_target_window (struct x_display_info *dpyinfo,
3062 if (child_return) 3086 if (child_return)
3063 { 3087 {
3064 if (x_dnd_get_wm_state_and_proto (dpyinfo, child_return, 3088 if (x_dnd_get_wm_state_and_proto (dpyinfo, child_return,
3065 &wmstate, &proto, &motif) 3089 &wmstate, &proto, &motif,
3090 &proxy)
3066 /* `proto' and `motif' are set by x_dnd_get_wm_state 3091 /* `proto' and `motif' are set by x_dnd_get_wm_state
3067 even if getting the wm state failed. */ 3092 even if getting the wm state failed. */
3068 || proto != -1 || motif != XM_DRAG_STYLE_NONE) 3093 || proto != -1 || motif != XM_DRAG_STYLE_NONE)
@@ -3075,8 +3100,6 @@ x_dnd_get_target_window (struct x_display_info *dpyinfo,
3075 return child_return; 3100 return child_return;
3076 } 3101 }
3077 3102
3078 proxy = x_dnd_get_window_proxy (dpyinfo, child_return);
3079
3080 if (proxy != None) 3103 if (proxy != None)
3081 { 3104 {
3082 proto = x_dnd_get_window_proto (dpyinfo, proxy); 3105 proto = x_dnd_get_window_proto (dpyinfo, proxy);