]> git.lyx.org Git - features.git/commitdiff
Only set dummy X11 selection if we do not own it
authorScott Kostyshak <skostysh@lyx.org>
Sat, 28 Mar 2020 01:23:08 +0000 (21:23 -0400)
committerScott Kostyshak <skostysh@lyx.org>
Mon, 4 May 2020 12:58:56 +0000 (08:58 -0400)
Before, we would continually set the selection to the empty string,
to maintain ownership. This causes problems with clipboard managers
GPaste and CopyQ. Further, in theory this should have better
performance since checking ownership should be faster than setting.

A disadvantage of this change is that the timestamp of the selection
will be old at this point in the code. However, when the selection
is requested, we put the selection contents at that point so the
selection timestamp should be accurate then. Further, the selection
contents are not accurate at this point in the code (they are just
the empty string), so it is not clear whether having an accurate
timestamp is beneficial.

Fixes #11715.

src/frontends/qt/GuiSelection.cpp

index 288cb18432cfbc7eb8a763b0acf42b4b136146d9..7e9d29ff060289af05d1ee62a90eb7725e07a429 100644 (file)
@@ -51,9 +51,10 @@ void GuiSelection::haveSelection(bool own)
        // an application actually requests it.
        // This way calling Selection::have() is cheap and we can do it as
        // often as we want.
-       //LYXERR(Debug::SELECTION, "GuiSelection: setting dummy selection");
-       if (own)
+       if (own && !qApp->clipboard()->ownsSelection()) {
+               LYXERR(Debug::SELECTION, "GuiSelection: setting dummy selection");
                qApp->clipboard()->setText(QString(), QClipboard::Selection);
+       }
        // We don't need to do anything if own = false, as this case is
        // handled by QT.
        // FIXME (gb): This is wrong. What is missing here is rather a call of