aboutsummaryrefslogtreecommitdiffstats
path: root/src/xselect.c
diff options
context:
space:
mode:
authorPo Lu2022-10-17 20:56:20 +0800
committerPo Lu2022-10-17 21:00:09 +0800
commitabf683bb0324b9c5d01adb90aedb6aa6fa7175e9 (patch)
tree1f28271f1c12d4e7bbba87e39433f802d2d0d55c /src/xselect.c
parentb9aff5fdb89092b68ebd7782c8dc85e6daca14b2 (diff)
downloademacs-abf683bb0324b9c5d01adb90aedb6aa6fa7175e9.tar.gz
emacs-abf683bb0324b9c5d01adb90aedb6aa6fa7175e9.zip
Fix pieces of code being too expensive over slow network connections
* lisp/menu-bar.el (menu-bar-edit-menu): Test buffer-read-only before gui-backend-selection-exists-p. This places the less expensive condition before the more expensive one. * src/xfns.c (compute_tip_xy): Use cached monitor attributes whenever available. (Fx_show_tip): Remove code that really did nothing. (Fx_backspace_delete_keys_p): Do not download the entire keymap from the server upon creating a frame. * src/xmenu.c (create_and_show_popup_menu): Use x_translate_coordinates_to_root. (x_menu_show): Use x_translate_coordinates_to_root. * src/xselect.c (Fx_selection_exists_p): If a temporary selection owner can be found, use it. * src/xterm.c (x_translate_coordinates_to_root) (x_handle_selection_monitor_event, x_find_selection_owner): New functions. These functions try to avoid downloading data from the X server in places that are called very often (i.e. during tool bar updates.) (handle_one_xevent): Handle selection notify events. Also catch some mistakes found. Fetch all kinds of key names as well. (x_create_special_window): New function. (x_term_init, x_delete_display): Ask for all key names. Also, passively monitor selections that are given to `x-selection-exists-p' during redisplay, so we do not have to ask the server about them upon each redisplay. (syms_of_xterm): New variable `x-fast-selection-list'. * src/xterm.h (struct x_monitored_selection): New structure. (X_INVALID_WINDOW): New define. (struct x_display_info): New fields for selection monitoring. Also, record the fixes extension base.
Diffstat (limited to 'src/xselect.c')
-rw-r--r--src/xselect.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/xselect.c b/src/xselect.c
index 66782d41723..498c28af536 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -2376,12 +2376,19 @@ On Nextstep, TERMINAL is unused. */)
2376{ 2376{
2377 Window owner; 2377 Window owner;
2378 Atom atom; 2378 Atom atom;
2379#ifdef HAVE_XFIXES
2380 Window temp_owner;
2381#endif
2379 struct frame *f = frame_for_x_selection (terminal); 2382 struct frame *f = frame_for_x_selection (terminal);
2380 struct x_display_info *dpyinfo; 2383 struct x_display_info *dpyinfo;
2381 2384
2382 CHECK_SYMBOL (selection); 2385 CHECK_SYMBOL (selection);
2383 if (NILP (selection)) selection = QPRIMARY; 2386
2384 if (EQ (selection, Qt)) selection = QSECONDARY; 2387 if (NILP (selection))
2388 selection = QPRIMARY;
2389
2390 if (EQ (selection, Qt))
2391 selection = QSECONDARY;
2385 2392
2386 if (!f) 2393 if (!f)
2387 return Qnil; 2394 return Qnil;
@@ -2392,10 +2399,22 @@ On Nextstep, TERMINAL is unused. */)
2392 return Qt; 2399 return Qt;
2393 2400
2394 atom = symbol_to_x_atom (dpyinfo, selection); 2401 atom = symbol_to_x_atom (dpyinfo, selection);
2395 if (atom == 0) return Qnil; 2402
2403 if (!atom)
2404 return Qnil;
2405
2406#ifdef HAVE_XFIXES
2407 /* See if this information can be obtained without a roundtrip. */
2408 temp_owner = x_find_selection_owner (dpyinfo, atom);
2409
2410 if (temp_owner != X_INVALID_WINDOW)
2411 return (temp_owner != None ? Qt : Qnil);
2412#endif
2413
2396 block_input (); 2414 block_input ();
2397 owner = XGetSelectionOwner (dpyinfo->display, atom); 2415 owner = XGetSelectionOwner (dpyinfo->display, atom);
2398 unblock_input (); 2416 unblock_input ();
2417
2399 return (owner ? Qt : Qnil); 2418 return (owner ? Qt : Qnil);
2400} 2419}
2401 2420