[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 0e7314f6f1: Avoid extra sync when fetching DND proxy window
From: |
Po Lu |
Subject: |
master 0e7314f6f1: Avoid extra sync when fetching DND proxy window |
Date: |
Mon, 28 Mar 2022 01:52:36 -0400 (EDT) |
branch: master
commit 0e7314f6f15a20cb2ae712c09bb201f571823a6f
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Avoid extra sync when fetching DND proxy window
* src/xterm.c (x_dnd_get_proxy_proto): New function.
(x_dnd_get_target_window): Use it on XCB to determine window
proxy and proto for toplevel window.
---
src/xterm.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 74 insertions(+), 1 deletion(-)
diff --git a/src/xterm.c b/src/xterm.c
index 97dfbc5add..443009c0db 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1343,9 +1343,76 @@ x_dnd_compute_toplevels (struct x_display_info *dpyinfo)
#define X_DND_SUPPORTED_VERSION 5
+
static int x_dnd_get_window_proto (struct x_display_info *, Window);
static Window x_dnd_get_window_proxy (struct x_display_info *, Window);
+#ifdef USE_XCB
+static void
+x_dnd_get_proxy_proto (struct x_display_info *dpyinfo, Window wdesc,
+ Window *proxy_out, int *proto_out)
+{
+ xcb_get_property_cookie_t xdnd_proto_cookie;
+ xcb_get_property_cookie_t xdnd_proxy_cookie;
+ xcb_get_property_reply_t *reply;
+ xcb_generic_error_t *error;
+
+ if (proxy_out)
+ *proxy_out = None;
+
+ if (proto_out)
+ *proto_out = -1;
+
+ if (proxy_out)
+ xdnd_proxy_cookie = xcb_get_property (dpyinfo->xcb_connection, 0,
+ (xcb_window_t) wdesc,
+ (xcb_atom_t) dpyinfo->Xatom_XdndProxy,
+ XCB_ATOM_WINDOW, 0, 1);
+
+ if (proto_out)
+ xdnd_proto_cookie = xcb_get_property (dpyinfo->xcb_connection, 0,
+ (xcb_window_t) wdesc,
+ (xcb_atom_t) dpyinfo->Xatom_XdndAware,
+ XCB_ATOM_ATOM, 0, 1);
+
+ if (proxy_out)
+ {
+ 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);
+ }
+ }
+
+ if (proto_out)
+ {
+ reply = xcb_get_property_reply (dpyinfo->xcb_connection,
+ xdnd_proto_cookie, &error);
+
+ if (!reply)
+ free (error);
+ else
+ {
+ if (reply->format == 32
+ && reply->type == XCB_ATOM_ATOM
+ && (xcb_get_property_value_length (reply) >= 4))
+ *proto_out = (int) *(xcb_atom_t *) xcb_get_property_value (reply);
+
+ free (reply);
+ }
+ }
+}
+#endif
+
#ifdef HAVE_XSHAPE
static bool
x_dnd_get_target_window_2 (XRectangle *rects, int nrects,
@@ -1433,7 +1500,11 @@ x_dnd_get_target_window (struct x_display_info *dpyinfo,
if (child != None)
{
- proxy = x_dnd_get_window_proxy (dpyinfo, child_return);
+#ifndef USE_XCB
+ proxy = x_dnd_get_window_proxy (dpyinfo, child);
+#else
+ x_dnd_get_proxy_proto (dpyinfo, child, &proxy, proto_out);
+#endif
if (proxy != None)
{
@@ -1446,7 +1517,9 @@ x_dnd_get_target_window (struct x_display_info *dpyinfo,
}
}
+#ifndef USE_XCB
*proto_out = x_dnd_get_window_proto (dpyinfo, child);
+#endif
return child;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 0e7314f6f1: Avoid extra sync when fetching DND proxy window,
Po Lu <=