diff options
author | Morten Sorvig <morten.sorvig@nokia.com> | 2009-11-10 07:01:14 -0600 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@nokia.com> | 2009-11-26 12:39:45 +0100 |
commit | 1e656716809d1ce0beee25c93d26db56804f1ba2 (patch) | |
tree | d37e49deef3572df9f78b0a2c5488af1808b6adb /src/gui | |
parent | abc7777911ef2f4a401cfaef86bffaea090755c7 (diff) |
Add NaCl event dispatcher.
Not based on unix, since nacl is missing
most of the required system calls.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/kernel.pri | 5 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_lite.cpp | 8 | ||||
-rw-r--r-- | src/gui/kernel/qeventdispatcher_nacl.cpp | 217 | ||||
-rw-r--r-- | src/gui/kernel/qeventdispatcher_nacl_p.h | 93 |
4 files changed, 322 insertions, 1 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 73dfd52d2f..81e3520d32 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -211,6 +211,11 @@ embedded_lite { kernel/qwidget_lite.cpp } +nacl { + HEADERS += kernel/qeventdispatcher_nacl_p.h + SOURCES += kernel/qeventdispatcher_nacl.cpp +} + !embedded:!embedded_lite:!x11:mac { SOURCES += \ kernel/qclipboard_mac.cpp \ diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index a42bfd767c..ac21c8d387 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -45,6 +45,9 @@ #if !defined(QT_NO_GLIB) #include "private/qeventdispatcher_glib_p.h" #endif +#ifdef Q_OS_NACL +#include "private/qeventdispatcher_nacl_p.h" +#endif #include "private/qeventdispatcher_unix_p.h" #ifndef QT_NO_CURSOR #include "private/qcursor_p.h" @@ -87,8 +90,11 @@ void QApplicationPrivate::createEventDispatcher() if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported()) eventDispatcher = new QEventDispatcherGlib(q); else -#endif +#elif defined(Q_OS_NACL) + eventDispatcher = new QEventDispatcherNaCl(q); +#else eventDispatcher = new QEventDispatcherUNIX(q); +#endif } static bool qt_try_modal(QWidget *widget, const QEvent *event) diff --git a/src/gui/kernel/qeventdispatcher_nacl.cpp b/src/gui/kernel/qeventdispatcher_nacl.cpp new file mode 100644 index 0000000000..f853a0eb6f --- /dev/null +++ b/src/gui/kernel/qeventdispatcher_nacl.cpp @@ -0,0 +1,217 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qeventdispatcher_nacl_p.h" + +#include "qplatformdefs.h" +#include "qapplication.h" +#include "qwaitcondition.h" +#include "qevent.h" +#include "qmutex.h" +#include <errno.h> +#include <stdio.h> + +#include <nacl/nacl_av.h> + +QT_BEGIN_NAMESPACE + +QT_USE_NAMESPACE + +class QEventDispatcherNaClPrivate : public QAbstractEventDispatcherPrivate +{ + Q_DECLARE_PUBLIC(QEventDispatcherNaCl) +public: + inline QEventDispatcherNaClPrivate() + { } +// QList<NaClEvent*> queuedUserInputEvents; + QWaitCondition delay; + QMutex mutex; +}; + + +QEventDispatcherNaCl::QEventDispatcherNaCl(QObject *parent) + : QAbstractEventDispatcher(*new QEventDispatcherNaClPrivate, parent) +{ } + +QEventDispatcherNaCl::~QEventDispatcherNaCl() +{ } + + +bool QEventDispatcherNaCl::processEvents(QEventLoop::ProcessEventsFlags flags) +{ + Q_D(QEventDispatcherNaCl); + + // perror("QEventDispatcherNaCl::foo()"); + // perror("QEventDispatcherNaCl::processEvents()"); + + NaClMultimediaEvent event; + + do { + QApplication::sendPostedEvents(); + nacl_video_poll_event(&event); + + if (event.type == NACL_EVENT_MOUSE_BUTTON_DOWN) { + perror("mouse down"); + QPoint p; + + QMouseEvent mouseEvent(QEvent::MouseButtonPress, p, Qt::LeftButton, + Qt::LeftButton, Qt::NoModifier); + //qApp->handleMouseEvent(0, &mouseEvent); + //event + } + + if (event.type == NACL_EVENT_MOUSE_BUTTON_UP) { + perror("mouse up"); + } + + if (event.type == NACL_EVENT_MOUSE_MOTION) { + perror(" mouse motion"); + } + if (event.type == NACL_EVENT_QUIT) { + perror(" quit"); + qApp->quit(); + break; + } + } while(flags & QEventLoop::WaitForMoreEvents); // busy-wait for more events + + + // if (flags & QEventLoop::WaitForMoreEvents) { + // d->mutex.lock(); + // d->delay.wait(&d->mutex, 1); + //} + + // perror("QEventDispatcherNaCl::foo()"); + +// d->interrupt = false; +// QApplication::sendPostedEvents(); +// if (!(flags & QEventLoop::ExcludeUserInputEvents) +// bool ret = qApp->NaClProcessEvent(event) == 1; +// if (filterEvent(event)) { + // delete event; + // continue; + // } +// if (QEventDispatcherUNIX::processEvents(flags)) + // return true; +// } +// return (nevents > 0); + + return false; +} + +bool QEventDispatcherNaCl::hasPendingEvents() +{ + perror("QEventDispatcherNaCl::hasPendingEvents()"); + extern uint qGlobalPostedEventsCount(); // from qapplication.cpp + return qGlobalPostedEventsCount(); +} + +void QEventDispatcherNaCl::registerSocketNotifier(QSocketNotifier *notifier) +{ + perror("QEventDispatcherNaCl::registerSocketNotifier()"); +} + +void QEventDispatcherNaCl::unregisterSocketNotifier(QSocketNotifier *notifier) +{ + perror("QEventDispatcherNaCl::unregisterSocketNotifier()"); +} + +void QEventDispatcherNaCl::registerTimer(int timerId, int interval, QObject *object) +{ + perror("QEventDispatcherNaCl::registerTimer()"); +} + +bool QEventDispatcherNaCl::unregisterTimer(int timerId) +{ + perror("QEventDispatcherNaCl::unregisterTimer()"); + return true; +} + +bool QEventDispatcherNaCl::unregisterTimers(QObject *object) +{ + perror("QEventDispatcherNaCl::unregisterTimers()"); + return true; +} + +QList<QAbstractEventDispatcher::TimerInfo> QEventDispatcherNaCl::registeredTimers(QObject *object) const +{ + perror("QEventDispatcherNaCl::registeredTimers()"); + QList<QAbstractEventDispatcher::TimerInfo> timerInfo; + return timerInfo; +} + +void QEventDispatcherNaCl::startingUp() +{ + perror("QEventDispatcherNaCl::startingUp()"); + int error; + error = nacl_multimedia_init(NACL_SUBSYSTEM_VIDEO); + if (error == -1) + perror("FAILED: QEventDispatcherNaCl::startingUp : nacl_multimedia_init(NACL_SUBSYSTEM_VIDEO);"); + + +} + +void QEventDispatcherNaCl::closingDown() +{ + perror("QEventDispatcherNaCl::closingDown()"); + int error; + error = nacl_multimedia_shutdown(); + if (error == -1) + perror("FAILED: QEventDispatcherNaCl::closingDown : nacl_multimedia_shutdown()"); +} + +void QEventDispatcherNaCl::wakeUp() +{ + perror("QEventDispatcherNaCl::wakeUp()"); +} + +void QEventDispatcherNaCl::interrupt() +{ + perror("QEventDispatcherNaCl::interrupt()"); +} + +void QEventDispatcherNaCl::flush() +{ + perror("QEventDispatcherNaCl::flush()"); + if(qApp) + qApp->sendPostedEvents(); +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qeventdispatcher_nacl_p.h b/src/gui/kernel/qeventdispatcher_nacl_p.h new file mode 100644 index 0000000000..c32949d6c1 --- /dev/null +++ b/src/gui/kernel/qeventdispatcher_nacl_p.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QEVENTDISPATCHER_NACL_P_H +#define QEVENTDISPATCHER_NACL_P_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 "private/qeventdispatcher_unix_p.h" + +QT_BEGIN_NAMESPACE + +class QEventDispatcherNaClPrivate; + +class QEventDispatcherNaCl : public QAbstractEventDispatcher +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QEventDispatcherNaCl) + +public: + explicit QEventDispatcherNaCl(QObject *parent = 0); + ~QEventDispatcherNaCl(); + + bool processEvents(QEventLoop::ProcessEventsFlags flags); + bool hasPendingEvents(); + + void registerSocketNotifier(QSocketNotifier *notifier); + void unregisterSocketNotifier(QSocketNotifier *notifier); + + void registerTimer(int timerId, int interval, QObject *object); + bool unregisterTimer(int timerId); + bool unregisterTimers(QObject *object); + QList<QAbstractEventDispatcher::TimerInfo> registeredTimers(QObject *object) const; + + void wakeUp(); + void interrupt(); + void flush(); + + void startingUp(); + void closingDown(); + +}; + +QT_END_NAMESPACE + +#endif // QEVENTDISPATCHER_NACL_P_H |