<html>
    <head>
      <base href="https://bugzilla.gnome.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - CLIPBOARD target request after PRIMARY request times out. GDK_SELECTION_NOTIFY has wrong selection id"
   href="https://bugzilla.gnome.org/show_bug.cgi?id=768177">768177</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>CLIPBOARD target request after PRIMARY request times out. GDK_SELECTION_NOTIFY has wrong selection id
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Platform
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>gtk+
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.20.x
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>Normal
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: Wayland
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>gtk-bugs@gtk.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>caolanm@redhat.com
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>gtk-bugs@gtk.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>rob@robster.org.uk, wayland-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>GNOME version</th>
          <td>---
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=330565&action=diff" name="attach_330565" title="this makes it work for me">attachment 330565</a> <a href="attachment.cgi?id=330565&action=edit" title="this makes it work for me">[details]</a></span> <a href='review?bug=768177&attachment=330565'>[review]</a>
this makes it work for me

LibreOffice under wayland won't successfully paste from the CLIPBOARD after the
PRIMARY selection is used to paste from another app into it.

I paste from PRIMARY and then immediately request the targets of CLIPBOARD:
selection_buffer_notify generates a GDK_SELECTION_NOTIFY event for this
CLIPBOARD request using selection_buffer_notify but sets the selection field to
PRIMARY from the passed in SelectionBuffer.

So the notification dosn't match in _gtk_selection_notify at the
info->selection == event->selection so the CLIPBOARD request is never satisfied
and times out.

The problem appears to be the cache used by
_gdk_wayland_display_convert_selection of gdk/wayland/gdkselection-wayland.c
where...

  buffer_data = g_hash_table_lookup (wayland_selection->selection_buffers,
                                     target);

...

  g_hash_table_insert (wayland_selection->selection_buffers,
                       GDK_ATOM_TO_POINTER (target),
                       buffer_data);

So the buffer_data for the PRIMARY selection was cached and reused for the
CLIPBOARD selection. The attached patch "for for me(tm)" by just updating the
selection of the cached buffer_data to the requested selection on retrieval</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>