On Linux, X selection updating prematurely when selecting text

Here’s my debug info from the About screen:

Anki 24.04.1 (ccd9ca1a)  (ao)
Python 3.9.18 Qt 6.6.2 PyQt 6.6.1
Platform: Linux-6.8.5-zen1-1-zen-x86_64-with-glibc2.38

===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
AnkiConnect ['2055492159', 2024-02-27T04:37, 'None', '']

===IDs of active AnkiWeb add-ons===

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])

I have searched about to see if I could find anyone else mention this issue (on github, the forum, the general web) but couldn’t see it.

In linux, in addition to the familiar copy-paste clipboard, there’s a ‘selection’ made when you highlight text with the cursor and normal behavior is for this selection to be updated when releasing the mouse button - you can paste said selection with the middle mouse button.

Anki appears to update this multiple times as you drag with the mouse.

I use a script (on a system level, not within Anki specifically) which monitors the selection for changes and processes it, which is why I noticed this probably rather obscure bug.

It doesn’t appear to be normal QT application behavior (e.g. Kate, another QT 6 app, only updates the x selection when releasing the mouse button)

Thanks for your time.

You’ll need to poke about in editor.py to see if you can figure out why it’s happening. On a Linux system here, _on_clipboard_change() is only called for me when an Anki receives focus, not as dragging is done.

Thanks for the suggestion, I don’t think I know enough to meaningfully poke about the source code. I’m really not a programmer, although I will sometimes hit my head against the wall until I get a script to do something I want.

I think the issue is unrelated to the editor screen (although it does also behave that way)
for example, here’s what monitoring the selection in a simple loop does when selecting text on the Statistics window:

I tried cloning the repo and grepping the whole source code for ‘select’ just to see if something jumped out at me as a thing I should check out but I have no idea!

For an idea of how other software handles the x selection clipboard

If it happens with the editor not opened, maybe it’s something related to Qt webviews. You could try another webview-using app, like qutebrowser.

I tried qutebrowser and it indeed behaves the same strange way.

Does that mean it has something to do with the behavior of this ht-tps://qtwebkit.github.io/doc/qtwebkit/qwebview.html#selectionChanged ?

I’m not sure where I can raise an issue with them, I found a repository without issues enabled… ht-tps://github.com/qt/qtwebkit any ideas?

Please see Report an issue to Qt · Issue #2652 · ankitects/anki · GitHub

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.