diff options
-rw-r--r-- | src/gui/kernel/qeventdispatcher_pepper.cpp | 164 | ||||
-rw-r--r-- | src/gui/kernel/qeventdispatcher_pepper_p.h | 12 | ||||
-rw-r--r-- | src/gui/painting/qgraphicssystem_pepper.cpp | 79 | ||||
-rw-r--r-- | src/gui/painting/qgraphicssystem_pepper.h | 85 | ||||
-rw-r--r-- | src/gui/painting/qwindowsurface_pepper.cpp | 120 | ||||
-rw-r--r-- | src/gui/painting/qwindowsurface_pepper.h | 73 |
6 files changed, 529 insertions, 4 deletions
diff --git a/src/gui/kernel/qeventdispatcher_pepper.cpp b/src/gui/kernel/qeventdispatcher_pepper.cpp index cd68295d84..7fe8a6167d 100644 --- a/src/gui/kernel/qeventdispatcher_pepper.cpp +++ b/src/gui/kernel/qeventdispatcher_pepper.cpp @@ -54,7 +54,6 @@ #include <time.h> #include <nacl/nacl_npapi.h> -#include <nacl/npapi_extensions.h> #include <nacl/npruntime.h> #include <nacl/npupp.h> @@ -75,7 +74,7 @@ public: bool QEventDispatcherPepper::hasPepperSupport() { bool hasSupport = false; - fprintf(stderr, "hasPepperSupport %b\n", hasSupport); + fprintf(stderr, "hasPepperSupport %d\n", hasSupport); return hasSupport; } @@ -89,6 +88,7 @@ QEventDispatcherPepper::~QEventDispatcherPepper() bool QEventDispatcherPepper::processEvents(QEventLoop::ProcessEventsFlags flags) { + Q_UNUSED(flags); } @@ -100,12 +100,12 @@ bool QEventDispatcherPepper::hasPendingEvents() void QEventDispatcherPepper::registerSocketNotifier(QSocketNotifier *notifier) { - + Q_UNUSED(notifier); } void QEventDispatcherPepper::unregisterSocketNotifier(QSocketNotifier *notifier) { - + Q_UNUSED(notifier); } void QEventDispatcherPepper::startingUp() @@ -134,4 +134,160 @@ void QEventDispatcherPepper::flush() qApp->sendPostedEvents(); } +void QEventDispatcherPepper::processPepperEvent(NPPepperEvent *event) +{ + switch (event->type) { + case NPEventType_MouseDown: + case NPEventType_MouseUp: + case NPEventType_MouseMove: + processMouseEvent(&event->u.mouse, event->type); + break; + case NPEventType_KeyDown: + case NPEventType_KeyUp: + processKeyEvent(&event->u.key, event->type); + break; + case NPEventType_Char: + processCharacterEvent(&event->u.character); + break; + case NPEventType_Minimize: + processMinimizeEvent(&event->u.minimize); + break; + case NPEventType_Focus: + processFocusEvent(&event->u.focus); + break; + case NPEventType_Device: + processDeviceEvent(&event->u.device); + break; + case NPEventType_MouseEnter: + case NPEventType_MouseLeave: + case NPEventType_MouseWheel: + default: + break; + } +} + +void QEventDispatcherPepper::processKeyEvent(NPKeyEvent *key, uint32 eventType) +{ +/* + uint32 modifier; + uint32 normalizedKeyCode; +*/ + if (eventType == NPEventType_KeyDown) { + //fprintf(stderr, "unicode %d", event.key.keysym.unicode); + QKeyEvent keyEvent(QEvent::KeyPress, key->normalizedKeyCode, Qt::NoModifier, + QString()); + QApplicationPrivate::handleKeyEvent(0, &keyEvent); + + } + + if (eventType == NPEventType_KeyUp) { + QKeyEvent keyEvent(QEvent::KeyRelease, key->normalizedKeyCode, Qt::NoModifier, + QString()); + QApplicationPrivate::handleKeyEvent(0, &keyEvent); + } +} + +void QEventDispatcherPepper::processCharacterEvent(NPCharacterEvent *character) +{ +/* + uint32 modifier; + uint16 text[4]; + uint16 unmodifiedText[4]; +*/ + QKeyEvent keyEvent(QEvent::KeyPress, 0, Qt::NoModifier, + QString(reinterpret_cast<QChar *>(character->text), 4)); + QApplicationPrivate::handleKeyEvent(0, &keyEvent); +} + +Qt::MouseButton pepperMouseButtonToQt(int32 pepperButton) +{ + Qt::MouseButton button; + if (pepperButton == NPMouseButton_Left) + button = Qt::LeftButton; + if (pepperButton == NPMouseButton_Middle) + button = Qt::MidButton; + if (pepperButton == NPMouseButton_Right) + button = Qt::RightButton; + return button; +} + +void QEventDispatcherPepper::processMouseEvent(NPMouseEvent *mouse, uint32 eventType) +{ +/* + NPMouseEvent: + uint32 modifier; + int32 button; + int32 x; + int32 y; + int32 clickCount; +*/ + QPoint p(mouse->x, mouse->y); + Qt::MouseButton button = pepperMouseButtonToQt(mouse->button); + + if (eventType == NPEventType_MouseDown) { + //fprintf(stderr, "mouse coords %d %d \n", event.button.x, event.button.y); + + QMouseEvent mouseEvent(QEvent::MouseButtonPress, p, p, button, + button, Qt::NoModifier); + QApplicationPrivate::handleMouseEvent(0, mouseEvent); + } + + else if (eventType == NPEventType_MouseUp) { + QMouseEvent mouseEvent(QEvent::MouseButtonRelease, p, p, button, + Qt::NoButton, Qt::NoModifier); + QApplicationPrivate::handleMouseEvent(0, mouseEvent); + } + + else if (eventType == NPEventType_MouseMove) { + //fprintf(stderr, " mouse motion %d %d", event.motion.x, event.motion.y); + QMouseEvent mouseEvent(QEvent::MouseMove, p, p, + Qt::NoButton, + Qt::NoButton, + Qt::NoModifier); + QApplicationPrivate::handleMouseEvent(0, mouseEvent); + } +} + +void QEventDispatcherPepper::processMouseWheelEvent(NPMouseWheelEvent *wheel) +{ +/* + uint32 modifier; + float deltaX; + float deltaY; + float wheelTicksX; + float wheelTicksY; + uint32 scrollByPage; +*/ + QWheelEvent wheelEvent(QPoint(), QPoint(wheel->deltaX, wheel->deltaY), + Qt::NoButton, Qt::NoButton, Qt::NoModifier); + + QApplicationPrivate::handleWheelEvent(0, wheelEvent); +} + +void QEventDispatcherPepper::processMinimizeEvent(NPMinimizeEvent *minimize) +{ + Q_UNUSED(minimize) +/* + int32 value; +*/ +} + +void QEventDispatcherPepper::processFocusEvent(NPFocusEvent *focus) +{ + Q_UNUSED(focus) +/* + int32 value; +*/ +} + +void QEventDispatcherPepper::processDeviceEvent(NPDeviceEvent *device) +{ + Q_UNUSED(device) +/* + uint32 device_uid; + uint32 subtype; +*/ +} + + QT_END_NAMESPACE diff --git a/src/gui/kernel/qeventdispatcher_pepper_p.h b/src/gui/kernel/qeventdispatcher_pepper_p.h index 2a724e821b..34253cc070 100644 --- a/src/gui/kernel/qeventdispatcher_pepper_p.h +++ b/src/gui/kernel/qeventdispatcher_pepper_p.h @@ -42,6 +42,9 @@ #ifndef QEVENTDISPATCHER_PEPPER_P_H #define QEVENTDISPATCHER_PEPPER_P_H +typedef unsigned int size_t; +#include <nacl/npapi_extensions.h> + // // W A R N I N G // ------------- @@ -82,6 +85,15 @@ public: void startingUp(); void closingDown(); +private: + void processPepperEvent(NPPepperEvent *event); + void processKeyEvent(NPKeyEvent *key, uint32 eventType); + void processCharacterEvent(NPCharacterEvent *character); + void processMouseEvent(NPMouseEvent *mouse, uint32 eventType); + void processMouseWheelEvent(NPMouseWheelEvent *wheel); + void processMinimizeEvent(NPMinimizeEvent *minimize); + void processFocusEvent(NPFocusEvent *focus); + void processDeviceEvent(NPDeviceEvent *device); }; QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystem_pepper.cpp b/src/gui/painting/qgraphicssystem_pepper.cpp new file mode 100644 index 0000000000..f18385ca0b --- /dev/null +++ b/src/gui/painting/qgraphicssystem_pepper.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgraphicssystem_nacl.h" +#include "qwindowsurface_nacl.h" +#include <QtGui/private/qpixmap_raster_p.h> + +#include <nacl/nacl_av.h> +#include <stdio.h> + +QT_BEGIN_NAMESPACE + +QPepperGraphicsSystem::QPepperGraphicsSystem() +{ + perror("QPepperGraphicsSystem::QPepperGraphicsSystem()"); + mPrimaryScreen = new QPepperGraphicsSystemScreen(); + + mPrimaryScreen->mGeometry = QRect(0, 0, 640, 480); + mPrimaryScreen->mPhysicalSize = QSize(640 / 4, 480 / 4); + mScreens.append(mPrimaryScreen); + + + // Setup pepper system/screen size here? +} + +QPepperGraphicsSystemScreen::~QPepperGraphicsSystemScreen() +{ + +} + +QPixmapData *QPepperGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} + +QWindowSurface *QPepperGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + return new QPepperWindowSurface(mPrimaryScreen, widget); +} + +QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystem_pepper.h b/src/gui/painting/qgraphicssystem_pepper.h new file mode 100644 index 0000000000..c93018f283 --- /dev/null +++ b/src/gui/painting/qgraphicssystem_pepper.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEM_NACL_H +#define QGRAPHICSSYSTEM_NACL_H + +#include <QtGui/private/qgraphicssystem_p.h> + +QT_BEGIN_NAMESPACE + +class QPepperGraphicsSystemScreen : public QGraphicsSystemScreen +{ +public: + QPepperGraphicsSystemScreen() + : mDepth(32), mFormat(QImage::Format_ARGB32_Premultiplied) {} + ~QPepperGraphicsSystemScreen(); + + QRect geometry() const { return mGeometry; } + int depth() const { return mDepth; } + QImage::Format format() const { return mFormat; } + QSize physicalSize() const { return mPhysicalSize; } + +public: + QRect mGeometry; + int mDepth; + QImage::Format mFormat; + QSize mPhysicalSize; +}; + +class QPepperGraphicsSystem : public QGraphicsSystem +{ +public: + QPepperGraphicsSystem(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + + QList<QGraphicsSystemScreen *> screens() const { return mScreens; } + +private: + QPepperGraphicsSystemScreen *mPrimaryScreen; + QList<QGraphicsSystemScreen *> mScreens; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/gui/painting/qwindowsurface_pepper.cpp b/src/gui/painting/qwindowsurface_pepper.cpp new file mode 100644 index 0000000000..877b4d6130 --- /dev/null +++ b/src/gui/painting/qwindowsurface_pepper.cpp @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwindowsurface_Pepper.h" +#include "qgraphicssystem_Pepper.h" +#include <QtCore/qdebug.h> +#include "qpainter.h" +#include <private/qapplication_p.h> +#include <Pepper/Pepper_av.h> + +QT_BEGIN_NAMESPACE + +QPepperWindowSurface::QPepperWindowSurface + (QPepperGraphicsSystemScreen *screen, QWidget *window) + : QWindowSurface(window), + mScreen(screen), + mImage(screen->geometry().size(), QImage::Format_ARGB32_Premultiplied) +{ + qDebug() << "QPepperWindowSurface::QPepperWindowSurface:" << (long)this; + mImage.fill(QColor(140, 140, 140, 255).rgba()); +} + +QPepperWindowSurface::~QPepperWindowSurface() +{ +} + +QPaintDevice *QPepperWindowSurface::paintDevice() +{ + qDebug() << "QPepperWindowSurface::paintDevice"; + return &mImage; +} + +void QPepperWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(region); + Q_UNUSED(offset); + // Flush bounding rect or flush multiple times? + QRect flushRect = region.boundingRect(); + + NPDeviceContext *context; + context->dirty.left = flushRect.left(); + context->dirty.right = flushRect.right(); + context->dirty.top = flushRect.top(); + context->dirty.bottom = flushRect.bottom(); + +} + +void QPepperWindowSurface::setGeometry(const QRect &rect) +{ + //fprintf(stderr, "QPepperWindowSurface::setGeometry %d %d", rect.width(), rect.height()); + qDebug() << "QPepperWindowSurface::setGeometry:" << (long)this << rect; + + + if (mImage.size().isValid()) {// use first set size only. + QApplicationPrivate::handleGeometryChange(this->window(), QRect(QPoint(), mImage.size())); + return; + } + + QWindowSurface::setGeometry(rect); + if (mImage.size() != rect.size()) + mImage = QImage(rect.size(), mScreen->format()); + + +} + +bool QPepperWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + return QWindowSurface::scroll(area, dx, dy); +} + +void QPepperWindowSurface::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +void QPepperWindowSurface::endPaint(const QRegion ®ion) +{ + Q_UNUSED(region); +} + +QT_END_NAMESPACE diff --git a/src/gui/painting/qwindowsurface_pepper.h b/src/gui/painting/qwindowsurface_pepper.h new file mode 100644 index 0000000000..07b6c6e0ed --- /dev/null +++ b/src/gui/painting/qwindowsurface_pepper.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_Pepper_H +#define QWINDOWSURFACE_Pepper_H + +#include <QtGui/private/qwindowsurface_p.h> + +QT_BEGIN_NAMESPACE + +class QPepperGraphicsSystemScreen; + +class QPepperWindowSurface : public QWindowSurface +{ +public: + QPepperWindowSurface + (QPepperGraphicsSystemScreen *screen, QWidget *window); + ~QPepperWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); + + void beginPaint(const QRegion ®ion); + void endPaint(const QRegion ®ion); + +private: + QPepperGraphicsSystemScreen *mScreen; + QImage mImage; +}; + +QT_END_NAMESPACE + +#endif |