From 76ba822e04e66f0cc49cd05af3b2b2db6b0ad9f5 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Wed, 13 Aug 2014 10:30:39 +0300 Subject: [PATCH 1/6] Make the expose region local Change-Id: I570bbe77185637ebe621e6c915eef2f4442fdd84 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/wayland/qwaylandwindow.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index a6190c0d171..6ebe610abef 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -315,9 +315,9 @@ void QWaylandWindow::setCanResize(bool canResize) } if (!mConfigure.isEmpty()) { doResize(); - QWindowSystemInterface::handleExposeEvent(window(), geometry()); + QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); } else if (mResizeDirty) { - QWindowSystemInterface::handleExposeEvent(window(), geometry()); + QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); mResizeDirty = false; } } @@ -333,7 +333,7 @@ void QWaylandWindow::requestResize() mRequestResizeSent = false; lock.unlock(); - QWindowSystemInterface::handleExposeEvent(window(), geometry()); + QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); QWindowSystemInterface::flushWindowSystemEvents(); } From 208fec2757059fe5a72d00a9c6ddb221baf87c5d Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Wed, 13 Aug 2014 11:29:37 +0200 Subject: [PATCH 2/6] Fix license test. Add missing copyright headers and fix existing (bad) ones. Change-Id: Ibbc6f3e996105305c8a2ed7d81ccee79795ee531 Reviewed-by: Andrew Knight --- .../qwaylandserverbufferintegration.cpp | 41 +++++++++++++++++++ .../platforms/wayland/qwaylandeventthread.cpp | 41 +++++++++++++++++++ .../platforms/wayland/qwaylandeventthread_p.h | 41 +++++++++++++++++++ 3 files changed, 123 insertions(+) diff --git a/src/plugins/platforms/wayland/hardwareintegration/qwaylandserverbufferintegration.cpp b/src/plugins/platforms/wayland/hardwareintegration/qwaylandserverbufferintegration.cpp index 6e3abe913f4..5bac689293a 100644 --- a/src/plugins/platforms/wayland/hardwareintegration/qwaylandserverbufferintegration.cpp +++ b/src/plugins/platforms/wayland/hardwareintegration/qwaylandserverbufferintegration.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qwaylandserverbufferintegration_p.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/wayland/qwaylandeventthread.cpp b/src/plugins/platforms/wayland/qwaylandeventthread.cpp index d309f7bb234..c6ac42bba8f 100644 --- a/src/plugins/platforms/wayland/qwaylandeventthread.cpp +++ b/src/plugins/platforms/wayland/qwaylandeventthread.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qwaylandeventthread_p.h" #include #include diff --git a/src/plugins/platforms/wayland/qwaylandeventthread_p.h b/src/plugins/platforms/wayland/qwaylandeventthread_p.h index 4174c96cfab..0d2758c4c67 100644 --- a/src/plugins/platforms/wayland/qwaylandeventthread_p.h +++ b/src/plugins/platforms/wayland/qwaylandeventthread_p.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QWAYLANDEVENTTHREAD_H #define QWAYLANDEVENTTHREAD_H From 68e5d64a830909b722a9277e50cd61c4fc2f83e2 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Wed, 13 Aug 2014 13:20:44 +0300 Subject: [PATCH 3/6] Reset the wl_keyboard/wl_pointer resource pointers if destroyed Change-Id: I8693f845817d2dd4b0e0b54352c374f6a0e643d3 Reviewed-by: Robin Burchell --- tests/auto/wayland/mockinput.cpp | 13 +++++++++++++ tests/auto/wayland/mockinput.h | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/tests/auto/wayland/mockinput.cpp b/tests/auto/wayland/mockinput.cpp index 40b01317f9a..7dbb735ed22 100644 --- a/tests/auto/wayland/mockinput.cpp +++ b/tests/auto/wayland/mockinput.cpp @@ -164,6 +164,13 @@ void Keyboard::sendKey(uint32_t key, uint32_t state) } } + +void Keyboard::keyboard_destroy_resource(wl_keyboard::Resource *resource) +{ + if (m_focusResource == resource) + m_focusResource = 0; +} + Pointer::Pointer(Compositor *compositor) : wl_pointer() , m_compositor(compositor) @@ -210,4 +217,10 @@ void Pointer::sendButton(uint32_t button, uint32_t state) } } +void Pointer::pointer_destroy_resource(wl_pointer::Resource *resource) +{ + if (m_focusResource == resource) + m_focusResource = 0; +} + } diff --git a/tests/auto/wayland/mockinput.h b/tests/auto/wayland/mockinput.h index 669bfaed608..128758cad93 100644 --- a/tests/auto/wayland/mockinput.h +++ b/tests/auto/wayland/mockinput.h @@ -88,6 +88,9 @@ public: void sendKey(uint32_t key, uint32_t state); +protected: + void keyboard_destroy_resource(wl_keyboard::Resource *resource) Q_DECL_OVERRIDE; + private: Compositor *m_compositor; @@ -107,6 +110,9 @@ public: void sendMotion(const QPoint &pos); void sendButton(uint32_t button, uint32_t state); +protected: + void pointer_destroy_resource(wl_pointer::Resource *resource) Q_DECL_OVERRIDE; + private: Compositor *m_compositor; From 5ef1d81af0401c2c1db396749d11b3ad8e7752a7 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Thu, 14 Aug 2014 16:50:57 +0300 Subject: [PATCH 4/6] Flush the wayland events on the dispatcher's awake signal This is not normally needed, but it is when an app, like our client test, needs to have the requests flushed out by a QCoreApplication::processEvents call. Change-Id: Id821eaf5b612dc44281141181a09718f409e7eb6 Reviewed-by: Robin Burchell --- src/plugins/platforms/wayland/qwaylandintegration.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 85300a13062..88eeed842ad 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -194,6 +194,7 @@ void QWaylandIntegration::initialize() { QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher; QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay, SLOT(flushRequests())); + QObject::connect(dispatcher, SIGNAL(awake()), mDisplay, SLOT(flushRequests())); } QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const From 6c9cd444fcf0d1e7598cd4a670836184b1c074bb Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Thu, 14 Aug 2014 16:57:47 +0300 Subject: [PATCH 5/6] Fix client tests Change-Id: I6511dfb826c522db3d8bd01c5670c06f187abff2 Reviewed-by: Robin Burchell --- tests/auto/wayland/mockcompositor.cpp | 10 ++++++++++ tests/auto/wayland/mockcompositor.h | 2 ++ tests/auto/wayland/tst_client.cpp | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/tests/auto/wayland/mockcompositor.cpp b/tests/auto/wayland/mockcompositor.cpp index e51f3ed577a..cfaa3478800 100644 --- a/tests/auto/wayland/mockcompositor.cpp +++ b/tests/auto/wayland/mockcompositor.cpp @@ -189,6 +189,11 @@ void *MockCompositor::run(void *data) return 0; } +void MockCompositor::discardSurfaces() +{ + m_compositor->discardSurfaces(); +} + namespace Impl { Compositor::Compositor() @@ -293,5 +298,10 @@ void Compositor::removeSurface(Surface *surface) m_pointer->setFocus(0, QPoint()); } +void Compositor::discardSurfaces() +{ + m_surfaces.clear(); +} + } diff --git a/tests/auto/wayland/mockcompositor.h b/tests/auto/wayland/mockcompositor.h index 7f3e2268312..68e55d3562c 100644 --- a/tests/auto/wayland/mockcompositor.h +++ b/tests/auto/wayland/mockcompositor.h @@ -81,6 +81,7 @@ public: void addSurface(Surface *surface); void removeSurface(Surface *surface); + void discardSurfaces(); static void setKeyboardFocus(void *data, const QList ¶meters); static void sendMousePress(void *data, const QList ¶meters); @@ -154,6 +155,7 @@ public: void sendKeyRelease(const QSharedPointer &surface, uint code); QSharedPointer surface(); + void discardSurfaces(); void lock(); void unlock(); diff --git a/tests/auto/wayland/tst_client.cpp b/tests/auto/wayland/tst_client.cpp index b43f531161e..9c3138bcb09 100644 --- a/tests/auto/wayland/tst_client.cpp +++ b/tests/auto/wayland/tst_client.cpp @@ -119,6 +119,9 @@ public: { QSocketNotifier *notifier = new QSocketNotifier(compositor->waylandFileDescriptor(), QSocketNotifier::Read, this); connect(notifier, SIGNAL(activated(int)), this, SLOT(processWaylandEvents())); + // connect to the event dispatcher to make sure to flush out the outgoing message queue + connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::awake, this, &tst_WaylandClient::processWaylandEvents); + connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::aboutToBlock, this, &tst_WaylandClient::processWaylandEvents); } public slots: @@ -146,7 +149,11 @@ private: void tst_WaylandClient::screen() { + QCoreApplication::processEvents(QEventLoop::AllEvents); + QTRY_COMPARE(QGuiApplication::primaryScreen()->size(), screenSize); + // discard the cursor surface created by the QWaylandInputDevice + compositor->discardSurfaces(); } void tst_WaylandClient::createDestroyWindow() From d9ba141df923049b3cf7e5cc91b2bf4898ddf16b Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Fri, 15 Aug 2014 19:38:13 +0300 Subject: [PATCH 6/6] Fix possible crash of the test client The cursor surface is not in the surfaces list when destroyed Change-Id: Ie29224679776d0abec7862d2976be892c63521a7 Reviewed-by: Robin Burchell --- tests/auto/wayland/mockcompositor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/wayland/mockcompositor.cpp b/tests/auto/wayland/mockcompositor.cpp index cfaa3478800..bb4f10fd942 100644 --- a/tests/auto/wayland/mockcompositor.cpp +++ b/tests/auto/wayland/mockcompositor.cpp @@ -291,7 +291,7 @@ void Compositor::addSurface(Surface *surface) void Compositor::removeSurface(Surface *surface) { - m_surfaces.remove(m_surfaces.indexOf(surface)); + m_surfaces.removeOne(surface); if (m_keyboard->focus() == surface) m_keyboard->setFocus(0); if (m_pointer->focus() == surface)