Merge remote-tracking branch 'origin/5.9' into 5.10

Conflicts:
	.qmake.conf
	src/compositor/compositor_api/qwaylandquickitem.cpp

Change-Id: Id2f49e8703a67daedcee66db83f006df828d9da0
This commit is contained in:
Liang Qi 2018-01-07 00:08:06 +01:00
commit 8bc7ea23e3
3 changed files with 29 additions and 18 deletions

View File

@ -2,7 +2,7 @@ CONFIG += testcase link_pkgconfig
TARGET = tst_client TARGET = tst_client
QT += testlib QT += testlib
QT += core-private gui-private QT += core-private gui-private waylandclient-private
QMAKE_USE += wayland-client wayland-server QMAKE_USE += wayland-client wayland-server

View File

@ -365,7 +365,9 @@ void Touch::sendDown(Surface *surface, const QPoint &position, int id)
Q_ASSERT(surface); Q_ASSERT(surface);
Resource *resource = resourceMap().value(surface->resource()->client()); Resource *resource = resourceMap().value(surface->resource()->client());
Q_ASSERT(resource); Q_ASSERT(resource);
wl_touch_send_down(resource->handle, serial, time, surface->resource()->handle, id, position.x(), position.y()); auto x = wl_fixed_from_int(position.x());
auto y = wl_fixed_from_int(position.y());
wl_touch_send_down(resource->handle, serial, time, surface->resource()->handle, id, x, y);
} }
void Touch::sendUp(Surface *surface, int id) void Touch::sendUp(Surface *surface, int id)
@ -378,7 +380,9 @@ void Touch::sendMotion(Surface *surface, const QPoint &position, int id)
{ {
Resource *resource = resourceMap().value(surface->resource()->client()); Resource *resource = resourceMap().value(surface->resource()->client());
uint32_t time = m_compositor->time(); uint32_t time = m_compositor->time();
wl_touch_send_motion(resource->handle, time, id, position.x(), position.y()); auto x = wl_fixed_from_int(position.x());
auto y = wl_fixed_from_int(position.y());
wl_touch_send_motion(resource->handle, time, id, x, y);
} }
void Touch::sendFrame(Surface *surface) void Touch::sendFrame(Surface *surface)

View File

