summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-12-02 10:30:40 +0100
committerPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-12-02 10:35:50 +0100
commit3698b116a1973146b76319673cdb6787f13f2de6 (patch)
treede31e4c3365d6852ed1f41621960ac9e48e85106 /src/client
parent68993c012b88df43b2cd75a8c8704092760f28c0 (diff)
parent4d3c3a08eba8d30805f18397c98e19ab9fd40722 (diff)
Merge remote-tracking branch 'qt/5.6' into wip-compositor-api
Diffstat (limited to 'src/client')
-rw-r--r--src/client/client.pro3
-rw-r--r--src/client/qwaylanddatadevice.cpp2
-rw-r--r--src/client/qwaylanddisplay.cpp42
-rw-r--r--src/client/qwaylanddisplay_p.h3
-rw-r--r--src/client/qwaylanddnd.cpp14
-rw-r--r--src/client/qwaylandeventthread.cpp112
-rw-r--r--src/client/qwaylandeventthread_p.h97
-rw-r--r--src/client/qwaylandinputcontext.cpp1
-rw-r--r--src/client/qwaylandintegration.cpp5
-rw-r--r--src/client/qwaylandnativeinterface.cpp10
10 files changed, 42 insertions, 247 deletions
diff --git a/src/client/client.pro b/src/client/client.pro
index 9ebd0352e..182a5d551 100644
--- a/src/client/client.pro
+++ b/src/client/client.pro
@@ -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 \
diff --git a/src/client/qwaylanddatadevice.cpp b/src/client/qwaylanddatadevice.cpp
index 779fd9cc2..42ab2293a 100644
--- a/src/client/qwaylanddatadevice.cpp
+++ b/src/client/qwaylanddatadevice.cpp
@@ -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();
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
index dbb8e12dd..a6f52bc24 100644
--- a/src/client/qwaylanddisplay.cpp
+++ b/src/client/qwaylanddisplay.cpp
@@ -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);
}
diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h
index f6500b0b2..d5ee16fc9 100644
--- a/src/client/qwaylanddisplay_p.h
+++ b/src/client/qwaylanddisplay_p.h
@@ -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;
diff --git a/src/client/qwaylanddnd.cpp b/src/client/qwaylanddnd.cpp
index 59f91411f..e195d193a 100644
--- a/src/client/qwaylanddnd.cpp
+++ b/src/client/qwaylanddnd.cpp
@@ -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()
diff --git a/src/client/qwaylandeventthread.cpp b/src/client/qwaylandeventthread.cpp
deleted file mode 100644
index e0a3edcb8..000000000
--- a/src/client/qwaylandeventthread.cpp
+++ /dev/null
@@ -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
diff --git a/src/client/qwaylandeventthread_p.h b/src/client/qwaylandeventthread_p.h
deleted file mode 100644
index 0920d403e..000000000
--- a/src/client/qwaylandeventthread_p.h
+++ /dev/null
@@ -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
diff --git a/src/client/qwaylandinputcontext.cpp b/src/client/qwaylandinputcontext.cpp
index d1ac14982..b02e9f668 100644
--- a/src/client/qwaylandinputcontext.cpp
+++ b/src/client/qwaylandinputcontext.cpp
@@ -68,6 +68,7 @@ static Qt::Key toQtKey(uint32_t sym)
return Qt::Key_unknown;
}
#else
+ Q_UNUSED(sym)
return Qt::Key_unknown;
#endif
}
diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp
index 82df8a30a..39fff533d 100644
--- a/src/client/qwaylandintegration.cpp
+++ b/src/client/qwaylandintegration.cpp
@@ -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
diff --git a/src/client/qwaylandnativeinterface.cpp b/src/client/qwaylandnativeinterface.cpp
index 0d20075f0..98e1a7366 100644
--- a/src/client/qwaylandnativeinterface.cpp
+++ b/src/client/qwaylandnativeinterface.cpp
@@ -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);