Re: [Owen Taylor <otaylor redhat com>] Re: copied item going away when you close the window you copied from



I'm currently working for a company porting an application from BeOS
to Linux. I've struggled long and hard with the differences between
the clipboard mechanism and the X selection mechanism. I agree with
Havoc's clipboard document. I have one clarification concerning
the primary selection being a sort of secret for experts. The
primary selection really is just a short cut form of drag and drop.

Thee second issue is the fact that the application I'm porting handles
a vastly richer pallete of data formats than most apps I've seen on
X. It supports almost every known bitmap format, and even most m$ office
formats. BeOs uses mime types to describe its clipboard contents (well,
actually the "promised" types the app can support.)

Another mechanism I've seen used on other platforms is to promise a
selection (for example if it was very large), then when the app is
dimissed it asks the user if they would like to actually do the
copy to the clipboard. 

I do think Gnome/Gtk (at one of these levels) needs something equivalent
to the old xclipboard program (perhaps with a panel applet interface to
the background daemon.) The problem is that no app can know when another
app grabs the selection unless they own it. The method used in
xclipboard 
is to always reclaim it and force copying of the clipboard contents.
Would it be possible to use one of the normally unused selections as a 
notifier? For example, the  background always owns the secondary
selection. 
Whenever any app asks for the primary or clipboard selections, they also 
claim the secondary and the daemon immediately asks for it back, in the 
process transfering info about the selection. This way the daemon can 
keep track of who has the selection without forcing copying of the 
contents.

Lastly, one other interesting feature of BeOS is the TranslatorRoster. This
is a service provided by the OS that allows translators (as shared libraries)
to register themselves with the OS so applications can use them to do 
conversions of various mimetypes either from the clipboard or other streams.
The app simply presents a given mimetype and a desired mimetype and the
roster queries each Translator to see if it supports the conversion. If 
one is found it is asked to do the translation. The advantage being that
apps don't have to support a multitude of formats. And there is a centralized
standard for tranlator writers to adhere to. 

Tomy




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