Clipboard for the dummies

Lubos Lunak l.lunak at suse.cz
Fri Nov 1 11:03:58 GMT 2002


 After talking to some people, looks like the previous mail was too 
complicated. Let's try it in a different way, so maybe now actually somebody 
says something.
 (Havoc: please grep for your name :)  )
 
Definition of terms:
clipboard - copied in using Ctrl+C, Ctrl+X, pasted using Ctrl+V
selection - the thing pasted with MMB, copied by selecting some text (whether 
only by mouse or also by keyboard is unclear, we have it inconsistent right 
now, and need to decide)
selected text - selected text, I use a different term than 'selection' because 
they're not always the same (again, it's inconsistent, and we need to decide)

 Also, selection and clipboard are completely separate, at least from the 
implementation point of view. Having a Klipper setting for automatic 
selection->clipboard syncing (one-way, off by default) seems to be acceptable 
and harmless, besides the broken KDE2 behaviour, which many people want for 
some reason. The following is about when they're completely separate, people 
wanting the syncing should keep in mind their setting while reading the 
following. I'm not going to talk about clipboard at all, only about selection 
and selected text. There's completely no problem with clipboard. Users who 
don't know about the selection feature shouldn't have a problem at all.

 There's no official documentation on how the selection should work, at least 
I'm not aware of any (please enlighten me in case there is). There are only 
unofficial documents describing how it should be done, there's how plain X 
apps (xedit,...) do it, there's how other (Gtk, etc.) apps do it. The only 
thing on which everybody agrees is that LMB selects and MMB pastes it 
afterwards, all remaining details differ.

 The most in-the-spirit-of-X11 way, which Gtk, xedit use, is like this: 
Selection is selected text, and selected text is selection (the ONLY 
selection). Which means:
- selected text, no matter how selected, will be pasted by MMB
- if there's nothing selected, MMB won't do anything
- if you open a dialog with a lineedit which autoselects the text (i.e. the 
default, but you can start typing whatever you want immediately), this 
becomes the selection pasted by MMB, and as soon as the dialog is closed, MMB 
will paste nothing
- if you select something in one app, previous selected text is unselected, no 
matter where it was, even in other app (this a bit conflicts with the 'if you 
don't know about MMB, it won't get in your way at all' claiming)

I guess that's all (Havoc?). I suggest you turn off Klipper and play with some 
Gtk2 app for a while if you can.

 Other apps, including KDE apps, usually use a less consistent mess, by 
allowing one or more of the following:
- only text selected by the mouse becomes the selection (i.e. not text 
selected by keyboard, or autoselected lineedits)
- when there's no selected text, selection is still remembered (the last valid 
selection) - this is why Qt lineedits unselect on focus out, while Gtk ones 
don't
- when a text is selected elsewhere, previously selected text stays selected
- explicit actions like 'copy link location' set selection, even if there's no 
text selected (I couldn't find any such action in any Gtk2 app to test, 
Havoc?)
- let's ignore the KDE2 style behaviour of mixing clipboard and selection, 
which e.g. Emacs uses too, according to Havoc

 When all this summed up (except for the clipboard and selection mixing), it's 
the other solution I included in the previous mail (let's call this variant 
the 'Joe User solution'). Both of the extremes seems most consistent 
solutions to me, but we can even choose something inbetween.

 I'd personally like the Joe User way of doing it, as I find this one the best 
from the users point of view, and certain features of the X11-pure style can 
be seen as misfeatures, but I expect a lot of people wouldn't like this and 
would want the X11-pure style solution. Maybe we could have a setting for 
either the Joe User way or the X11-pure style for the old fashioned ones, but 
we should have a one, at most two ways of doing it - right now, all of the 
four points above are true in some KDE/Qt apps/widgets and not in others. 
Remember, it would be nice if we did it the same way like others do, so we'd 
have to make at least Qt and Gtk work the same, in case we don't go with the 
X11-pure style (Havoc: any chance?).

 Now, in case somebody cares, please say something. Try it during the weekend 
as your homework ;). Ask if you don't understand something, choose something, 
suggest a better solution (or just say that you don't care - I can do other 
things then).

 PS: Just in case you noticed, the recent qt-copy snapshot has a QLineEdit 
bug, which prevents MMB pasting from working. Already reported to TT.

-- 
Lubos Lunak
KDE developer
---------------------------------------------------------------------
SuSE CR, s.r.o.  e-mail: l.lunak at suse.cz , l.lunak at kde.org
Drahobejlova 27  tel: +420 2 9654 2373
190 00 Praha 9   fax: +420 2 9654 2374
Czech Republic   http://www.suse.cz/



More information about the kde-core-devel mailing list