all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* X selections and multi tty
@ 2011-05-26 22:49 Chong Yidong
  2011-05-27  0:47 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Chong Yidong @ 2011-05-26 22:49 UTC (permalink / raw)
  To: emacs-devel

I'm doing a cleanup of xselect.c, and came across something puzzling.

AFAIU, clipboards and other X selections are per-X-server, which
corresponds to terminal objects in Emacs (or close enough; each terminal
corresponds to an X display opened by XOpenDisplay).

Emacs currently uses a global variable, Vselection_alist, to keep track
of what X selections it controls.  This seems incorrect, and OTOH it
should lead to funky behavior when you use the same Emacs session on two
different X servers.

For instance, Emacs might own the clipboard on two X servers
simultaneously; when it receives a SelectionClear on one, it will act as
though it's lost the clipboard period---when in fact the second X server
still think Emacs owns the clipboard.

The obvious solution seems to be to change Vselection_alist into a
terminal-local variable.  However, there exists this code in
x_handle_selection_clear:

  /* 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->terminal->kboard == dpyinfo->terminal->kboard)
      {
	Window owner_window
	  = XGetSelectionOwner (t_dpyinfo->display, selection);
	if (x_window_to_frame (t_dpyinfo, owner_window) != 0)
	  {
	    UNBLOCK_INPUT;
	    return;
	  }
      }
  UNBLOCK_INPUT;

This contradicts what I thought: it assumes that if Emacs owns the
selection on a different display, it doesn't need to relinquish
ownership of the selection.

Anyone know what's going on?



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-05-27 12:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-26 22:49 X selections and multi tty Chong Yidong
2011-05-27  0:47 ` Stefan Monnier
2011-05-27  2:47   ` Chong Yidong
2011-05-27  3:43   ` Chong Yidong
2011-05-27 12:33     ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.