diff options
author | Po Lu <luangruo@yahoo.com> | 2022-10-17 20:56:20 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-10-17 21:00:09 +0800 |
commit | abf683bb0324b9c5d01adb90aedb6aa6fa7175e9 (patch) | |
tree | 1f28271f1c12d4e7bbba87e39433f802d2d0d55c /src/xselect.c | |
parent | b9aff5fdb89092b68ebd7782c8dc85e6daca14b2 (diff) | |
download | emacs-abf683bb0324b9c5d01adb90aedb6aa6fa7175e9.tar.gz |
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.c | 25 |
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. */) { Window owner; Atom atom; +#ifdef HAVE_XFIXES + Window temp_owner; +#endif struct frame *f = frame_for_x_selection (terminal); struct x_display_info *dpyinfo; CHECK_SYMBOL (selection); - if (NILP (selection)) selection = QPRIMARY; - if (EQ (selection, Qt)) selection = QSECONDARY; + + if (NILP (selection)) + selection = QPRIMARY; + + if (EQ (selection, Qt)) + selection = QSECONDARY; if (!f) return Qnil; @@ -2392,10 +2399,22 @@ On Nextstep, TERMINAL is unused. */) return Qt; atom = symbol_to_x_atom (dpyinfo, selection); - if (atom == 0) return Qnil; + + if (!atom) + return Qnil; + +#ifdef HAVE_XFIXES + /* See if this information can be obtained without a roundtrip. */ + temp_owner = x_find_selection_owner (dpyinfo, atom); + + if (temp_owner != X_INVALID_WINDOW) + return (temp_owner != None ? Qt : Qnil); +#endif + block_input (); owner = XGetSelectionOwner (dpyinfo->display, atom); unblock_input (); + return (owner ? Qt : Qnil); } |