[Xquartz-dev] Proposal for PRIMARY and CLIPBOARD Copy/Paste

Jeremy Huddleston jeremyhu at apple.com
Thu Sep 11 19:32:51 PDT 2008


On Sep 11, 2008, at 17:58, George Peter Staplin wrote:

> Quoted Jeremy Huddleston <jeremyhu at apple.com>:
>
>>
>> On Sep 11, 2008, at 16:18, George Peter Staplin wrote:
>>
>>> Quoted Jeremy Huddleston <jeremyhu at apple.com>:
>>>
>>>> Ok, my original response was over iPhone, so I couldn't really
>>>> elaborate too much...  here's the basic logic/pseudocode for how  
>>>> this
>>>> should work:
>>>>
>>>> Event PRIMARY changed (ie someone selected new text):
>>>> 	if option_proxy_on_select:
>>>> 		PRIMARY -> PB
>
> How do you detect the selection when not every toolkit will set the
> selection owner when text changes?

You don't.  That's also why this is disabled by default.

>  I think it's asking for trouble to
> have every toolkit set the owner after a change.  We'd have to
> probably patch Tk, Motif, and lots of legacy apps.  Some of which may
> be compiled statically and running remotely...

Well, like I mentioned, it's disabled by default and provided for  
people that have asked for it and want it and understand this  
limitation.  In other words, that's not your problem.

>
>
>>>> Event X11.app Edit->Copy menu item:
>>>> 	PRIMARY -> PB
>>>>
>>>> Event CLIPBOARD changed:
>>>> 	if option_proxy_CLIPBOARD:
>>>> 		CLIPBOARD -> PB
>
> How do you detect that?  You have to do an XConvertSelection to see if
> it has changed, and process the SelectionNotify...  We can detect when
> the owner changes, but not when the actual contents have changed,
> unless we retrieve the contents.

You mentioned that pbproxy would be greedy to maintain ownership of  
CLIPBOARD.  It will notice this when someone takes CLIPBOARD away from  
it.

>>>> Event PB updated:
>>>> 	if option_proxy_pb_to_clipboard:
>>>> 		PB -> CLIPBOARD (this involves "grabbing" the CLIPBOARD)
>>>> 	if option_proxy_pb_to_primary:
>>>> 		PB -> PRIMARY (essentially same as above)
>>>>
>>>> Event server asks for PRIMARY/CLIPBOARD:
>>>> 	get what's in PB and return
>>>
>>> This won't work correctly in some cases from what I see.  The
>>> CLIPBOARD and PRIMARY selections are just owned.  And once owned it
>>> seems not all X11 apps will set ownership again (e.g. Tk and  
>>> possibly
>>> others).  They don't technically have to.  So we have the same
>>> ambiguous situation as before.
>>
>> We don't care if TK "resets" that it owns PRIMARY.  Primary is  
>> proxied
>> on the Edit->Copy event, so the "new" value is proxied even if it
>> doesn't "reassert" its claim on the second selection.
>
> I think our images of how this works differ, but I'm not certain how
> to clarify my image, and understand yours better.

I'm essentially saying that you don't really need to care about that  
particular hangup because you'll never encounter it in the default  
configuration, and powerusers who enable the 'proxy on select' will  
just have to be happy with it working when it works and not expect it  
to work in some aps (like Tk based ones).

>> As far as CLIPBOARD goes... I think most people concerned with
>> CLIPBOARD will be using GTK which doesn't exhibit this problem... but
>> your "make pbproxy proxy/cache/reclaim CLIPBOARD" approach might work
>> here as a solution.  But you should definitely not do that for  
>> PRIMARY
>> (since it would cause selected text to always unselect).
>
> I don't know.  To me it seems simpler now to add 2 menu items.

No.

> 1. PRIMARY=None CLIPBOARD=None PB=unknown
>    select text in a text widget
> 2. PRIMARY=textWindow CLIPBOARD=None PB=unknown
>    Gimp image copy via an Edit->Copy menu item
> 3. PRIMARY=textWindow CLIPBOARD=imageWindow PB=unknown
>    XQuartz Edit->Copy
>
> What do we copy?

The gimp image after stage 2 (ie, your PB=unknown in 3 should be  
PB="gimp image").  The selection after stage 3.  That's the only thing  
that is HIG compliant, and the only thing that should really be  
expected.

> 1. PRIMARY=None CLIPBOARD=NONE PB=unknown
>    Gimp image copy via Edit->Copy menu item
> 2. PRIMARY=None CLIPBOARD=imageWindow PB=unknown
>    select text in a text widget
> 3. PRIMARY=textWindow CLIPBOARD=imageWindow PB=unknown
>    XQuartz Edit->Copy
>
> What do we copy?

Before stage2, PB should be the gimp image instead of unknown.
After stage 3, PB should be the text.

--Jeremy

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3221 bytes
Desc: not available
Url : http://lists.macosforge.org/pipermail/xquartz-dev/attachments/20080911/0ebf251c/attachment-0001.bin 


More information about the Xquartz-dev mailing list