Make sure the pointer focus is really reset when destroying
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>
Thu, 10 May 2012 12:19:04 +0000 (15:19 +0300)
committerLaszlo Agocs <laszlo.p.agocs@nokia.com>
Thu, 10 May 2012 17:15:08 +0000 (19:15 +0200)
Using the grab interface introduced an issue which crashes the
compositor quite often when running widget apps.

Change-Id: I74b64fb7b18ec510773b3b533a3c778be7173db4
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/compositor/wayland_wrapper/wlcompositor.cpp
src/compositor/wayland_wrapper/wlinputdevice.cpp

index df19698..9f00045 100644 (file)
@@ -271,8 +271,14 @@ void Compositor::processWaylandEvents()
 
 void Compositor::surfaceDestroyed(Surface *surface)
 {
-    if (defaultInputDevice()->mouseFocus() == surface)
-        defaultInputDevice()->setMouseFocus(0, QPoint(), QPoint());
+    if (defaultInputDevice()->mouseFocus() == surface) {
+        InputDevice *dev = defaultInputDevice();
+        dev->setMouseFocus(0, QPointF(), QPointF());
+        // Make sure the surface is reset regardless of what the grabber
+        // interface's focus() does. (e.g. the default implementation does
+        // nothing when a button is down which would be disastrous here)
+        wl_input_device_set_pointer_focus(dev->base(), 0, 0, 0);
+    }
     m_surfaces.removeOne(surface);
     m_dirty_surfaces.remove(surface);
     if (m_directRenderSurface == surface)
index 4bbf0dd..2e11153 100644 (file)
@@ -246,7 +246,7 @@ void InputDevice::setMouseFocus(Surface *surface, const QPointF &globalPos, cons
 {
     base()->x = wl_fixed_from_double(globalPos.x());
     base()->y = wl_fixed_from_double(globalPos.y());
-    base()->current = surface->base();
+    base()->current = surface ? surface->base() : 0;
     base()->current_x = wl_fixed_from_double(localPos.x());
     base()->current_y = wl_fixed_from_double(localPos.y());
     base()->pointer_grab->interface->focus(base()->pointer_grab,