14 Commits

Author SHA1 Message Date
Johan Klokkhammer Helsing
68bbf5fd1c Client tests: Add test for a simple wl_touch tap
Change-Id: I35aec950da0ac0d10cf1fa0c4bc1f56ba232cf89
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-08-27 12:35:33 +02:00
Johan Klokkhammer Helsing
74e3dd6d60 Client tests: Add touch infrastructure and simple test
This doesn't test much, but adds the infrastructure needed for more
thorough tests later on.

More or less exactly matches the mocking for wl_keyboard and wl_pointer.

Change-Id: I563bb9be7ccaaf0aa83611e84d051cc307455ccb
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-08-27 08:47:23 +02:00
Johan Klokkhammer Helsing
ae5db4fec1 Client tests: Fix incorrect test for keyboard capability
Change-Id: I4e35e86f489941dcce986ba416f3fe55d968d186
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-08-26 16:27:46 +02:00
Johan Klokkhammer Helsing
c0d8e3dc36 Client tests: Add missing cleanup for keyboards
Change-Id: Ia085dbe34b6e3b7cf83b4f55c265e12b1145ab8a
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-08-26 16:27:30 +02:00
Johan Klokkhammer Helsing
72cae9c58c Client: Implement primary-selection-unstable-v1
[ChangeLog][QPA plugin] Added support for middle mouse pasting through the
primary-selection-unstable-v1 protocol.

Fixes: QTBUG-66008
Change-Id: I7c8fb9aa2c856f5b6794aeab1ee75d80cad05dcd
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-05-10 12:35:00 +00:00
Paul Olav Tvete
dfd4633804 Merge remote-tracking branch 'qt/5.13' into dev
Change-Id: I3dc204fcaa71c01a80b0c622443012eb07964431
2019-03-21 11:57:15 +01:00
Robin Burchell
df531a6f3c Client: Implement wl_pointer version 5
Version 5 adds frame events, which groups multiple pointer events together,
enabling diagonal scrolling, leave and enter without an intermediate state, and
together with the new axis_source, axis_discrete and axis_stop also adds what
needed to differentiate between wheel events and touchpad scrolling.

This patch adds scroll phases and pixel deltas to QWaylandInputDevice, and
makes sure handleWheelEvent is called accordingly.

[ChangeLog][QPA plugin] Pixel delta is now set for mouse scrolling events if
originating from an appropriate device such as a touch pad (requires compositor
support for wl_seat version 5 or later).

Fixes: QTBUG-69876
Fixes: QTBUG-63720
Change-Id: I094a1ef0365893bee135cae7e6df89fafdafa2f2
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2019-03-14 13:12:00 +00:00
Johan Klokkhammer Helsing
7fa16ebff6 Client: Don't send illegal wl_pointer.set_cursor requests
When the cursor focus' wl_surface is destroyed, or the pointer leaves a
surface, we have to reset the enter serial to avoid sending illegal set_cursor
requests.

Change-Id: I0c886e4123acb4aebd325b07bf15b9d3fa8589da
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2019-02-27 14:05:12 +00:00
Johan Klokkhammer Helsing
a5bcdd0f86 Client: Refactor cursors and fix various bugs
This patch is mostly a cleanup to prepare for implementations of
xcursor-configuration, but also fixes a couple of issues.

Most of the logic has now been moved out of QWaylandDisplay and QWaylandCursor
and into QWaylandInputDevice and QWaylandInputDevice::Pointer. QWaylandDisplay
now only contains mechanisms for avoiding loading the same theme multiple
times.

There is now only one setCursor method on QWaylandInputDevice, accepting a
QCursor and storing its values so changing scale factor doesn't require calling
setCursor again. QWaylandInputDevice::Pointer::updateCursor() is called
instead.

Cursor buffer scale is now set according to enter/leave events of the cursor
surface itself instead of the current window, this fixes incorrect buffer
scales for cursors on windows that span multiple outputs. The window buffer
scale can still be passed into the seat as a fallback until the first enter
event is received.

This also fixes a bug where the QWaylandBuffer of a bitmap cursor could be
deleted while it was being used as a cursor.

[ChangeLog][QPA plugin] Fixed a bug where the DPI of bitmap cursors were not
sent to the compositor, leading to the compositor incorrectly scaling the
cursor up or down.

[ChangeLog][QPA plugin] Fixed a bug where bitmap cursor hotspots were off when
the screen scale factor was different from the bitmap cursor device pixel
ratio.

