Primary Selection clipboard does not work on Wayland+gtk3

Bug #1650298 reported by AndyAirey
38
This bug affects 7 people
Affects Status Importance Assigned to Milestone
Terminator
Incomplete
Low
Unassigned

Bug Description

When pasting using middle-click in Terminator it pastes the content from the main clipboard and not from Primary Selection.

To reproduce:
- Ctrl-C some text, from a browser for example
- Select other text from anywhere (browser, Terminator ...)
- Middle-click in Terminator

Expected Results:
- the contents of primary selection clipboard (select/middle-mouse) are pasted like in other GUI apps

Actual Results:
- the contents of the standard clipboard (ctrl-c/ctrl-v) are pasted.

This was working fine on X.org.
It started happening when starting to use Wayland on Fedora 25 with Gnome 3.22.
Tested against latest code, bzr revision 1684.

Tags: wayland
Revision history for this message
Stephen Boddy (stephen-j-boddy) wrote :

That's because I don't think Wayland supports primary selection by default yet.

It looks like the Gnome project may be trying to replace the functionality with their own implmentation. See here for a bit of detail:
http://www.phoronix.com/scan.php?page=news_item&px=GNOME-Mutter-Primary-Select&utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Phoronix+%28Phoronix%29

It looks like you should be on a new enough release, assuming you are using mutter. It's a bit hazy for me at the moment what if anything we can do. This is a window manager/desktop level feature, and I don't know that we would be expected to do anything differently in order to get the new implementation working. Needless to say, I don't use fedora, and I'm only on GTK 3.18, so I can't investigate myself for the moment.

As a workaround that might help in the interim, you could set the "Copy on select" option on in your profile. This should (hopefully) copy selections to the clipboard. Then middle click will paste the clipboard as before, but at least it's the right content. It does lose you the ability to have two stored chunks of text however.

Revision history for this message
AndyAirey (aairey) wrote :

It does support it, at leas on the implementation by Fedora 25[1] and Gnome 3[2].
As you can see from the Phoronix article it was merged in for the 3.20 release.

It works in any other application like firefox, gedit, empathy, gnome-terminal ...
Just in terminator the pasting does not work.

[1] https://fedoraproject.org/wiki/Wayland_features#BLOCKER:_primary_selection
[2] https://wiki.gnome.org/Initiatives/Wayland/PrimarySelection

tags: added: wayland
description: updated
Revision history for this message
Phill Kenoyer (phill-r) wrote :

For me it works everywhere except pasting into Terminator. The primary selection works in Terminator to middle click paste to other apps, but primary select does not middle click paste into Terminator at all unless the selection is copied to the clipboard (edit->copy).

Revision history for this message
Ryan Howe (rjhowe) wrote :

Since f25 does add this support. The following line is causing this to fail.

/usr/lib/python2.7/site-packages/terminatorlib/terminal.py

    use_primary = (display_manager() != 'WAYLAND')

Where because WAYLAND usually only supports one clipboard, this logic was added to address it.

As a work around I removed the logic and it works now.

   use_primary = display_manager()

I was not able to spend time digging into the code and what all should be added to fix this for a Distro that runs Wayland but still uses primary selection. I hope this helps.

Revision history for this message
AndyAirey (aairey) wrote :

Okay before anyone else has this issue.

I tried the above and now terminator is no longer working.
Getting the below error:

```
ERROR:dbus.proxies:Introspect error on :1.82:/net/tenshu/Terminator2: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
Traceback (most recent call last):
  File "/usr/bin/terminator", line 105, in <module>
    ipc.new_window_cmdline(optionslist)
  File "/usr/lib/python2.7/site-packages/terminatorlib/ipc.py", line 178, in _exec
    func(proxy, *args, **argd)
  File "/usr/lib/python2.7/site-packages/terminatorlib/ipc.py", line 184, in new_window_cmdline
    session.new_window_cmdline(options)
  File "/usr/lib64/python2.7/site-packages/dbus/proxies.py", line 70, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib64/python2.7/site-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib64/python2.7/site-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
```

Even tried reinstalling with DNF and it still gives me this error ...

Revision history for this message
AndyAirey (aairey) wrote :

Ok a reboot as mentioned here[1] solved my issue in #5.

Sorry for the noise.

Your workaround does indeed work for me!
Maybe we can add an extra check in terminatorlib/util.py that checks for a combination of wayland _and_ fedora?
In that case, let util.display_manager() return with another string than 'WAYLAND'.
That should solve the issue for now.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1402575

Revision history for this message
Stephen Boddy (stephen-j-boddy) wrote :

So I have no idea how to detect what version of Wayland is running, or alternatively how to query for supported features in the protocol. If someone could point me to this info I could probably make Terminator do the right thing here.

My fallback is to have *another* config option for working around the earlier Wayland not supporting primary. But it does require the user understanding yet another option.

Opinions? Suggestions? Pointers?

Changed in terminator:
status: New → Incomplete
importance: Undecided → Low
Revision history for this message
Stephen Boddy (stephen-j-boddy) wrote :

Hmmm. In case it wasn't clear from my previous messages:

