# HG changeset patch # User Richard M. Stallman # Date 917208394 0 # Node ID 719325fbe6a1d62e4c1950c0db47af37654b5b2f # Parent 93161ca8b2e56b9e4c20bc05969bcf7941be4368 (x_handle_selection_clear): Don't clear the selection if Emacs still owns it through a different display. diff -r 93161ca8b2e5 -r 719325fbe6a1 src/xselect.c --- a/src/xselect.c Sun Jan 24 14:13:32 1999 +0000 +++ b/src/xselect.c Sun Jan 24 20:06:34 1999 +0000 @@ -755,7 +755,7 @@ } } -/* Handle a SelectionClear event EVENT, which indicates that some other +/* Handle a SelectionClear event EVENT, which indicates that some client cleared out our previously asserted selection. This is called from keyboard.c when such an event is found in the queue. */ @@ -770,6 +770,26 @@ Lisp_Object selection_symbol, local_selection_data; Time local_selection_time; struct x_display_info *dpyinfo = x_display_info_for_display (display); + struct x_display_info *t_dpyinfo; + + /* If the new selection owner is also Emacs, + don't clear the new selection. */ + BLOCK_INPUT; + /* Check each display on the same terminal, + to see if this Emacs job now owns the selection + through that display. */ + for (t_dpyinfo = x_display_list; t_dpyinfo; t_dpyinfo = t_dpyinfo->next) + if (t_dpyinfo->kboard == dpyinfo->kboard) + { + Window owner_window + = XGetSelectionOwner (t_dpyinfo->display, selection); + if (x_window_to_frame (t_dpyinfo, owner_window) != 0) + { + UNBLOCK_INPUT; + return; + } + } + UNBLOCK_INPUT; selection_symbol = x_atom_to_symbol (dpyinfo, display, selection);