From b0a4355c5320eecdf008521e1b40cd221e8352f2 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 11 Jun 2012 11:36:43 +0300 Subject: [PATCH] Reset keyboard focus when a surface is destroyed MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Only pointer focus was reset, resulting in undefined behavior when acessing keyboardFocus() after all surfaces had gone away. Change-Id: I8c9f71e2eadbf69de1dc7856f4a05dd309ab95eb Reviewed-by: Jørgen Lind --- src/compositor/wayland_wrapper/wlcompositor.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/compositor/wayland_wrapper/wlcompositor.cpp b/src/compositor/wayland_wrapper/wlcompositor.cpp index 61ec91e..a67ad58 100644 --- a/src/compositor/wayland_wrapper/wlcompositor.cpp +++ b/src/compositor/wayland_wrapper/wlcompositor.cpp @@ -271,18 +271,22 @@ void Compositor::processWaylandEvents() void Compositor::surfaceDestroyed(Surface *surface) { - if (defaultInputDevice()->mouseFocus() == surface) { - InputDevice *dev = defaultInputDevice(); + InputDevice *dev = defaultInputDevice(); + if (dev->mouseFocus() == surface) { 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_pointer_set_focus(dev->pointerDevice(), 0, 0, 0); } + if (dev->keyboardFocus() == surface) + dev->setKeyboardFocus(0); + m_surfaces.removeOne(surface); m_dirty_surfaces.remove(surface); if (m_directRenderSurface == surface) setDirectRenderSurface(0, 0); + waylandCompositor()->surfaceAboutToBeDestroyed(surface->waylandSurface()); } -- 2.7.4