diff options
author | Po Lu <luangruo@yahoo.com> | 2022-04-06 20:48:06 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-04-06 20:48:06 +0800 |
commit | fc62efc563733819795441d41ce450d64c56ed48 (patch) | |
tree | c67f86665dc923b83116269fae3377f7de061e93 | |
parent | c0bb11432ee07228d8819cc98c6ce29ccd42ae97 (diff) | |
download | emacs-fc62efc563733819795441d41ce450d64c56ed48.tar.gz emacs-fc62efc563733819795441d41ce450d64c56ed48.tar.bz2 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.c | 31 |
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, static int x_dnd_get_wm_state_and_proto (struct x_display_info *dpyinfo, Window window, int *wmstate_out, - int *proto_out, int *motif_out) + int *proto_out, int *motif_out, + Window *proxy_out) { #ifndef USE_XCB Atom type; @@ -2667,6 +2668,7 @@ x_dnd_get_wm_state_and_proto (struct x_display_info *dpyinfo, #else xcb_get_property_cookie_t wmstate_cookie; xcb_get_property_cookie_t xdnd_proto_cookie; + xcb_get_property_cookie_t xdnd_proxy_cookie; xcb_get_property_cookie_t xm_style_cookie; xcb_get_property_reply_t *reply; xcb_generic_error_t *error; @@ -2696,6 +2698,8 @@ x_dnd_get_wm_state_and_proto (struct x_display_info *dpyinfo, else *motif_out = XM_DRAG_STYLE_NONE; + *proxy_out = x_dnd_get_window_proxy (dpyinfo, window); + if (data) XFree (data); #else @@ -2709,6 +2713,10 @@ x_dnd_get_wm_state_and_proto (struct x_display_info *dpyinfo, (xcb_window_t) window, (xcb_atom_t) dpyinfo->Xatom_XdndAware, XCB_ATOM_ATOM, 0, 1); + xdnd_proxy_cookie = xcb_get_property (dpyinfo->xcb_connection, 0, + (xcb_window_t) window, + (xcb_atom_t) dpyinfo->Xatom_XdndProxy, + XCB_ATOM_WINDOW, 0, 1); xm_style_cookie = xcb_get_property (dpyinfo->xcb_connection, 0, (xcb_window_t) window, (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, free (reply); } + *proxy_out = None; + reply = xcb_get_property_reply (dpyinfo->xcb_connection, + xdnd_proxy_cookie, &error); + + if (!reply) + free (error); + else + { + if (reply->format == 32 + && reply->type == XCB_ATOM_WINDOW + && (xcb_get_property_value_length (reply) >= 4)) + *proxy_out = *(xcb_window_t *) xcb_get_property_value (reply); + + free (reply); + } + *motif_out = XM_DRAG_STYLE_NONE; reply = xcb_get_property_reply (dpyinfo->xcb_connection, @@ -3062,7 +3086,8 @@ x_dnd_get_target_window (struct x_display_info *dpyinfo, if (child_return) { if (x_dnd_get_wm_state_and_proto (dpyinfo, child_return, - &wmstate, &proto, &motif) + &wmstate, &proto, &motif, + &proxy) /* `proto' and `motif' are set by x_dnd_get_wm_state even if getting the wm state failed. */ || proto != -1 || motif != XM_DRAG_STYLE_NONE) @@ -3075,8 +3100,6 @@ x_dnd_get_target_window (struct x_display_info *dpyinfo, return child_return; } - proxy = x_dnd_get_window_proxy (dpyinfo, child_return); - if (proxy != None) { proto = x_dnd_get_window_proto (dpyinfo, proxy); |