]> 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>
Wed, 6 May 2020 12:29:00 +0000 (08:29 -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.

(cherry picked from commit af4ee1a487c4d899b71df02ba57c2f024fea6786)
(cherry picked from commit 23abb5aaa36af07aadfa5e565869104778ba0d6d)

src/frontends/qt4/GuiSelection.cpp
status.23x

index fef258c326a4dc89434e6991babcde79d2f5f64e..f5259424f247f4b2d4ac6aaee400c836636b481f 100644 (file)
@@ -51,14 +51,15 @@ 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
-       //else
        //      qApp->clipboard()->clear(QClipboard::Selection);
+       // when own is false.
        // Since we do not issue this call we rather implement
        // "persistent selections" as far as X is concerned.
 }
index 81ebd0dc8b5d399c93d529555e283e6523b80e19..0d0c1815b4590b190521c5eafabfcc44c8d5307a 100644 (file)
@@ -119,6 +119,8 @@ What's new
 
 - Do not insert \textquoteright with Hunspell (bug 11832).
 
+- Fix disappearing selection with clipboard managers on X11 (bug 11715).
+
 
 * INTERNALS