kernel/qplatformwindow_qpa.h \
kernel/qplatformglcontext_qpa.h \
kernel/qwindowcontext_qpa.h \
- kernel/qplatformeventloopintegration_qpa.h \
kernel/qplatformcursor_qpa.h \
kernel/qplatformclipboard_qpa.h \
kernel/qplatformnativeinterface_qpa.h \
kernel/qplatformintegrationfactory_qpa.cpp \
kernel/qplatformintegrationplugin_qpa.cpp \
kernel/qplatformwindow_qpa.cpp \
- kernel/qplatformeventloopintegration_qpa.cpp \
kernel/qplatformglcontext_qpa.cpp \
kernel/qwindowcontext_qpa.cpp \
kernel/qplatformcursor_qpa.cpp \
d->userEventSource = 0;
}
-bool QPAEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags)
-{
- static bool init = false;
- if (!init) {
- if (QGuiApplicationPrivate::platformIntegration()->createEventLoopIntegration()) {
- qWarning("Eventloop integration is not supported by the glib event dispatcher");
- qWarning("Use the UNIX event dispatcher by defining environment variable QT_NO_GLIB=1");
- }
- init = true;
- }
- return QEventDispatcherGlib::processEvents(flags);
-}
-
QT_END_NAMESPACE
public:
explicit QPAEventDispatcherGlib(QObject *parent = 0);
~QPAEventDispatcherGlib();
-
- bool processEvents(QEventLoop::ProcessEventsFlags flags);
};
struct GUserEventSource;
#include "qcoreapplication.h"
#include "qeventdispatcher_qpa_p.h"
#include "private/qguiapplication_p.h"
-#include "qplatformeventloopintegration_qpa.h"
#include <QWindowSystemInterface>
#include <QtCore/QElapsedTimer>
QT_USE_NAMESPACE
-class Rendezvous
+QEventDispatcherQPAPrivate::QEventDispatcherQPAPrivate()
{
-public:
- void checkpoint()
- {
- if (state.testAndSetOrdered(0,1)) {
- semaphore.acquire();
- } else if (state.testAndSetAcquire(1,0)) {
- semaphore.release();
- } else {
- qWarning("Barrier internal error");
- }
- }
-private:
- QSemaphore semaphore;
- QAtomicInt state;
-};
-
-class SelectWorker : public QThread
-{
-public:
- SelectWorker(QEventDispatcherQPAPrivate *eventDispatcherPrivate)
- : QThread(),
- m_edPrivate(eventDispatcherPrivate),
- m_retVal(0)
- {
- }
-
- void setSelectValues(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
- {
- m_nfds = nfds;
- m_readfds = readfds;
- m_writefds = writefds;
- m_exceptfds = exceptfds;
-
- }
-
- int retVal() const {
- return m_retVal;
- }
-
-protected:
- void run();
-
-private:
- QEventDispatcherQPAPrivate *m_edPrivate;
- int m_retVal;
-
- int m_nfds;
- fd_set *m_readfds, *m_writefds, *m_exceptfds;
-};
+}
-class QEventDispatcherQPAPrivate : public EVENTDISPATCHERBASEPRIVATE
+QEventDispatcherQPAPrivate::~QEventDispatcherQPAPrivate()
{
- Q_DECLARE_PUBLIC(QEventDispatcherQPA)
-public:
- QEventDispatcherQPAPrivate()
- : eventLoopIntegration(0),
- barrierBeforeBlocking(0),
- barrierReturnValue(0),
- selectReturnMutex(0),
- selectWorkerNeedsSync(true),
- selectWorkerHasResult(false),
- m_integrationInitialised(false),
- m_hasIntegration(false),
- m_isEventLoopIntegrationRunning(false)
- {
- }
-
- ~QEventDispatcherQPAPrivate()
- {
- delete selectWorker;
- delete eventLoopIntegration;
- delete barrierBeforeBlocking;
- delete barrierReturnValue;
- delete selectReturnMutex;
- }
-
- bool hasIntegration() const
- {
- if (!m_integrationInitialised) {
- QEventDispatcherQPAPrivate *that = const_cast<QEventDispatcherQPAPrivate *>(this);
- if (qApp && (qApp->thread() == QThread::currentThread())) { // guiThread
- if (QGuiApplicationPrivate::platformIntegration()) {
- that->eventLoopIntegration = QGuiApplicationPrivate::platformIntegration()->createEventLoopIntegration();
- if (that->eventLoopIntegration) {
- that->selectWorker = new SelectWorker(that);
- that->barrierBeforeBlocking = new Rendezvous;
- that->barrierReturnValue = new Rendezvous;
- that->selectReturnMutex = new QMutex;
- that->selectWorker->start();
- that->m_hasIntegration = true;
- if (!QElapsedTimer::isMonotonic())
- qWarning("Having eventloop integration without monotonic timers can lead to undefined behaviour");
- }
- }
- }
- that->m_integrationInitialised = true;
- }
- return m_hasIntegration;
- }
-
- bool isEventLoopIntegrationRunning() const
- {
- return m_isEventLoopIntegrationRunning;
- }
-
- void runEventLoopIntegration()
- {
- if (qApp && (qApp->thread() == QThread::currentThread())) {
- m_isEventLoopIntegrationRunning = true;
- eventLoopIntegration->startEventLoop();
- }
- }
-
- QPlatformEventLoopIntegration *eventLoopIntegration;
- Rendezvous *barrierBeforeBlocking;
- Rendezvous *barrierReturnValue;
-
- QMutex *selectReturnMutex;
- bool selectWorkerNeedsSync;
- bool selectWorkerHasResult;
-
- SelectWorker *selectWorker;
-private:
- bool m_integrationInitialised;
- bool m_hasIntegration;
- bool m_isEventLoopIntegrationRunning;
-};
+}
QEventDispatcherQPA::QEventDispatcherQPA(QObject *parent)
: EVENTDISPATCHERBASE(*new QEventDispatcherQPAPrivate, parent)
{ }
+QEventDispatcherQPA::QEventDispatcherQPA(QEventDispatcherUNIXPrivate &priv, QObject *parent)
+ : EVENTDISPATCHERBASE(priv, parent)
+{ }
+
+
QEventDispatcherQPA::~QEventDispatcherQPA()
{ }
{
Q_D(QEventDispatcherQPA);
- if (d->hasIntegration()) {
- if (!d->isEventLoopIntegrationRunning()) {
- d->runEventLoopIntegration();
- }
- if (d->threadData->quitNow) {
- d->eventLoopIntegration->quitEventLoop();
- return false;
- }
- }
-
int nevents = 0;
// handle gui and posted events
return qGlobalPostedEventsCount() || QWindowSystemInterfacePrivate::windowSystemEventsQueued();
}
-void QEventDispatcherQPA::registerSocketNotifier(QSocketNotifier *notifier)
-{
- Q_D(QEventDispatcherQPA);
- EVENTDISPATCHERBASE::registerSocketNotifier(notifier);
- if (d->hasIntegration())
- wakeUp();
-
-}
-
-void QEventDispatcherQPA::unregisterSocketNotifier(QSocketNotifier *notifier)
-{
- Q_D(QEventDispatcherQPA);
- EVENTDISPATCHERBASE::unregisterSocketNotifier(notifier);
- if (d->hasIntegration())
- wakeUp();
-}
-
void QEventDispatcherQPA::flush()
{
if(qApp)
qApp->sendPostedEvents();
}
-int QEventDispatcherQPA::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- timeval *timeout)
-{
- Q_D(QEventDispatcherQPA);
- int retVal = 0;
- if (d->hasIntegration()) {
- qint64 timeoutmsec = 0;
- if (timeout)
- timeoutmsec = timeout->tv_sec * 1000 + (timeout->tv_usec/1000);
- d->selectReturnMutex->lock();
- if (d->selectWorkerNeedsSync) {
- if (d->selectWorkerHasResult) {
- retVal = d->selectWorker->retVal();
- d->selectWorkerHasResult = false;
-
- d->selectReturnMutex->unlock();
- d->barrierReturnValue->checkpoint();
- d->eventLoopIntegration->setNextTimerEvent(0);
- return retVal;
- } else {
- d->selectWorkerNeedsSync = false;
- d->selectWorker->setSelectValues(nfds,readfds, writefds, exceptfds);
- d->barrierBeforeBlocking->checkpoint();
- }
- }
- d->selectReturnMutex->unlock();
- d->eventLoopIntegration->setNextTimerEvent(timeoutmsec);
- retVal = 0; //is 0 if select has not returned
- } else {
-#if defined(Q_OS_UNIX)
- retVal = EVENTDISPATCHERBASE::select(nfds, readfds, writefds, exceptfds, timeout);
-#elif defined(Q_OS_WIN)
- // ### TODO
-#endif
- }
- return retVal;
-}
-
-
-void SelectWorker::run()
-{
-
- while(true) {
- m_retVal = 0;
- m_edPrivate->barrierBeforeBlocking->checkpoint(); // wait for mainthread
-#if defined(Q_OS_UNIX)
- int tmpRet = qt_safe_select(m_nfds,m_readfds,m_writefds,m_exceptfds,0);
-#elif defined(Q_OS_WIN)
- // ### TODO
- int tmpRet = 0;
-#endif
- m_edPrivate->selectReturnMutex->lock();
- m_edPrivate->eventLoopIntegration->qtNeedsToProcessEvents();
-
- m_edPrivate->selectWorkerNeedsSync = true;
- m_edPrivate->selectWorkerHasResult = true;
- m_retVal = tmpRet;
-
- m_edPrivate->selectReturnMutex->unlock();
- m_edPrivate->barrierReturnValue->checkpoint();
- }
-}
QT_END_NAMESPACE
public:
explicit QEventDispatcherQPA(QObject *parent = 0);
+ QEventDispatcherQPA(QEventDispatcherUNIXPrivate &priv, QObject *parent);
~QEventDispatcherQPA();
bool processEvents(QEventLoop::ProcessEventsFlags flags);
bool hasPendingEvents();
- void registerSocketNotifier(QSocketNotifier *notifier);
- void unregisterSocketNotifier(QSocketNotifier *notifier);
-
void flush();
+};
-protected:
- int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- timeval *timeout);
+class QEventDispatcherQPAPrivate : public EVENTDISPATCHERBASEPRIVATE
+{
+ Q_DECLARE_PUBLIC(QEventDispatcherQPA)
+public:
+ QEventDispatcherQPAPrivate();
+ ~QEventDispatcherQPAPrivate();
};
QT_END_NAMESPACE
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformeventloopintegration_qpa.h"
-
-#include <QtCore/QCoreApplication>
-
-#include <QtCore/QDebug>
-
-class QPlatformEventLoopIntegrationPrivate
-{
-public:
- QPlatformEventLoopIntegrationPrivate();
- qint64 nextTimerEvent;
-};
-
-QPlatformEventLoopIntegrationPrivate::QPlatformEventLoopIntegrationPrivate()
- : nextTimerEvent(0)
-{
-}
-
-QPlatformEventLoopIntegration::QPlatformEventLoopIntegration()
- : d_ptr(new QPlatformEventLoopIntegrationPrivate)
-
-{
-}
-
-QPlatformEventLoopIntegration::~QPlatformEventLoopIntegration()
-{
-}
-
-qint64 QPlatformEventLoopIntegration::nextTimerEvent() const
-{
- Q_D(const QPlatformEventLoopIntegration);
- return d->nextTimerEvent;
-}
-
-
-void QPlatformEventLoopIntegration::setNextTimerEvent(qint64 nextTimerEvent)
-{
- Q_D(QPlatformEventLoopIntegration);
- d->nextTimerEvent = nextTimerEvent;
-}
-
-void QPlatformEventLoopIntegration::processEvents()
-{
- QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents);
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPLATFORMEVENTLOOPINTEGRATION_QPA_H
-#define QPLATFORMEVENTLOOPINTEGRATION_QPA_H
-
-#include <QtCore/qglobal.h>
-#include <QtCore/QScopedPointer>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QPlatformEventLoopIntegrationPrivate;
-
-class Q_GUI_EXPORT QPlatformEventLoopIntegration
-{
- Q_DECLARE_PRIVATE(QPlatformEventLoopIntegration);
-public:
- QPlatformEventLoopIntegration();
- virtual ~QPlatformEventLoopIntegration();
-
- virtual void startEventLoop() = 0;
- virtual void quitEventLoop() = 0;
- virtual void qtNeedsToProcessEvents() = 0;
-
- qint64 nextTimerEvent() const;
- void setNextTimerEvent(qint64 nextTimerEvent);
-
- static void processEvents();
-protected:
- QScopedPointer<QPlatformEventLoopIntegrationPrivate> d_ptr;
-private:
- Q_DISABLE_COPY(QPlatformEventLoopIntegration);
- friend class QEventDispatcherQPA;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QPLATFORMEVENTLOOPINTEGRATION_QPA_H
return QPixmap();
}
-/*!
- Factory function for the eventloop integration interface.
-
- Default implementation returns 0, which causes the eventloop to run in a single thread mode.
-
- \sa QPlatformEventLoopIntegration
-*/
-QPlatformEventLoopIntegration *QPlatformIntegration::createEventLoopIntegration() const
-{
- return 0;
-}
/*!
Accessor for the platform integrations fontdatabase.
class QPlatformWindow;
class QWindow;
class QBlittable;
-class QPlatformEventLoopIntegration;
class QPlatformFontDatabase;
class QPlatformClipboard;
class QPlatformNativeInterface;
virtual QPlatformDrag *drag() const;
#endif
-// Experimental in mainthread eventloop integration
-// This should only be used if it is only possible to do window system event processing in
-// the gui thread. All of the functions in QWindowSystemInterface are thread safe.
- virtual QPlatformEventLoopIntegration *createEventLoopIntegration() const;
-
// Access native handles. The window handle is already available from Wid;
virtual QPlatformNativeInterface *nativeInterface() const;
QT_CLASS_LIB(QPlatformCursorImage, QtGui, qplatformcursor_qpa.h)
QT_CLASS_LIB(QPlatformCursorPrivate, QtGui, qplatformcursor_qpa.h)
QT_CLASS_LIB(QPlatformCursor, QtGui, qplatformcursor_qpa.h)
-QT_CLASS_LIB(QPlatformEventLoopIntegration, QtGui, qplatformeventloopintegration_qpa.h)
QT_CLASS_LIB(QPlatformGLContext, QtGui, qplatformglcontext_qpa.h)
QT_CLASS_LIB(QPlatformIntegration, QtGui, qplatformintegration_qpa.h)
QT_CLASS_LIB(QPlatformIntegrationFactoryInterface, QtGui, qplatformintegrationplugin_qpa.h)