<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 - Focus events are not always matched"
   href="https://bugzilla.gnome.org/show_bug.cgi?id=780422">780422</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Focus events are not always matched
          </td>
        </tr>

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

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

        <tr>
          <th>Version</th>
          <td>3.22.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>jonathon@quotidian.org
          </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>In virt-viewer, we are getting a warning in the terminal when running under
wayland. 

Some very short background: virt-viewer does certain things (e.g. grab the
keyboard, enable usb auto-redirect, etc) when the spice widget gets focus, and
"undoes" those things when the widget loses focus. 

The reason that we are getting a warning is because we are not getting matched
focus-in and focus-out events. When running under wayland in Fedora 25, if we
click inside the virt-viewer window, a focus-in event is generated. However,
when clicking outside of the window, *two* focus-out events are generated. The
handler for the first event runs without problem, but the second one generates
a warning since it is attempting to perform a task that has already been
performed by the first handler.

I bisected gtk+ to determine when the problem appeared, and came up with the
following commit:

commit <a href="https://git.gnome.org/browse/gtk%2B/commit/?id=de2268000d7e3eb5e84603810f9a6f971efb1072">de2268000d7e3eb5e84603810f9a6f971efb1072</a>
Author: Carlos Garnacho <<a href="mailto:carlosg@gnome.org">carlosg@gnome.org</a>>
Date:   Wed Jun 24 17:48:18 2015 +0200

    wayland: Ensure device grabs generate crossing/focus events

    On X11 this is something the windowing system does for us, which the
    wayland backend should emulate, being grabs completely client-side.

    So, if the grab and current focus windows differ, make sure we emit
    focus/crossing events as it corresponds to the grab device.

I've not yet been able to create a minimal test case to trigger this bug in
gtk+.

This bug was initially opened in the spice bug tracker, but after discussing it
with some Gtk+ developers, they suggested opening a bug in Gtk+. Original bug
is here: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=99296">https://bugs.freedesktop.org/show_bug.cgi?id=99296</a></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>