summaryrefslogtreecommitdiffstats
path: root/tests/auto/compositor/compositor/tst_compositor.cpp
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2017-09-28 16:21:21 +0200
committerJohan Helsing <johan.helsing@qt.io>2017-10-18 11:39:25 +0000
commitfa7a1f77226795ece274b3505655e522881a0e24 (patch)
tree3e3e730642b9f03dbdbbd385ae1a4900f5b7cb19 /tests/auto/compositor/compositor/tst_compositor.cpp
parent3876d75305d3a1d2967c887b9591a327f726d91e (diff)
Fix crash after destroying view with mouse focus
Don't emit QWaylandSeat::mouseFocusChanged with a destroyed QWaylandView. QWaylandPointer has been refactored to make it easier to follow enter and leave logic. A missing emit for buttonPressedChanged has been fixed as well. This also adds a test for pointer events to verify that setting mouse focus works and that the crash has been fixed. Task-number: QTBUG-63208 Change-Id: Id0c174a7b609dfd0152f3ae446dd51fd8befd554 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'tests/auto/compositor/compositor/tst_compositor.cpp')
-rw-r--r--tests/auto/compositor/compositor/tst_compositor.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/compositor/compositor/tst_compositor.cpp b/tests/auto/compositor/compositor/tst_compositor.cpp
index 3d7d2dab..6f00b6e6 100644
--- a/tests/auto/compositor/compositor/tst_compositor.cpp
+++ b/tests/auto/compositor/compositor/tst_compositor.cpp
@@ -27,6 +27,8 @@
****************************************************************************/
#include "mockclient.h"
+#include "mockseat.h"
+#include "mockpointer.h"
#include "testcompositor.h"
#include "testkeyboardgrabber.h"
#include "testseat.h"
@@ -56,6 +58,7 @@ private slots:
void keyboardGrab();
void seatCreation();
void seatKeyboardFocus();
+ void seatMouseFocus();
void singleClient();
void multipleClients();
void geometry();
@@ -438,6 +441,59 @@ void tst_WaylandCompositor::seatKeyboardFocus()
QTRY_VERIFY(!compositor.defaultSeat()->keyboardFocus());
}
+void tst_WaylandCompositor::seatMouseFocus()
+{
+ TestCompositor compositor(true);
+ compositor.create();
+
+ // Create client after all the seats have been set up as the mock client
+ // does not dynamically listen to new seats
+ MockClient client;
+ wl_surface *surface = client.createSurface();
+ QTRY_COMPARE(compositor.surfaces.size(), 1);
+
+ QWaylandSurface *waylandSurface = compositor.surfaces.at(0);
+ auto view = new QWaylandView;
+ view->setSurface(waylandSurface);
+
+ QWaylandSeat* seat = compositor.defaultSeat();
+ seat->setMouseFocus(view);
+ seat->sendMouseMoveEvent(view, QPointF(10, 10), QPointF(100, 100));
+
+ compositor.flushClients();
+
+ QTRY_VERIFY(seat->mouseFocus());
+ QTRY_VERIFY(seat->pointer());
+ QTRY_COMPARE(seat->mouseFocus()->surface(), waylandSurface);
+
+ QTRY_COMPARE(client.m_seats.size(), 1);
+ MockPointer *mockPointer = client.m_seats.first()->pointer();
+ QVERIFY(mockPointer);
+ QTRY_COMPARE(mockPointer->m_enteredSurface, surface);
+
+ delete view;
+
+ compositor.flushClients();
+
+ QTRY_COMPARE(mockPointer->m_enteredSurface, nullptr);
+ QTRY_VERIFY(!compositor.defaultSeat()->mouseFocus());
+
+ view = new QWaylandView;
+ view->setSurface(waylandSurface);
+ seat->sendMouseMoveEvent(view, QPointF(10, 10), QPointF(100, 100));
+ QTRY_COMPARE(compositor.defaultSeat()->mouseFocus(), view);
+
+ compositor.flushClients();
+
+ QTRY_COMPARE(mockPointer->m_enteredSurface, surface);
+
+ wl_surface_destroy(surface);
+ QTRY_VERIFY(compositor.surfaces.size() == 0);
+ QTRY_VERIFY(!compositor.defaultSeat()->mouseFocus());
+
+ delete view;
+}
+
class XdgTestCompositor: public TestCompositor {
Q_OBJECT
public: