emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

X selections and multi tty


From: Chong Yidong
Subject: X selections and multi tty
Date: Thu, 26 May 2011 18:49:12 -0400

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?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]