summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <olivier.blin@softathome.com>2015-10-13 19:24:37 +0200
committerOlivier Blin <qt@blino.org>2015-10-20 09:06:22 +0000
commit7f646611ca996320fec933633711b9d89833863c (patch)
tree5399270e8949ea9015b1baaa6d3f3cf59ede6d49
parent505c37307980e20baf02961d1be5abf858d5510a (diff)
Fix setting focusDestroyListener when no keyboard resource is bound
When no keyboard resource is bound, the destruction handler for the focused surface was not called, and the pointers to focused objects were not reset. Thus the m_focus surface pointer could become invalid. Change-Id: Iee404219304ae7b2bae87131ab140ab134e98118 Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
-rw-r--r--src/compositor/wayland_wrapper/qwlkeyboard.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/compositor/wayland_wrapper/qwlkeyboard.cpp b/src/compositor/wayland_wrapper/qwlkeyboard.cpp
index 3d0af6aaf..7520fae3f 100644
--- a/src/compositor/wayland_wrapper/qwlkeyboard.cpp
+++ b/src/compositor/wayland_wrapper/qwlkeyboard.cpp
@@ -118,10 +118,15 @@ KeyboardGrabber *Keyboard::currentGrab() const
void Keyboard::focused(Surface *surface)
{
- if (m_focusResource && m_focus != surface) {
- uint32_t serial = wl_display_next_serial(m_compositor->wl_display());
- send_leave(m_focusResource->handle, serial, m_focus->resource()->handle);
+ if (m_focus != surface) {
+ if (m_focusResource) {
+ uint32_t serial = wl_display_next_serial(m_compositor->wl_display());
+ send_leave(m_focusResource->handle, serial, m_focus->resource()->handle);
+ }
m_focusDestroyListener.reset();
+ if (surface) {
+ m_focusDestroyListener.listenForDestruction(surface->resource()->handle);
+ }
}
Resource *resource = surface ? resourceMap().value(surface->resource()->client()) : 0;
@@ -130,7 +135,6 @@ void Keyboard::focused(Surface *surface)
uint32_t serial = wl_display_next_serial(m_compositor->wl_display());
send_modifiers(resource->handle, serial, m_modsDepressed, m_modsLatched, m_modsLocked, m_group);
send_enter(resource->handle, serial, surface->resource()->handle, QByteArray::fromRawData((char *)m_keys.data(), m_keys.size() * sizeof(uint32_t)));
- m_focusDestroyListener.listenForDestruction(surface->resource()->handle);
}
m_focusResource = resource;