]> git.lyx.org Git - lyx.git/commitdiff
* src/frontends/qt4/GuiSelection.C
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Fri, 5 Jan 2007 10:32:07 +0000 (10:32 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Fri, 5 Jan 2007 10:32:07 +0000 (10:32 +0000)
(GuiSelection::haveSelection): Add a big comment what we actually do
here, and why. It took me quite some time to figure that out.

* src/frontends/Selection.h
(haveSelection): Add more detailed documentation

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16527 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/Selection.h
src/frontends/qt4/GuiSelection.C

index fd9c88973468049f1ed278e6ab1d38d356417e74..6c7e7829827cb1a4e0688e883f52f6b314500835 100644 (file)
@@ -27,7 +27,15 @@ class Selection
 public:
        virtual ~Selection() {}
 
-       /// Tell the window system whether we have a selection.
+       /**
+        * Tell the window system whether we set or cleared our selection.
+        * This is a noop on systems that don't have a selection.
+        * This should be called by the kernel whenever a selection is
+        * created, changed or cleared.
+        * \param own
+        * If true: Tell that we got a valid selection.
+        * If false: Tell that we cleared our selection.
+        */
        virtual void haveSelection(bool) = 0;
        /**
         * Get the X selection contents.
index 83c3dfb625bcefb028be1e492232a8c23275048d..3a59d515cabb4779363ca1110fa361a318fdf4a7 100644 (file)
@@ -35,6 +35,15 @@ void GuiSelection::haveSelection(bool own)
        if (!qApp->clipboard()->supportsSelection())
                return;
 
+       // Tell qt that we have a selection by setting a dummy selection.
+       // We don't use the interface provided by Qt for setting the
+       // selection for performance reasons (see documentation of
+       // Selection::put()). Instead we only tell here that we have a
+       // selection by setting the selection to the empty string.
+       // The real selection is set in GuiApplication::x11EventFilter when
+       // an application actually requests it.
+       // This way calling Selection::have() is cheap and we can do it as
+       // often as we want.
        if (own)
                qApp->clipboard()->setText(QString(), QClipboard::Selection);
        // We don't need to do anything if own = false, as this case is