From: Georg Baum Date: Fri, 5 Jan 2007 10:32:07 +0000 (+0000) Subject: * src/frontends/qt4/GuiSelection.C X-Git-Tag: 1.6.10~11331 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=690a630c5ec361c50be7b6c84d5f9963948a1b3c;p=lyx.git * src/frontends/qt4/GuiSelection.C (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 --- diff --git a/src/frontends/Selection.h b/src/frontends/Selection.h index fd9c889734..6c7e782982 100644 --- a/src/frontends/Selection.h +++ b/src/frontends/Selection.h @@ -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. diff --git a/src/frontends/qt4/GuiSelection.C b/src/frontends/qt4/GuiSelection.C index 83c3dfb625..3a59d515ca 100644 --- a/src/frontends/qt4/GuiSelection.C +++ b/src/frontends/qt4/GuiSelection.C @@ -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