Task-number: QTBUG-68571
Change-Id: I747a47ffff01b7b5f6a0ede3552ab37884c4fa60
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-02-15 09:12:35 +00:00
Johan Klokkhammer Helsing
49fc676e8b Client xdg-shell: Add test for tooltips on popups
This used to cause protocol errors.

Task-number: QTBUG-71734
Change-Id: Ic937210fc42c93f1d411fb0fb4f269de01f07b5b
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-02-06 15:30:23 +00:00
Johan Klokkhammer Helsing
4aa82cf999 Add client test for data device
Change-Id: Id89ec40a3f484808385401829a09a43781a1bed7
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-01-30 15:02:31 +00:00
Johan Klokkhammer Helsing
d2c9c5537d Client tests: Add simple test for keyboard press
Change-Id: Ib28be5277af9145834c7808f993c747e21845616
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-01-30 14:35:10 +00:00
Johan Klokkhammer Helsing
badf0575a2 Client: Add wl_output tests
Also removes overlapping old tests and adds a (currently failing) test for
QTBUG-72828.

Task-number: QTBUG-72828
Change-Id: Id93d5872ed1c4f181935c1e493e9d8d0ae9cfaf3
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-01-17 07:21:17 +00:00
Johan Klokkhammer Helsing
f6dd4ab120 Create a new type of mock compositor for client tests
There are a number of issues with the current client testing:

- Adding new compositor functionality is cumbersome (need to add compositor
  send method, command, implementation, not to mention creating new wrapper
  objects.
- Customizing available globals and their versions is not possible and would be
  hard to implement. I.e. how to test that functionality works with old and new
  versions of an interface? Handle globals being destroyed. We did this with
  wl_output, but it was painfully cumbersome.
- Hard to verify that the compositor state is clean between tests. It is
  currently done in some tests, but requires boiler plate code which needs to
  be added and maintained for each test.
- In general lots of boiler-plate for new tests. (We have to have separate
  tests as long as Qt has global/static state. I.e. if one shell extension has
  been initialized, we can't deinitialize and initialize another one, so tests
  have to be separate.)
- Dispatching server events tied to the client event loop sometimes makes it
  hard to write tests without deadlocks.
- Abstraction, encapsulation and automatic behavior that can't be disabled
  makes it hard to test low-level functionality like surface exposure.

So, in an attempt to mitigate these issues, I wrote a new testing framework.

- Compositor dispatch is running continuously in it's own thread, access to
  compositor state is guarded by a mutex on the compositor, locking this will
  make dispatching stop, so the test can safely access internals. Although a
  bit cumbersome at first this makes it much easier to directly use server
  protocol commands from the test itself, i.e. no need to create commands for
  every single thing we want to test.
- The CoreCompositor::exec template method can accept a lambda that will be run
  with dispatching stopped. It can also return a value, conveniently letting us
  safely extract or modify compositor state from tests.
- This framework also takes full advantage of the qtwaylandscanner, using
  wrapper classes for everything, reducing boiler plate considerably.
- The compositor parts are designed to do as little as possible automatically,
  but still provide easy ways to enable common functionality, like releasing
  buffers automatically, configuring shell surfaces etc.
- Compositor globals are pluggable, use add<GlobalClass>() and
  remove<GlobalClass>() to add new global interfaces. I.e. easy to create a
  compositor with or without data_device_manager for instance.
- DefaultCompositor provides a sensible default set of functionality and
  convenience methods for most test-cases. Custom ones can still be made by
  inheriting from CoreCompositor directly instead or by removing or adding
  globals to DefaultCompositor.
- Globals have an isClean() method. Implement it to verify that the client
  didn't leave any objects lying around from the previous test.
  CoreCompositor::isClean calls isClean on the globals so a single call is all
  that's needed.

In short, we've traded mock compositor encapsulation and thread safety
guarantees for less boiler-plate, easier and more convenient access to
internals.

Anything accessing compositor state should go into a exec() call, or through
the wrapper macros QCOMPOSITOR_VERIFY and QCOMPOSITOR_COMPARE (or the TRY
versions). I've also tried to make the compositor print warnings if compositor
state is accessed in an unsafe way.

The mock compositor is currently built once per test due to CI limitations
(same thing as with the old tests).

Change-Id: Ia3feb80ce175d3814292b7f4768a0cc719f8b0e8
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-12-11 15:46:49 +00:00