Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/pointer_input.cpp
Show All 16 Lines | |||||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "kwin_wayland_test.h" | 20 | #include "kwin_wayland_test.h" | ||
21 | #include "platform.h" | 21 | #include "platform.h" | ||
22 | #include "abstract_client.h" | 22 | #include "abstract_client.h" | ||
23 | #include "cursor.h" | 23 | #include "cursor.h" | ||
24 | #include "deleted.h" | 24 | #include "deleted.h" | ||
25 | #include "effects.h" | ||||
25 | #include "pointer_input.h" | 26 | #include "pointer_input.h" | ||
26 | #include "options.h" | 27 | #include "options.h" | ||
27 | #include "screenedge.h" | 28 | #include "screenedge.h" | ||
28 | #include "screens.h" | 29 | #include "screens.h" | ||
29 | #include "wayland_server.h" | 30 | #include "wayland_server.h" | ||
30 | #include "workspace.h" | 31 | #include "workspace.h" | ||
31 | #include "shell_client.h" | 32 | #include "shell_client.h" | ||
32 | #include <kwineffects.h> | 33 | #include <kwineffects.h> | ||
Show All 19 Lines | |||||
52 | { | 53 | { | ||
53 | Q_OBJECT | 54 | Q_OBJECT | ||
54 | private Q_SLOTS: | 55 | private Q_SLOTS: | ||
55 | void initTestCase(); | 56 | void initTestCase(); | ||
56 | void init(); | 57 | void init(); | ||
57 | void cleanup(); | 58 | void cleanup(); | ||
58 | void testWarpingUpdatesFocus(); | 59 | void testWarpingUpdatesFocus(); | ||
59 | void testWarpingGeneratesPointerMotion(); | 60 | void testWarpingGeneratesPointerMotion(); | ||
61 | void testWarpingDuringFilter(); | ||||
60 | void testUpdateFocusAfterScreenChange(); | 62 | void testUpdateFocusAfterScreenChange(); | ||
61 | void testModifierClickUnrestrictedMove_data(); | 63 | void testModifierClickUnrestrictedMove_data(); | ||
62 | void testModifierClickUnrestrictedMove(); | 64 | void testModifierClickUnrestrictedMove(); | ||
63 | void testModifierScrollOpacity_data(); | 65 | void testModifierScrollOpacity_data(); | ||
64 | void testModifierScrollOpacity(); | 66 | void testModifierScrollOpacity(); | ||
65 | void testScrollAction(); | 67 | void testScrollAction(); | ||
66 | void testFocusFollowsMouse(); | 68 | void testFocusFollowsMouse(); | ||
67 | void testMouseActionInactiveWindow_data(); | 69 | void testMouseActionInactiveWindow_data(); | ||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Line(s) | 180 | { | |||
206 | 208 | | |||
207 | // now warp | 209 | // now warp | ||
208 | Cursor::setPos(QPoint(26, 26)); | 210 | Cursor::setPos(QPoint(26, 26)); | ||
209 | QVERIFY(movedSpy.wait()); | 211 | QVERIFY(movedSpy.wait()); | ||
210 | QCOMPARE(movedSpy.count(), 1); | 212 | QCOMPARE(movedSpy.count(), 1); | ||
211 | QCOMPARE(movedSpy.last().first().toPointF(), QPointF(26, 26)); | 213 | QCOMPARE(movedSpy.last().first().toPointF(), QPointF(26, 26)); | ||
212 | } | 214 | } | ||
213 | 215 | | |||
216 | void PointerInputTest::testWarpingDuringFilter() | ||||
217 | { | ||||
218 | // this test verifies that pointer motion is handled correctly if | ||||
219 | // the pointer gets warped during processing of input events | ||||
220 | using namespace KWayland::Client; | ||||
221 | | ||||
222 | // create pointer | ||||
223 | auto pointer = m_seat->createPointer(m_seat); | ||||
224 | QVERIFY(pointer); | ||||
225 | QVERIFY(pointer->isValid()); | ||||
226 | QSignalSpy movedSpy(pointer, &Pointer::motion); | ||||
227 | QVERIFY(movedSpy.isValid()); | ||||
228 | | ||||
229 | // warp cursor into expected geometry | ||||
230 | Cursor::setPos(10, 10); | ||||
231 | | ||||
232 | // create a window | ||||
233 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||||
234 | QVERIFY(clientAddedSpy.isValid()); | ||||
235 | Surface *surface = Test::createSurface(m_compositor); | ||||
236 | QVERIFY(surface); | ||||
237 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | ||||
238 | QVERIFY(shellSurface); | ||||
239 | render(surface); | ||||
240 | QVERIFY(clientAddedSpy.wait()); | ||||
241 | AbstractClient *window = workspace()->activeClient(); | ||||
242 | QVERIFY(window); | ||||
243 | | ||||
244 | QCOMPARE(window->pos(), QPoint(0, 0)); | ||||
245 | QVERIFY(window->geometry().contains(Cursor::pos())); | ||||
246 | | ||||
247 | // is PresentWindows effect for top left screen edge loaded | ||||
248 | QVERIFY(static_cast<EffectsHandlerImpl*>(effects)->isEffectLoaded("presentwindows")); | ||||
249 | QVERIFY(movedSpy.isEmpty()); | ||||
250 | quint32 timestamp = 0; | ||||
251 | kwinApp()->platform()->pointerMotion(QPoint(0, 0), timestamp++); | ||||
252 | // screen edges push back | ||||
253 | QCOMPARE(Cursor::pos(), QPoint(1, 1)); | ||||
254 | QVERIFY(movedSpy.wait()); | ||||
255 | QCOMPARE(movedSpy.count(), 2); | ||||
256 | QCOMPARE(movedSpy.at(0).first().toPoint(), QPoint(0, 0)); | ||||
257 | QCOMPARE(movedSpy.at(1).first().toPoint(), QPoint(1, 1)); | ||||
258 | } | ||||
259 | | ||||
214 | void PointerInputTest::testUpdateFocusAfterScreenChange() | 260 | void PointerInputTest::testUpdateFocusAfterScreenChange() | ||
215 | { | 261 | { | ||
216 | // this test verifies that a pointer enter event is generated when the cursor changes to another | 262 | // this test verifies that a pointer enter event is generated when the cursor changes to another | ||
217 | // screen due to removal of screen | 263 | // screen due to removal of screen | ||
218 | using namespace KWayland::Client; | 264 | using namespace KWayland::Client; | ||
219 | // ensure cursor is on second screen | 265 | // ensure cursor is on second screen | ||
220 | Cursor::setPos(1500, 300); | 266 | Cursor::setPos(1500, 300); | ||
221 | 267 | | |||
▲ Show 20 Lines • Show All 703 Lines • Show Last 20 Lines |