Re: Back to copy/paste.
Re: Back to copy/paste.
- Subject: Re: Back to copy/paste.
- From: Harald Hanche-Olsen <email@hidden>
- Date: Fri, 18 Apr 2008 00:43:19 +0200 (CEST)
+ Nathan <email@hidden>:
> Here, let me start. I created a wiki page here:
>
> http://www.x.org/wiki/XDarwin_Clipboard
>
> Go look it over, and then tell me what I got wrong,
Okay, I'll bite.
First, a bit of terminology: I suggest sticking to these terms
consistently throughout:
- the pasteboard (used to be called the "cocoa clipboard" or "OS X
clipboard"): This is the name used in the pbcopy, pbpaste manual
pages and is much harder to confuse with the X11 clipboard
selection.
- the (X11) primary selection
- the (X11) clipboard selection
Now, to the "Current interaction between clipboards" section:
> when X11 gains focus: The cocoa clipboard is copied into the primary
> AND clipboard selection;
This is confusing: You just finished explaining that the X11
selections are POINTERS, not COPIES. So copying something to these
non-copies is nonsensical. Surely, what must happen is that some X
client claims ownership of the primary and clipboard selections?
(I presume that client is quartz-wm, though xlsclients does not list
quartz-wm as a client. Hidden by magic?)
(I am confused by the phrase "when OS X gains focus", since X11 also
runs under OS X. Isn't it better to say "when X11 loses focus"?)
More seriously, my experiments indicate that the description of what
actually happens is quite wrong. Here is what I get from extensive
experimentation.
- No matter who has focus, whenever text is copied to the pasteboard,
that text also becomes the clipboard selection.
- Whenever X11 gains focus, the pastboard contents becomes the primary
selection. Nothing happens to the clipboard selection.
- Whenever X11 loses focus, if the clipboard selection has changed
then it is copied to the pasteboard.
- However, if you have EVER used Edit -> Copy in X11, this action will
no longer happen (until you quit and restart X11).
Below are some details of my experimental setup (think of this as my
"materials and methods" section if you're scientifically inclined).
I run the following code in an X11 emacs to keep updating the
clipboard selection without the need for a focus transfer (just put it
in the *scratch* buffer and hit C-x C-e with the cursor behind the
text; use C-g to interrupt the infinite loop when done)
(let ((s 0) (c nil))
(while t
(setq s (1+ s))
(setq c (format "clip#%s" s))
(x-set-selection 'CLIPBOARD c)
(message c)
(sit-for 2)))
I then see messages clip#1, clip#2, ... appearing in emacs's
minibuffer at two second intervals. Now switch to a Terminal window
(not xterm), wait for a the clip#n to advance a step or two, and run
pbpaste. I see the clip#n that was in effect at the time of the focus
transfer, not the current one. Each time I switch to X11 and back I
get the one in effect at the time of the switch from X11. [Caveat:
don't click in the emacs window to bring focus back to X11, for then
emacs' input queue will be nonempty, and sit-for will return
immediately, and the loop will run amok.]
For the other direction, I run this in the X11 emacs to keep track of
stuff, then switch focus around and play with selections and using
pbcopy in a Terminal window (inside a loopy bit of shell script
similar to the above emacs code).
(while t
(message "primary: %s\nclipboard: %s"
(ignore-errors (x-get-selection 'PRIMARY))
(ignore-errors (x-get-selection 'CLIPBOARD)))
(sit-for 1))
- Harald
_______________________________________________
Do not post admin requests to the list. They will be ignored.
X11-users mailing list (email@hidden)
This email sent to email@hidden