At one point Wayland did not have a PRIMARY, only a CLIPBOARD. A workaround was implemented in Terminator that along with "copy on select" allowed you to highlight, then middle-click to paste.

Now Wayland does have both, but if I remove the workaround to give both PRIMARY and CLIPBOARD, then I break older Wayland behaviour. I've found nothing telling me how to determine which version of Wayland I'm running on so that I can decide what action to take.

Revision history for this message
Lfarkas (lfarkas) wrote :

imho the latest terminator should have to support the latest wayland! so please fix it! and by default add a workaround for older wayland (and probably a readme or faq would be useful to clear the current situation and for which combination of terminator and wayland which setting should have to use. it's a very annoying now!

Revision history for this message
AndyAirey (aairey) wrote : Re: [Bug 1650298] Re: Primary Selection clipboard does not work on Wayland+gtk3

It's not about older vs newer Wayland.
It's about Fedora Wayland vs default Wayland.

Upstream Wayland has not implemented Primary Selection.
At least not the last time I checked, which was when opening this bug.

On Wed, 22 Feb 2017 at 10:26 Lfarkas <email address hidden> wrote:

> imho the latest terminator should have to support the latest wayland! so
> please fix it! and by default add a workaround for older wayland (and
> probably a readme or faq would be useful to clear the current situation
> and for which combination of terminator and wayland which setting should
> have to use. it's a very annoying now!
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1650298
>
> Title:
> Primary Selection clipboard does not work on Wayland+gtk3
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/terminator/+bug/1650298/+subscriptions
>

Revision history for this message
Stephen Boddy (stephen-j-boddy) wrote :

As the maintainer I'm going to second what AndyAirey said, as far as I can tell this is not upstream, and RedHat are out on their own with this. I didn't realise this was a RH exclusive, I thought it was just a question of wayland versions. I'm not going to add yet more knobs to Terminator to accommodate that, as then I have to implement every thing with an associated knob. We already have a pretty complex configuration dialog as it is.

I still haven't found any way to determine if the primary buffer is present and usable with Wayland, which would be the ideal way.

@Lfarkas: peppering your messages with exclamation marks demanding I fix it is rather rude. And, before you point out the "please", no that doesn't mitigate the peremptory tone. I will take on board an action to update the documentation, which needs a good update before the 2.0 "blessed" release, to make the situation clear. If you take objection to my approach, feel free to start researching and figuring out how to properly detect the wayland/primary presence, and I will sing your praises on the day your patch lands in my inbox.

Revision history for this message
Lfarkas (lfarkas) wrote :

first of all i wouldn't like to be rude, so sorry if you feel that.

so i'm just made a quick research in fedora 25 that all of
- wayland 1.12.0,
- xorg-x11-server 1.19.1 (from which xorg-x11-server-Xwayland comes),
- gnome-session 3.22.2 (from where gnome-session-wayland-session) comes and
- gtk3 3.22.8
are the latest and released version without any patch. ie all primary selection in wayland already upstream. anyway AFAIS the code is not in wayland itself but in but in gtk3's gdk/wayland/gdkselection-wayland.c so if terminator would use primary instead of clipboard that it'd working on these latest version of packages. i hope it's help.

Revision history for this message
Lfarkas (lfarkas) wrote :

and it seems here is a much more technical description: https://bugzilla.redhat.com/show_bug.cgi?id=1404432

Revision history for this message
AndyAirey (aairey) wrote :

@Lfarkas at least now you made a constructive reply ;)

It seems I was mistaken. I haven't delved in the code, so it was a mere
assumption that Primary Selection was only available in Fedora's Wayland.
As from the BugZilla it appears it is implementend within mutter.

I think we have two options here:
1. somehow check for mutter.gnome-shell (and preferably it's version too)
from within util.display_manager()
2. do not do anything specific in terminator.py in case of 'WAYLAND' and
test it on other systems than Fedora that use WAYLAND.

The second option would be the cleanest and least work for sure :)
Although it does require testing on other distros.

On Thu, 23 Feb 2017 at 17:01 Lfarkas <email address hidden> wrote:

> and it seems here is a much more technical description:
> https://bugzilla.redhat.com/show_bug.cgi?id=1404432
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1650298
>
> Title:
> Primary Selection clipboard does not work on Wayland+gtk3
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/terminator/+bug/1650298/+subscriptions
>

Revision history for this message
Stephen Boddy (stephen-j-boddy) wrote :

@Lfarkus like Andy said, that was much more constructive. I've wrapped myself in a bit of knot trying to figure out the proper course of action. From reviewing things I added this deviation for Wayland when fixing a keybinder issue which was also broken with wayland. It seemed like a good idea at the time, but obviously it's now causing a problem. I think now I need to check if the display = wayland, and the gtk version < 3.20, and only then use the workaround. Maybe there's a better way, but in my sleep deprived state, I'm not seeing it.

On a personal note, I just started a new contract that requires a pretty long and draining commute, and I'm struggling/lacking in the sleep department, giving me a noticeably shortened tolerance. Once I get a good nights rest I may look at my response to you, and feel like I over-reacted and a little chagrin.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.