all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@stupidchicken.com>
To: emacs-devel@gnu.org
Subject: X selections and multi tty
Date: Thu, 26 May 2011 18:49:12 -0400	[thread overview]
Message-ID: <87hb8h2i3b.fsf@stupidchicken.com> (raw)

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	other threads:[~2011-05-26 22:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-26 22:49 Chong Yidong [this message]
2011-05-27  0:47 ` X selections and multi tty Stefan Monnier
2011-05-27  2:47   ` Chong Yidong
2011-05-27  3:43   ` Chong Yidong
2011-05-27 12:33     ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87hb8h2i3b.fsf@stupidchicken.com \
    --to=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.