Merge remote-tracking branch 'qt/5.6' into wip-compositor-api

Change-Id: Ie70fdd03e1259a8cb75bbdbf1324e3e4a2b51807
This commit is contained in:
Paul Olav Tvete 2015-12-02 10:30:40 +01:00
commit 8c56476164
13 changed files with 62 additions and 248 deletions

View File

@ -16,7 +16,6 @@ load(qt_module)
QMAKE_CXXFLAGS_WARN_ON -= -Wcast-qual
CONFIG -= precompile_header
CONFIG -= create_cmake
CONFIG += link_pkgconfig qpa/genericunixfontdatabase wayland-scanner
!equals(QT_WAYLAND_GL_CONFIG, nogl) {
@ -78,7 +77,6 @@ SOURCES += qwaylandintegration.cpp \
qwaylandabstractdecoration.cpp \
qwaylanddecorationfactory.cpp \
qwaylanddecorationplugin.cpp \
qwaylandeventthread.cpp\
qwaylandwindowmanagerintegration.cpp \
qwaylandinputcontext.cpp \
qwaylanddatadevice.cpp \
@ -111,7 +109,6 @@ HEADERS += qwaylandintegration_p.h \
qwaylandabstractdecoration_p.h \
qwaylanddecorationfactory_p.h \
qwaylanddecorationplugin_p.h \
qwaylandeventthread_p.h \
qwaylandwindowmanagerintegration_p.h \
qwaylandinputcontext_p.h \
qwaylanddatadevice_p.h \

View File

@ -7,7 +7,7 @@ config_brcm_egl: \
SUBDIRS += brcm-egl
config_xcomposite {
config_egl: \
contains(QT_CONFIG, egl): \
SUBDIRS += xcomposite-egl
!contains(QT_CONFIG, opengles2):config_glx: \

View File

@ -151,7 +151,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
QDrag *drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->currentDrag();
QMimeData *dragData;
QMimeData *dragData = Q_NULLPTR;
Qt::DropActions supportedActions;
if (drag) {
dragData = drag->mimeData();

View File

@ -33,7 +33,6 @@
#include "qwaylanddisplay_p.h"
#include "qwaylandeventthread_p.h"
#include "qwaylandintegration_p.h"
#include "qwaylandwindow_p.h"
#include "qwaylandscreen_p.h"
@ -145,21 +144,15 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
{
qRegisterMetaType<uint32_t>("uint32_t");
mEventThreadObject = new QWaylandEventThread(0);
mEventThread = new QThread(this);
mEventThread->setObjectName(QStringLiteral("QtWayland"));
mEventThreadObject->moveToThread(mEventThread);
mEventThread->start();
mEventThreadObject->displayConnect();
mDisplay = mEventThreadObject->display(); //blocks until display is available
mDisplay = wl_display_connect(NULL);
if (mDisplay == NULL) {
qErrnoWarning(errno, "Failed to create display");
::exit(1);
}
struct ::wl_registry *registry = wl_display_get_registry(mDisplay);
init(registry);
connect(mEventThreadObject, SIGNAL(newEventsRead()), this, SLOT(flushRequests()));
connect(mEventThreadObject, &QWaylandEventThread::fatalError, this, &QWaylandDisplay::exitWithError);
mWindowManagerIntegration.reset(new QWaylandWindowManagerIntegration(this));
forceRoundTrip();
@ -175,15 +168,28 @@ QWaylandDisplay::~QWaylandDisplay(void)
}
mScreens.clear();
delete mDndSelectionHandler.take();
mEventThread->quit();
mEventThread->wait();
delete mEventThreadObject;
wl_display_disconnect(mDisplay);
}
void QWaylandDisplay::checkError() const
{
int ecode = wl_display_get_error(mDisplay);
if ((ecode == EPIPE || ecode == ECONNRESET)) {
// special case this to provide a nicer error
qWarning("The Wayland connection broke. Did the Wayland compositor die?");
} else {
qErrnoWarning(ecode, "The Wayland connection experienced a fatal error");
}
}
void QWaylandDisplay::flushRequests()
{
if (wl_display_prepare_read(mDisplay) == 0) {
wl_display_read_events(mDisplay);
}
if (wl_display_dispatch_pending(mDisplay) < 0) {
mEventThreadObject->checkError();
checkError();
exitWithError();
}
@ -194,15 +200,13 @@ void QWaylandDisplay::flushRequests()
void QWaylandDisplay::blockingReadEvents()
{
if (wl_display_dispatch(mDisplay) < 0) {
mEventThreadObject->checkError();
checkError();
exitWithError();
}
}
void QWaylandDisplay::exitWithError()
{
mEventThread->quit();
mEventThread->wait();
::exit(1);
}

View File

@ -176,6 +176,7 @@ public slots:
private:
void waitForScreens();
void exitWithError();
void checkError() const;
struct Listener {
RegistryListener listener;
@ -185,8 +186,6 @@ private:
struct wl_display *mDisplay;
QtWayland::wl_compositor mCompositor;
struct wl_shm *mShm;
QThread *mEventThread;
QWaylandEventThread *mEventThreadObject;
QScopedPointer<QtWayland::wl_shell> mShell;
QScopedPointer<QWaylandXdgShell> mShellXdg;
QList<QWaylandScreen *> mScreens;

View File

@ -65,21 +65,9 @@ QMimeData * QWaylandDrag::platformDropData()
void QWaylandDrag::startDrag()
{
bool cancel = false;
if (!shapedPixmapWindow()) {
QBasicDrag::startDrag();
// Don't call cancel() here, since that will hide 'shapedPixmapWindow()', and
// QWaylandWindow::setVisible(false) will flush the window system queue,
// ending up trying to render the window, which doesn't have a role yet,
// and so blocking waiting for a frame callback.
cancel = true;
}
QBasicDrag::startDrag();
QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon);
if (cancel)
QBasicDrag::cancel();
QBasicDrag::startDrag();
}
void QWaylandDrag::cancel()

View File

@ -1,112 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** 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 The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwaylandeventthread_p.h"
#include <QtCore/QSocketNotifier>
#include <QCoreApplication>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
QWaylandEventThread::QWaylandEventThread(QObject *parent)
: QObject(parent)
, m_display(0)
, m_fileDescriptor(-1)
, m_readNotifier(0)
, m_displayLock(new QMutex)
{
}
QWaylandEventThread::~QWaylandEventThread()
{
delete m_displayLock;
wl_display_disconnect(m_display);
}
void QWaylandEventThread::displayConnect()
{
m_displayLock->lock();
QMetaObject::invokeMethod(this, "waylandDisplayConnect", Qt::QueuedConnection);
}
// ### be careful what you do, this function may also be called from other
// threads to clean up & exit.
void QWaylandEventThread::checkError() const
{
int ecode = wl_display_get_error(m_display);
if ((ecode == EPIPE || ecode == ECONNRESET)) {
// special case this to provide a nicer error
qWarning("The Wayland connection broke. Did the Wayland compositor die?");
} else {
qErrnoWarning(ecode, "The Wayland connection experienced a fatal error");
}
}
void QWaylandEventThread::readWaylandEvents()
{
if (wl_display_prepare_read(m_display) == 0) {
wl_display_read_events(m_display);
}
emit newEventsRead();
}
void QWaylandEventThread::waylandDisplayConnect()
{
m_display = wl_display_connect(NULL);
if (m_display == NULL) {
qErrnoWarning(errno, "Failed to create display");
::exit(1);
}
m_displayLock->unlock();
m_fileDescriptor = wl_display_get_fd(m_display);
m_readNotifier = new QSocketNotifier(m_fileDescriptor, QSocketNotifier::Read, this);
connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(readWaylandEvents()));
}
wl_display *QWaylandEventThread::display() const
{
QMutexLocker displayLock(m_displayLock);
return m_display;
}
}
QT_END_NAMESPACE

View File

@ -1,97 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** 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 The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWAYLANDEVENTTHREAD_H
#define QWAYLANDEVENTTHREAD_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QObject>
#include <QMutex>
#include <wayland-client.h>
#include <QtWaylandClient/private/qwaylandclientexport_p.h>
QT_BEGIN_NAMESPACE
class QSocketNotifier;
namespace QtWaylandClient {
class Q_WAYLAND_CLIENT_EXPORT QWaylandEventThread : public QObject
{
Q_OBJECT
public:
explicit QWaylandEventThread(QObject *parent = 0);
~QWaylandEventThread();
void displayConnect();
wl_display *display() const;
void checkError() const;
private slots:
void readWaylandEvents();
void waylandDisplayConnect();
signals:
void newEventsRead();
void fatalError();
private:
struct wl_display *m_display;
int m_fileDescriptor;
QSocketNotifier *m_readNotifier;
QMutex *m_displayLock;
};
}
QT_END_NAMESPACE
#endif // QWAYLANDEVENTTHREAD_H

View File

@ -68,6 +68,7 @@ static Qt::Key toQtKey(uint32_t sym)
return Qt::Key_unknown;
}
#else
Q_UNUSED(sym)
return Qt::Key_unknown;
#endif
}

