Text selected in SciTE 4.4.6 is not pasted into another application (including gnome-terminal) when the middle button is pressed.
Running:
WAYLAND_DEBUG=1 scite README 2>&1 | grep -i primary_selection_offer
Then selecting some text in SciTE does not generate any new terminal output.
Contrast this by replacing scite with gedit.
Gentoo Linux
GTK 3.24.24
Mutter 3.38.2
wayland 1.18.0
wayland-protocols 1.2
gnome-terminal 3.36.2
Reproduced on Ubuntu 20.10. It does however work when SciTE is built for GTK 2.x.
FWIW, GTK2 does not support Wayland, so it'll be using XWayland, which I guess will be bridging the primary selection behavior itself.
Seeing the same problem with geany, which employs scintilla as its editor component. Adding this here for the benefit of other new wayland users. Thank you for scintilla!
GTK was using a private protocol for primary selection on Wayland but moved to the standard with 3.24.24. It does not look like there will be much work don on this area of GTK 3.x as 4.x is now the focus.
https://gitlab.gnome.org/GNOME/gtk/-/issues/2591
While I haven't read much of the GTK sources, it appears that on Wayland, it makes simple primary selection setting
gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), s, -1);work but not the more complexgtk_selection_owner_setwith callbacks to provide the data.Scintilla could
gtk_clipboard_set_texteach time the selection changes but that seems expensive as the user may drag the mouse over hundreds of characters per second. It also doesn't provide a signal for when another application has claimed the primary selection which is used to change the selection colour to show it is no longer primary.Instead,
gtk_clipboard_set_with_datacan be used as this allows lazily allocating and providing the selection text. It also receives a signal through its clear function when another application claims primary.Attached is a patch that does this and which is working OK on Ubuntu 21.04 with GTK 3.24.25. There's also code that would be removed for this change but this is not included in the patch as it makes it more complex to understand.
Its potentially a bit slower than needed as it calls
gtk_clipboard_clearandgtk_clipboard_getfor every change in selection. Keeping a singlegtk_clipboard_getopen led to stale text after another application had retrieved the primary selection from Scintilla. It would be possible to set a flag in the get function that then started a newgtk_clipboard_geton the nextClaimSelection.That works for me, added to SciTE 5.0.2 on Gentoo Linux, GTK 3.24.28, GNOME 40. Thanks!
Committed fix as [921cb3] . This goes beyond the earlier patch by removing the old primary selection code.
This revision worked well for me on Ubuntu 21.04 with gedit and GNOME Terminal. It worked mostly with LibreOffice Writer but, if some text is selected in Writer; then some text is selected in SciTE; then middle click in Writer (without otherwise focusing it) the result is that the text that was selected earlier in Writer is pasted rather than the text from SciTE.
As this change may do more work, slow downs, possibly with rapidly changing selections, should be reported. There could be a flag to turn off primary selection if it is too expensive in some situations.
Related
Commit: [921cb3]