From e3cc20df4290ef0364206e930ed43ae06bd6ed58 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Mon, 10 Oct 2016 18:01:43 +0200 Subject: Clients tests: Don't send leave events for destroyed surfaces Change-Id: Ia7dd13f629439b116f494ff8b7432020a65ea1df Reviewed-by: Paul Olav Tvete --- tests/auto/client/client/mockcompositor.cpp | 6 ++---- tests/auto/client/client/mockinput.cpp | 16 ++++++++++++++++ tests/auto/client/client/mockinput.h | 2 ++ 3 files changed, 20 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/client/client/mockcompositor.cpp b/tests/auto/client/client/mockcompositor.cpp index 45a35ea7d..2c5f2541f 100644 --- a/tests/auto/client/client/mockcompositor.cpp +++ b/tests/auto/client/client/mockcompositor.cpp @@ -362,10 +362,8 @@ void Compositor::addSurface(Surface *surface) void Compositor::removeSurface(Surface *surface) { m_surfaces.removeOne(surface); - if (m_keyboard->focus() == surface) - m_keyboard->setFocus(0); - if (m_pointer->focus() == surface) - m_pointer->setFocus(0, QPoint()); + m_keyboard->handleSurfaceDestroyed(surface); + m_pointer->handleSurfaceDestroyed(surface); } } diff --git a/tests/auto/client/client/mockinput.cpp b/tests/auto/client/client/mockinput.cpp index fe06bf79b..99acdd43a 100644 --- a/tests/auto/client/client/mockinput.cpp +++ b/tests/auto/client/client/mockinput.cpp @@ -267,6 +267,14 @@ void Keyboard::setFocus(Surface *surface) m_focus = surface; } +void Keyboard::handleSurfaceDestroyed(Surface *surface) +{ + if (surface == m_focus) { + m_focusResource = nullptr; + m_focus = nullptr; + } +} + void Keyboard::sendKey(uint32_t key, uint32_t state) { if (m_focusResource) { @@ -314,6 +322,14 @@ void Pointer::setFocus(Surface *surface, const QPoint &pos) m_focus = surface; } +void Pointer::handleSurfaceDestroyed(Surface *surface) +{ + if (m_focus == surface) { + m_focus = nullptr; + m_focusResource = nullptr; + } +} + void Pointer::sendMotion(const QPoint &pos) { if (m_focusResource) diff --git a/tests/auto/client/client/mockinput.h b/tests/auto/client/client/mockinput.h index 031be2a4a..7e88ffb0f 100644 --- a/tests/auto/client/client/mockinput.h +++ b/tests/auto/client/client/mockinput.h @@ -75,6 +75,7 @@ public: Surface *focus() const { return m_focus; } void setFocus(Surface *surface); + void handleSurfaceDestroyed(Surface *surface); void sendKey(uint32_t key, uint32_t state); @@ -97,6 +98,7 @@ public: Surface *focus() const { return m_focus; } void setFocus(Surface *surface, const QPoint &pos); + void handleSurfaceDestroyed(Surface *surface); void sendMotion(const QPoint &pos); void sendButton(uint32_t button, uint32_t state); -- cgit v1.2.3