View File

@ -54,6 +54,7 @@
#include <qpa/qplatformcursor.h>
#include <QtGui/QSurfaceFormat>
#include <QtGui/QOpenGLContext>
#include <QSocketNotifier>
#include <qpa/qplatforminputcontextfactory_p.h>
#include <qpa/qplatformaccessibility.h>
@ -201,6 +202,10 @@ void QWaylandIntegration::initialize()
QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay, SLOT(flushRequests()));
QObject::connect(dispatcher, SIGNAL(awake()), mDisplay, SLOT(flushRequests()));
int fd = wl_display_get_fd(mDisplay->wl_display());
QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay);
QObject::connect(sn, SIGNAL(activated(int)), mDisplay, SLOT(flushRequests()));
}
QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const

View File

@ -39,6 +39,7 @@
#include "qwaylanddisplay_p.h"
#include "qwaylandwindowmanagerintegration_p.h"
#include "qwaylandscreen_p.h"
#include "qwaylandwlshellsurface_p.h"
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/QScreen>
#include <QtWaylandClient/private/qwaylandclientbufferintegration_p.h>
@ -80,6 +81,15 @@ void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourc
if (lowerCaseResource == "surface") {
return ((QWaylandWindow *) window->handle())->object();
}
if (lowerCaseResource == "wl_shell_surface") {
QWaylandWindow *w = (QWaylandWindow *) window->handle();
if (!w)
return NULL;
QWaylandWlShellSurface *s = qobject_cast<QWaylandWlShellSurface *>(w->shellSurface());
if (!s)
return NULL;
return s->object();
}
if (lowerCaseResource == "egldisplay" && m_integration->clientBufferIntegration())
return m_integration->clientBufferIntegration()->nativeResource(QWaylandClientBufferIntegration::EglDisplay);

View File

@ -0,0 +1,12 @@
project(test_plugins)
cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0056 NEW)
find_package(Qt5WaylandClient REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
include_directories(${Qt5WaylandClient_PRIVATE_INCLUDE_DIRS})
add_executable(test_waylandclient_exe main.cpp)
target_link_libraries(test_waylandclient_exe Qt5::WaylandClient)

View File

@ -0,0 +1,7 @@
#include <private/qwaylandcursor_p.h>
int main()
{
// use symbol
QtWaylandClient::QWaylandCursor cursor(Q_NULLPTR);
}