Am Donnerstag, 4. Januar 2007 13:07 schrieb Abdelrazak Younes: > Georg Baum wrote: > > Apart from that I don't think that I am missing something. The X selection > > gets filled if another X application requests it (see the documentation of > > Selection::put, until yesterday I did not fully understand that). We don't > > care at all about the X selection except for the following cases: > > > > - Another app requests our selection. This is handled in > > GuiApplication::x11EventFilter. isInternal() is not needed. > > OK. > > > - We want to paste the selection by middle mouse button. Then we either > > paste the internal one if cur.selection() is true, or else we call > > theSelection()->get(). We don't need isInternal() here, cur.selection() is > > less expensive and does exactly what we need. You certaionly don't want to > > treat selection by keyboard differently than selection by mouse here? > > Sure I want. The X selection should be filled in only when using the mouse!
What do you mean by X selection now? If you mean what is modeled by frontend::Selection then you are wrong. That selection is only filled if another app explicitly requests it, never as a response to some user action (mouse or keyboard). And if another app requests the selection from LyX, then it should get it, regardless how it was set. But even if you don't agree with that last sentence: isInternal() does not help to implement something else. If you mean what LyX maintains as selection in the kernel: Then Selection::isInternal() can not tell you whether it came from the mouse or from the keyboard. > Therefore I make a clear distinction between text selected by the > keyboard and text selected by the mouse. This is the reason why we need > isInternal() here. I don't agree that we need that clear distinction, but even if we put that aside for a moment: Can you show me how isInternal() could help to make this distinction? I honestly don't see how that could work. > I want to set the X selection in those cases: > > 1) dragging the mouse with left button > 2) left button double-click > 3) left button triple-click > 4) ctrl+left button click > > But not when selecting with the keyboard because: > 1) I want this last operation to be very fast and filling in a new cut > at each arrow key press is stupid. > 2) I want to reuse the current X selection. Why should that be emptied > if I didn't touch the mouse since the last selection? Because of the "simple model": The selection is the highlighted text. No highlighted text - no selection. If there are several windows with highlighted text the selection is the latest text that was highlighted. > 3) It is clearly wrong to emptied the X selection (that could have been > filled in by another app) with only the keyboard. The X selection should > be emptied with a mouse click only! That is against the "simple model" that is described in http://freedesktop.org/wiki/Standards_2fClipboardsWiki. > Hope I am clear now but all of this was very obvious to me. To me it is rather obvious that we don't want 2) and 3) (but I know that Bo likes to have something else, so this has to be discussed). The most important point is this: All this has nothing to do with isInternal(), but rather with the fact whether a certain key press or mouse movement should change the selection or not. We don't need isInternal() to decide that, we rather need to make that decision in the code that handles key presses, mouse events etc, and call a function that tells X that we now own the newest selection, or that our selection has been cleared (this is currently done by haveSelection()). If you still don't believe me that isInternal() is not needed please show me some code that proves that I am wrong. Georg
