aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-03-28 13:52:17 +0800
committerPo Lu2022-03-28 13:52:17 +0800
commit0e7314f6f15a20cb2ae712c09bb201f571823a6f (patch)
tree9668dd376cbd724620e0379257be82bd7816dde6 /src
parentf5adb2584a9e25e3bbf01d1ca1c7fc6e511a4012 (diff)
downloademacs-0e7314f6f15a20cb2ae712c09bb201f571823a6f.tar.gz
emacs-0e7314f6f15a20cb2ae712c09bb201f571823a6f.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c75
1 files changed, 74 insertions, 1 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 97dfbc5add1..443009c0dba 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1343,9 +1343,76 @@ x_dnd_compute_toplevels (struct x_display_info *dpyinfo)
1343 1343
1344#define X_DND_SUPPORTED_VERSION 5 1344#define X_DND_SUPPORTED_VERSION 5
1345 1345
1346
1346static int x_dnd_get_window_proto (struct x_display_info *, Window); 1347static int x_dnd_get_window_proto (struct x_display_info *, Window);
1347static Window x_dnd_get_window_proxy (struct x_display_info *, Window); 1348static Window x_dnd_get_window_proxy (struct x_display_info *, Window);
1348 1349
1350#ifdef USE_XCB
1351static void
1352x_dnd_get_proxy_proto (struct x_display_info *dpyinfo, Window wdesc,
1353 Window *proxy_out, int *proto_out)
1354{
1355 xcb_get_property_cookie_t xdnd_proto_cookie;
1356 xcb_get_property_cookie_t xdnd_proxy_cookie;
1357 xcb_get_property_reply_t *reply;
1358 xcb_generic_error_t *error;
1359
1360 if (proxy_out)
1361 *proxy_out = None;
1362
1363 if (proto_out)
1364 *proto_out = -1;
1365
1366 if (proxy_out)
1367 xdnd_proxy_cookie = xcb_get_property (dpyinfo->xcb_connection, 0,
1368 (xcb_window_t) wdesc,
1369 (xcb_atom_t) dpyinfo->Xatom_XdndProxy,
1370 XCB_ATOM_WINDOW, 0, 1);
1371
1372 if (proto_out)
1373 xdnd_proto_cookie = xcb_get_property (dpyinfo->xcb_connection, 0,
1374 (xcb_window_t) wdesc,
1375 (xcb_atom_t) dpyinfo->Xatom_XdndAware,
1376 XCB_ATOM_ATOM, 0, 1);
1377
1378 if (proxy_out)
1379 {
1380 reply = xcb_get_property_reply (dpyinfo->xcb_connection,
1381 xdnd_proxy_cookie, &error);
1382
1383 if (!reply)
1384 free (error);
1385 else
1386 {
1387 if (reply->format == 32
1388 && reply->type == XCB_ATOM_WINDOW
1389 && (xcb_get_property_value_length (reply) >= 4))
1390 *proxy_out = *(xcb_window_t *) xcb_get_property_value (reply);
1391
1392 free (reply);
1393 }
1394 }
1395
1396 if (proto_out)
1397 {
1398 reply = xcb_get_property_reply (dpyinfo->xcb_connection,
1399 xdnd_proto_cookie, &error);
1400
1401 if (!reply)
1402 free (error);
1403 else
1404 {
1405 if (reply->format == 32
1406 && reply->type == XCB_ATOM_ATOM
1407 && (xcb_get_property_value_length (reply) >= 4))
1408 *proto_out = (int) *(xcb_atom_t *) xcb_get_property_value (reply);
1409
1410 free (reply);
1411 }
1412 }
1413}
1414#endif
1415
1349#ifdef HAVE_XSHAPE 1416#ifdef HAVE_XSHAPE
1350static bool 1417static bool
1351x_dnd_get_target_window_2 (XRectangle *rects, int nrects, 1418x_dnd_get_target_window_2 (XRectangle *rects, int nrects,
@@ -1433,7 +1500,11 @@ x_dnd_get_target_window (struct x_display_info *dpyinfo,
1433 1500
1434 if (child != None) 1501 if (child != None)
1435 { 1502 {
1436 proxy = x_dnd_get_window_proxy (dpyinfo, child_return); 1503#ifndef USE_XCB
1504 proxy = x_dnd_get_window_proxy (dpyinfo, child);
1505#else
1506 x_dnd_get_proxy_proto (dpyinfo, child, &proxy, proto_out);
1507#endif
1437 1508
1438 if (proxy != None) 1509 if (proxy != None)
1439 { 1510 {
@@ -1446,7 +1517,9 @@ x_dnd_get_target_window (struct x_display_info *dpyinfo,
1446 } 1517 }
1447 } 1518 }
1448 1519
1520#ifndef USE_XCB
1449 *proto_out = x_dnd_get_window_proto (dpyinfo, child); 1521 *proto_out = x_dnd_get_window_proto (dpyinfo, child);
1522#endif
1450 return child; 1523 return child;
1451 } 1524 }
1452 1525