After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 758396 - Clipboard of terminal get out of sync with the main clipboard on Wayland
Clipboard of terminal get out of sync with the main clipboard on Wayland
Status: RESOLVED INCOMPLETE
Product: gnome-terminal
Classification: Core
Component: general
3.18.x
Other Linux
: Normal normal
: ---
Assigned To: GNOME Terminal Maintainers
GNOME Terminal Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-11-20 14:17 UTC by Géza Búza
Modified: 2016-02-21 10:24 UTC
See Also:
GNOME target: ---
GNOME version: 3.17/3.18



Description Géza Búza 2015-11-20 14:17:17 UTC
Sometimes when I paste a text into the terminal by Ctrl + Shift + V, the previously used text will be inserted instead of the actual. Other applications insert the correct text via Ctrl + V.

As I workaround I copy the text again into the clipboard. After that paste works again in the terminal.

All of this happens randomly. Is there a way I can debug it?

Environment:
Gnome terminal version: 3.18.2
Wayland version: 1.9.0
Xorg server version: 1.18.0
GTK3 version: 3.18.4
Comment 1 Matthias Clasen 2015-11-20 16:53:38 UTC
WAYLAND_DEBUG=1 produced Wayland protocol debug output, but you may have a hard time capturing that from gnome-terminal. In any case, I think this bug should start its life on the gnome-terminal side.
Comment 2 Christian Persch 2015-11-20 17:13:32 UTC
See https://wiki.gnome.org/Apps/Terminal/Debugging how to debug g-t.

However, I don't see how this could be a g-t bug. It works on X, so if it doesn't on wayland, that's most likely a problem in gdk.
Comment 3 Matthias Clasen 2015-11-23 14:35:58 UTC
Fine. I'll state that it works under Wayland as well, on my system. 

GTK+ is not handling Ctrl-Shift-V. Make of it what you want, but blindly moving all bugs to GTK+ is not getting them fixed any faster.
Comment 4 Christian Persch 2015-11-23 17:12:10 UTC
In this case here, Shift-Ctrl-V just does:

  clipboard = gtk_widget_get_clipboard (..., GDK_SELECTION_CLIPBOARD);
  gtk_clipboard_request_targets (clipboard, ...)

and on receiving the targets:

if (gtk_targets_include_uri (targets, n_targets)) {
    gtk_clipboard_request_uris (clipboard, ....)
  } else /* if (gtk_targets_include_text (targets, n_targets)) */ {
    vte_terminal_paste_clipboard (VTE_TERMINAL (data->screen));
  }

where vte_terminal_paste_clipboard is just gtk_clipboard_request_text().

So if the 'previously used text' is received by these request functions, I really don't see how that could be any fault of g-t/vte.

Comment 0 doesn't state from which programme the clipboard data originated; if it's g-t (via Shift-Ctrl-C) then that's just from gtk_clipboard_set_with_owner() for the GDK_SELECTION_CLIPBOARD GdkClipboard , text/plain target and the selected text as data.


Also note that vte has ZERO code that depends on the gdk backend, and g-t only has a couple such checks (WM checks (gdk_x11_screen_supports_net_wm_hint(), "window-manager-changed" signal handling) [I'll just remove these now since they're obsolete], setting of an environment variable in the child process on the X backend, and using X directly to get a fallback startup timestamp).  THAT is the basis for my assessment that a bug that occurs on wayland but not on X, is a priori unlikely to be a g-t/vte bug. So I'm not just 'blindly' moving bugs around!
Comment 5 Géza Búza 2015-11-23 23:29:45 UTC
@Christian The copied text came from PHPStorm IDE (so outside G-T). But I don't think the problem is related to the application where data is coming from. I also have GPaste installed, which displays clipboard history and I saw my text on the top of the list. However what I got in G-T was the second item in GPaste (so the previously copied text).

I know it's hard to guess where the problem is especially when it happens randomly. That's why I asked if there is a way to debug it. I'm thinking of enable logging of API calls made by G-T. So next time the issue happens I can present you the logs and hopefully that could help track down the problem. Is there a way to do that?
Comment 6 Christian Persch 2015-11-25 07:31:56 UTC
See the link in comment 2 on how to start g-t-server in a way that lets you set WAYLAND_DEBUG env var in it.
Comment 7 Christian Persch 2015-12-15 19:49:27 UTC
Well, did you capture the debug output with g-t-server run with WAYLAND_DEBUG set?
Comment 8 Géza Búza 2015-12-16 20:53:15 UTC
No, I couldn't do it. First problem is that I couldn't get gdb to save the log messages to a file by redirecting standard output. Second is that it produces a ton of messages per second, so the log file would take gigabytes after a day I guess. Some filtering would be useful here. Is there any trick to solve these problems?

By the way, the reported problem happened only once, since I created this bug ticket. I use the terminal on a daily basis. Again I copied text from a Java application into the terminal. 
If I go back to the Java app and press Crtl + C on the selected text nothing changes, wrong text will be pasted into the terminal. But when I paste the text first into another text editor like Sublime and select it, press Ctrl + C, then the pasting magically start working in the terminal. So maybe it has something to do with how Java Virtual Machine interacts with the clipboard.