Merge remote-tracking branch 'qt/5.10' into dev

Change-Id: I603cbb164e6015c1bb7796bd8bb055d84dbc3b04
This commit is contained in:
Paul Olav Tvete 2018-01-30 10:37:24 +01:00
commit 397d3f75ab
8 changed files with 78 additions and 24 deletions

View File

@ -7,6 +7,8 @@ OTHER_FILES += \
SOURCES += main.cpp SOURCES += main.cpp
TARGET = qt-plugin-wayland-egl
PLUGIN_TYPE = wayland-graphics-integration-client PLUGIN_TYPE = wayland-graphics-integration-client
PLUGIN_CLASS_NAME = QWaylandEglClientBufferPlugin PLUGIN_CLASS_NAME = QWaylandEglClientBufferPlugin
load(qt_plugin) load(qt_plugin)

View File

@ -66,7 +66,7 @@ void QWaylandBuffer::init(wl_buffer *buf)
void QWaylandBuffer::release(void *data, wl_buffer *) void QWaylandBuffer::release(void *data, wl_buffer *)
{ {
static_cast<QWaylandBuffer *>(data)->mBusy--; static_cast<QWaylandBuffer *>(data)->mBusy = false;
} }
const wl_buffer_listener QWaylandBuffer::listener = { const wl_buffer_listener QWaylandBuffer::listener = {

View File

@ -73,14 +73,14 @@ public:
virtual QSize size() const = 0; virtual QSize size() const = 0;
virtual int scale() const { return 1; } virtual int scale() const { return 1; }
void setBusy() { mBusy++; } void setBusy() { mBusy = true; }
bool busy() const { return mBusy > 0; } bool busy() const { return mBusy; }
protected: protected:
struct wl_buffer *mBuffer; struct wl_buffer *mBuffer;
private: private:
int mBusy; bool mBusy;
static void release(void *data, wl_buffer *); static void release(void *data, wl_buffer *);
static const wl_buffer_listener listener; static const wl_buffer_listener listener;

View File

@ -1050,7 +1050,7 @@ QVariant QWaylandWindow::property(const QString &name, const QVariant &defaultVa
void QWaylandWindow::requestUpdate() void QWaylandWindow::requestUpdate()
{ {
if (!mFrameCallback) if (!mWaitingForFrameSync)
QPlatformWindow::requestUpdate(); QPlatformWindow::requestUpdate();
else else
mUpdateRequested = true; mUpdateRequested = true;

View File

@ -125,6 +125,8 @@ QWaylandXdgSurfaceV6::QWaylandXdgSurfaceV6(QWaylandXdgShellV6 *shell, ::zxdg_sur
QWaylandXdgSurfaceV6::~QWaylandXdgSurfaceV6() QWaylandXdgSurfaceV6::~QWaylandXdgSurfaceV6()
{ {
if (m_toplevel)
zxdg_toplevel_v6_destroy(m_toplevel->object());
if (m_popup) if (m_popup)
zxdg_popup_v6_destroy(m_popup->object()); zxdg_popup_v6_destroy(m_popup->object());
destroy(); destroy();
@ -169,7 +171,8 @@ void QWaylandXdgSurfaceV6::setType(Qt::WindowType type, QWaylandWindow *transien
setToplevel(); setToplevel();
if (transientParent) { if (transientParent) {
auto parentXdgSurface = static_cast<QWaylandXdgSurfaceV6 *>(transientParent->shellSurface()); auto parentXdgSurface = static_cast<QWaylandXdgSurfaceV6 *>(transientParent->shellSurface());
m_toplevel->set_parent(parentXdgSurface->m_toplevel->object()); if (parentXdgSurface)
m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
} }
} }
} }

View File

@ -35,8 +35,12 @@
#include <QMimeData> #include <QMimeData>
#include <QPixmap> #include <QPixmap>
#include <QDrag> #include <QDrag>
#include <QWindow>
#include <QOpenGLWindow>
#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);
@ -97,6 +101,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;
@ -109,6 +115,25 @@ public:
QPoint mousePressPos; QPoint mousePressPos;
}; };
class TestGlWindow : public QOpenGLWindow
{
Q_OBJECT
public:
TestGlWindow();
protected:
void paintGL() override;
};
TestGlWindow::TestGlWindow()
{}
void TestGlWindow::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT);
}
class tst_WaylandClient : public QObject class tst_WaylandClient : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -149,6 +174,7 @@ private slots:
void dontCrashOnMultipleCommits(); void dontCrashOnMultipleCommits();
void hiddenTransientParent(); void hiddenTransientParent();
void hiddenPopupParent(); void hiddenPopupParent();
void glWindow();
private: private:
MockCompositor *compositor; MockCompositor *compositor;
@ -235,7 +261,7 @@ void tst_WaylandClient::removePrimaryScreen()
compositor->sendRemoveOutput(firstOutput); compositor->sendRemoveOutput(firstOutput);
QTRY_COMPARE(QGuiApplication::screens().size(), 1); QTRY_COMPARE(QGuiApplication::screens().size(), 1);
compositor->sendMousePress(surface, QPoint(10, 10)); compositor->sendMousePress(surface, window.frameOffset() + QPoint(10, 10));
QTRY_COMPARE(window.mousePressEventCount, 1); QTRY_COMPARE(window.mousePressEventCount, 1);
compositor->sendMouseRelease(surface); compositor->sendMouseRelease(surface);
QTRY_COMPARE(window.mouseReleaseEventCount, 1); QTRY_COMPARE(window.mouseReleaseEventCount, 1);
@ -290,7 +316,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);
@ -299,7 +325,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);
@ -358,6 +384,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:
@ -392,14 +419,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);
@ -416,10 +443,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);
@ -480,7 +507,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;
@ -494,20 +521,37 @@ void tst_WaylandClient::hiddenPopupParent()
QTRY_VERIFY(compositor->surface()); QTRY_VERIFY(compositor->surface());
} }
void tst_WaylandClient::glWindow()
{
QSKIP("Skipping GL tests, as not supported by all CI systems: See https://bugreports.qt.io/browse/QTBUG-65802");
QScopedPointer<TestGlWindow> testWindow(new TestGlWindow);
testWindow->show();
QSharedPointer<MockSurface> surface;
QTRY_VERIFY(surface = compositor->surface());
//confirm we don't crash when we delete an already hidden GL window
//QTBUG-65553
testWindow->setVisible(false);
QTRY_VERIFY(!compositor->surface());
}
int main(int argc, char **argv) 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.setOutputMode(screenSize); compositor.setOutputMode(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);

View File

@ -360,7 +360,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)
@ -373,7 +375,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

@ -1,5 +1,6 @@
CONFIG += testcase link_pkgconfig CONFIG += testcase link_pkgconfig
QT += testlib QT += testlib
QT += core-private gui-private waylandclient-private
QMAKE_USE += wayland-client wayland-server QMAKE_USE += wayland-client wayland-server