@ -37,6 +37,8 @@
#include <QDrag> #include <QDrag>
#include <QtTest/QtTest> #include <QtTest/QtTest>
#include <QtWaylandClient/private/qwaylandintegration_p.h>
#include <QtGui/private/qguiapplication_p.h>
static const QSize screenSize(1600, 1200); static const QSize screenSize(1600, 1200);
@ -96,6 +98,8 @@ public:
++touchEventCount; ++touchEventCount;
} }
QPoint frameOffset() const { return QPoint(frameMargins().left(), frameMargins().top()); }
int focusInEventCount; int focusInEventCount;
int focusOutEventCount; int focusOutEventCount;
int keyPressEventCount; int keyPressEventCount;
@ -201,7 +205,7 @@ void tst_WaylandClient::events()
QPoint mousePressPos(16, 16); QPoint mousePressPos(16, 16);
QCOMPARE(window.mousePressEventCount, 0); QCOMPARE(window.mousePressEventCount, 0);
compositor->sendMousePress(surface, mousePressPos); compositor->sendMousePress(surface, window.frameOffset() + mousePressPos);
QTRY_COMPARE(window.mousePressEventCount, 1); QTRY_COMPARE(window.mousePressEventCount, 1);
QTRY_COMPARE(window.mousePressPos, mousePressPos); QTRY_COMPARE(window.mousePressPos, mousePressPos);
@ -210,7 +214,7 @@ void tst_WaylandClient::events()
QTRY_COMPARE(window.mouseReleaseEventCount, 1); QTRY_COMPARE(window.mouseReleaseEventCount, 1);
const int touchId = 0; const int touchId = 0;
compositor->sendTouchDown(surface, QPoint(10, 10), touchId); compositor->sendTouchDown(surface, window.frameOffset() + QPoint(10, 10), touchId);
compositor->sendTouchFrame(surface); compositor->sendTouchFrame(surface);
QTRY_COMPARE(window.touchEventCount, 1); QTRY_COMPARE(window.touchEventCount, 1);
@ -269,6 +273,7 @@ public:
m_dragIcon = QPixmap::fromImage(cursorImage); m_dragIcon = QPixmap::fromImage(cursorImage);
} }
~DndWindow(){} ~DndWindow(){}
QPoint frameOffset() const { return QPoint(frameMargins().left(), frameMargins().top()); }
bool dragStarted; bool dragStarted;
protected: protected:
@ -302,14 +307,14 @@ void tst_WaylandClient::touchDrag()
QTRY_COMPARE(QGuiApplication::focusWindow(), &window); QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
const int id = 0; const int id = 0;
compositor->sendTouchDown(surface, QPoint(10, 10), id); compositor->sendTouchDown(surface, window.frameOffset() + QPoint(10, 10), id);
compositor->sendTouchFrame(surface); compositor->sendTouchFrame(surface);
compositor->sendTouchMotion(surface, QPoint(20, 20), id); compositor->sendTouchMotion(surface, window.frameOffset() + QPoint(20, 20), id);
compositor->sendTouchFrame(surface); compositor->sendTouchFrame(surface);
compositor->waitForStartDrag(); compositor->waitForStartDrag();
compositor->sendDataDeviceDataOffer(surface); compositor->sendDataDeviceDataOffer(surface);
compositor->sendDataDeviceEnter(surface, QPoint(20, 20)); compositor->sendDataDeviceEnter(surface, window.frameOffset() + QPoint(20, 20));
compositor->sendDataDeviceMotion( QPoint(21, 21)); compositor->sendDataDeviceMotion(window.frameOffset() + QPoint(21, 21));
compositor->sendDataDeviceDrop(surface); compositor->sendDataDeviceDrop(surface);
compositor->sendDataDeviceLeave(surface); compositor->sendDataDeviceLeave(surface);
QTRY_VERIFY(window.dragStarted); QTRY_VERIFY(window.dragStarted);
@ -326,10 +331,10 @@ void tst_WaylandClient::mouseDrag()
compositor->setKeyboardFocus(surface); compositor->setKeyboardFocus(surface);
QTRY_COMPARE(QGuiApplication::focusWindow(), &window); QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
compositor->sendMousePress(surface, QPoint(10, 10)); compositor->sendMousePress(surface, window.frameOffset() + QPoint(10, 10));
compositor->sendDataDeviceDataOffer(surface); compositor->sendDataDeviceDataOffer(surface);
compositor->sendDataDeviceEnter(surface, QPoint(20, 20)); compositor->sendDataDeviceEnter(surface, window.frameOffset() + QPoint(20, 20));
compositor->sendDataDeviceMotion( QPoint(21, 21)); compositor->sendDataDeviceMotion(window.frameOffset() + QPoint(21, 21));
compositor->waitForStartDrag(); compositor->waitForStartDrag();
compositor->sendDataDeviceDrop(surface); compositor->sendDataDeviceDrop(surface);
compositor->sendDataDeviceLeave(surface); compositor->sendDataDeviceLeave(surface);
@ -390,7 +395,7 @@ void tst_WaylandClient::hiddenPopupParent()
QTRY_VERIFY(surface = compositor->surface()); QTRY_VERIFY(surface = compositor->surface());
QPoint mousePressPos(16, 16); QPoint mousePressPos(16, 16);
QCOMPARE(toplevel.mousePressEventCount, 0); QCOMPARE(toplevel.mousePressEventCount, 0);
compositor->sendMousePress(surface, mousePressPos); compositor->sendMousePress(surface, toplevel.frameOffset() + mousePressPos);
QTRY_COMPARE(toplevel.mousePressEventCount, 1); QTRY_COMPARE(toplevel.mousePressEventCount, 1);
QWindow popup; QWindow popup;
@ -409,15 +414,17 @@ int main(int argc, char **argv)
setenv("XDG_RUNTIME_DIR", ".", 1); setenv("XDG_RUNTIME_DIR", ".", 1);
setenv("QT_QPA_PLATFORM", "wayland", 1); // force QGuiApplication to use wayland plugin setenv("QT_QPA_PLATFORM", "wayland", 1); // force QGuiApplication to use wayland plugin
// wayland-egl hangs in the test setup when we try to initialize. Until it gets
// figured out, avoid clientBufferIntegration() from being called in
// QWaylandWindow::createDecorations().
setenv("QT_WAYLAND_DISABLE_WINDOWDECORATION", "1", 1);
MockCompositor compositor; MockCompositor compositor;
compositor.setOutputGeometry(QRect(QPoint(), screenSize)); compositor.setOutputGeometry(QRect(QPoint(), screenSize));
QGuiApplication app(argc, argv); QGuiApplication app(argc, argv);
// Initializing some client buffer integrations (i.e. eglInitialize) may block while waiting
// for a wayland sync. So we call clientBufferIntegration prior to applicationInitialized
// (while the compositor processes events without waiting) in order to avoid hanging later.
auto *waylandIntegration = static_cast<QtWaylandClient::QWaylandIntegration *>(QGuiApplicationPrivate::platformIntegration());
waylandIntegration->clientBufferIntegration();
compositor.applicationInitialized(); compositor.applicationInitialized();
tst_WaylandClient tc(&compositor); tst_WaylandClient tc(&compositor);