From 8d66385993774662fe58fe57dbc32edb64aa4568 Mon Sep 17 00:00:00 2001 From: kdeyev Date: Tue, 26 Mar 2013 22:06:47 +0200 Subject: [PATCH 01/11] last Qt version and VS2010 compilation --- .qmake.conf | 3 + src/plugins/platforms/html/html.json | 3 + src/plugins/platforms/html/html.pro | 3 + src/plugins/platforms/html/main.cpp | 8 +- .../platforms/html/qhtmlbackingstore.cpp | 4 +- .../platforms/html/qhtmlbackingstore.h | 2 +- src/plugins/platforms/html/qhtmlcursor.cpp | 2 +- src/plugins/platforms/html/qhtmlcursor.h | 2 +- .../platforms/html/qhtmlintegration.cpp | 19 +- src/plugins/platforms/html/qhtmlintegration.h | 2 +- src/plugins/platforms/html/qhtmlscreen.cpp | 4 +- src/plugins/platforms/html/qhtmlscreen.h | 2 +- src/plugins/platforms/html/qhtmlwindow.cpp | 4 +- src/plugins/platforms/html/qhtmlwindow.h | 2 +- src/services/html/main.cpp | 2 + src/services/html/qhtmlservice.cpp | 193 +++++++++++++++--- src/services/html/qhtmlservice.h | 42 +++- 17 files changed, 242 insertions(+), 55 deletions(-) create mode 100644 .qmake.conf create mode 100644 src/plugins/platforms/html/html.json diff --git a/.qmake.conf b/.qmake.conf new file mode 100644 index 0000000..8840bd9 --- /dev/null +++ b/.qmake.conf @@ -0,0 +1,3 @@ +load(qt_build_config) + +MODULE_VERSION = 0.0.0 diff --git a/src/plugins/platforms/html/html.json b/src/plugins/platforms/html/html.json new file mode 100644 index 0000000..e282ede --- /dev/null +++ b/src/plugins/platforms/html/html.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "html" ] +} diff --git a/src/plugins/platforms/html/html.pro b/src/plugins/platforms/html/html.pro index 6841bda..9145c14 100644 --- a/src/plugins/platforms/html/html.pro +++ b/src/plugins/platforms/html/html.pro @@ -1,4 +1,7 @@ TARGET = qhtml + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QHtmlIntegrationPlugin load(qt_plugin) QT += serviceframework core-private gui-private platformsupport-private diff --git a/src/plugins/platforms/html/main.cpp b/src/plugins/platforms/html/main.cpp index ceb12b8..26d7d7d 100644 --- a/src/plugins/platforms/html/main.cpp +++ b/src/plugins/platforms/html/main.cpp @@ -23,13 +23,15 @@ #include "qhtmlintegration.h" -#include +#include #include QT_BEGIN_NAMESPACE class QHtmlIntegrationPlugin : public QPlatformIntegrationPlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.1" FILE "html.json") public: QStringList keys() const; QPlatformIntegration *create(const QString&, const QStringList&); @@ -51,6 +53,6 @@ QPlatformIntegration *QHtmlIntegrationPlugin::create(const QString& system, cons return 0; } -Q_EXPORT_PLUGIN2(html, QHtmlIntegrationPlugin) - QT_END_NAMESPACE + +#include "main.moc" diff --git a/src/plugins/platforms/html/qhtmlbackingstore.cpp b/src/plugins/platforms/html/qhtmlbackingstore.cpp index 40dd640..98c90f5 100644 --- a/src/plugins/platforms/html/qhtmlbackingstore.cpp +++ b/src/plugins/platforms/html/qhtmlbackingstore.cpp @@ -24,7 +24,7 @@ #include "qhtmlbackingstore.h" #include -#include +#include #include QT_BEGIN_NAMESPACE @@ -84,7 +84,7 @@ bool QHtmlBackingStore::scroll(const QRegion &area, int dx, int dy) void QHtmlBackingStore::onFlush() { window()->handle()->setGeometry(window()->geometry()); - window()->handle()->setVisible(window()->visible()); + window()->handle()->setVisible(window()->isVisible()); flush(QRect(QPoint(0, 0), window()->geometry().size())); } diff --git a/src/plugins/platforms/html/qhtmlbackingstore.h b/src/plugins/platforms/html/qhtmlbackingstore.h index 6048611..f9ed021 100644 --- a/src/plugins/platforms/html/qhtmlbackingstore.h +++ b/src/plugins/platforms/html/qhtmlbackingstore.h @@ -24,7 +24,7 @@ #ifndef QHTMLBACKINGSTORE_H #define QHTMLBACKINGSTORE_H -#include +#include #include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/html/qhtmlcursor.cpp b/src/plugins/platforms/html/qhtmlcursor.cpp index 0205df9..19edc82 100644 --- a/src/plugins/platforms/html/qhtmlcursor.cpp +++ b/src/plugins/platforms/html/qhtmlcursor.cpp @@ -27,7 +27,7 @@ #include QHtmlCursor::QHtmlCursor(QHtmlScreen *screen, QObject *htmlService) - : QPlatformCursor(screen), + : QPlatformCursor(), mHtmlService(htmlService) { } diff --git a/src/plugins/platforms/html/qhtmlcursor.h b/src/plugins/platforms/html/qhtmlcursor.h index 63120ad..aaee343 100644 --- a/src/plugins/platforms/html/qhtmlcursor.h +++ b/src/plugins/platforms/html/qhtmlcursor.h @@ -24,7 +24,7 @@ #ifndef QHTMLCURSOR_H #define QHTMLCURSOR_h -#include +#include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/html/qhtmlintegration.cpp b/src/plugins/platforms/html/qhtmlintegration.cpp index 3ae25f4..342644f 100644 --- a/src/plugins/platforms/html/qhtmlintegration.cpp +++ b/src/plugins/platforms/html/qhtmlintegration.cpp @@ -30,20 +30,31 @@ #include #include #include -#include #include +#ifndef Q_OS_WIN +#include +#else +#include +#endif + #include QT_BEGIN_NAMESPACE static const char *interfaceName = "com.nokia.qt.qpa.HtmlService"; -QHtmlIntegration::QHtmlIntegration() - : mEventDispatcher(createUnixEventDispatcher()) +QHtmlIntegration::QHtmlIntegration() : +#ifdef Q_OS_WIN + mEventDispatcher(new QEventDispatcherWin32()) +#else + mEventDispatcher(createUnixEventDispatcher()) +#endif { QGuiApplicationPrivate::instance()->setEventDispatcher(mEventDispatcher); - mHtmlService.reset(QServiceManager().loadInterface(QStringLiteral(interfaceName))); + mHtmlService.reset(QServiceManager().loadInterface(QString::fromLatin1(interfaceName))); + if (mHtmlService.data() == NULL) + exit(0); mScreen.reset(new QHtmlScreen(mHtmlService.data())); screenAdded(mScreen.data()); diff --git a/src/plugins/platforms/html/qhtmlintegration.h b/src/plugins/platforms/html/qhtmlintegration.h index 87aa821..0a1daa1 100644 --- a/src/plugins/platforms/html/qhtmlintegration.h +++ b/src/plugins/platforms/html/qhtmlintegration.h @@ -24,7 +24,7 @@ #ifndef QHTMLINTEGRATION_H #define QHTMLINTEGRATION_H -#include +#include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/html/qhtmlscreen.cpp b/src/plugins/platforms/html/qhtmlscreen.cpp index b513c89..28b76b3 100644 --- a/src/plugins/platforms/html/qhtmlscreen.cpp +++ b/src/plugins/platforms/html/qhtmlscreen.cpp @@ -25,7 +25,7 @@ #include "qhtmlcursor.h" #include -#include +#include QT_BEGIN_NAMESPACE @@ -66,7 +66,7 @@ QImage::Format QHtmlScreen::format() const void QHtmlScreen::setGeometry(int x, int y, int width, int height) { mGeometry = QRect(x, y, width, height); - QWindowSystemInterface::handleScreenGeometryChange(screen()); + QWindowSystemInterface::handleScreenGeometryChange(screen(), mGeometry); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/html/qhtmlscreen.h b/src/plugins/platforms/html/qhtmlscreen.h index 74bf5d2..0a1b9b8 100644 --- a/src/plugins/platforms/html/qhtmlscreen.h +++ b/src/plugins/platforms/html/qhtmlscreen.h @@ -24,7 +24,7 @@ #ifndef QHTMLSCREEN_H #define QHTMLSCREEN_H -#include +#include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/html/qhtmlwindow.cpp b/src/plugins/platforms/html/qhtmlwindow.cpp index 2583e4c..dda49c2 100644 --- a/src/plugins/platforms/html/qhtmlwindow.cpp +++ b/src/plugins/platforms/html/qhtmlwindow.cpp @@ -24,7 +24,7 @@ #include "qhtmlwindow.h" #include -#include +#include QT_BEGIN_NAMESPACE @@ -34,7 +34,7 @@ QHtmlWindow::QHtmlWindow(QWindow *window, QObject *htmlService) { QMetaObject::invokeMethod(mHtmlService, "allocateWinId", Q_RETURN_ARG(int, mWinId), - Q_ARG(int, static_cast(window->windowType()))); + Q_ARG(int, static_cast(window->type()))); connect(mHtmlService, SIGNAL(destroy(int)), SLOT(onDestroy(int))); diff --git a/src/plugins/platforms/html/qhtmlwindow.h b/src/plugins/platforms/html/qhtmlwindow.h index 8a0d498..b1c485c 100644 --- a/src/plugins/platforms/html/qhtmlwindow.h +++ b/src/plugins/platforms/html/qhtmlwindow.h @@ -24,7 +24,7 @@ #ifndef QHTMLWINDOW_H #define QHTMLWINDOW_H -#include +#include QT_BEGIN_NAMESPACE diff --git a/src/services/html/main.cpp b/src/services/html/main.cpp index 3300e43..ce423b1 100644 --- a/src/services/html/main.cpp +++ b/src/services/html/main.cpp @@ -47,6 +47,8 @@ int main(int argc, char** argv) // this will start the server and keep it running QObject *htmlService = QServiceManager().loadInterface(QString::fromLatin1(interfaceName)); + if (htmlService == NULL) + exit(0); const int returnCode = app.exec(); delete htmlService; diff --git a/src/services/html/qhtmlservice.cpp b/src/services/html/qhtmlservice.cpp index b0a832b..acb1e0b 100644 --- a/src/services/html/qhtmlservice.cpp +++ b/src/services/html/qhtmlservice.cpp @@ -52,7 +52,7 @@ int QHtmlService::getScreenHeight() const void QHtmlService::changeCursor(int shape) const { - sendMessage(MessageCommand::ChangeCursor, shape); + sendMessage(QString(QChar::fromLatin1(static_cast(MessageCommand::ChangeCursor))), shape); } int QHtmlService::allocateWinId(int windowType) @@ -66,45 +66,45 @@ int QHtmlService::allocateWinId(int windowType) mWinIds.insert(newWinId); const int popup = windowType == Qt::Popup ? 1 : 0; - sendMessage(MessageCommand::CreateWindow, newWinId, popup); + sendMessage(QString(QChar::fromLatin1(static_cast(MessageCommand::CreateWindow))), newWinId, popup); return newWinId; } void QHtmlService::deallocateWinId(int winId) { - sendMessage(MessageCommand::DestroyWindow, winId); + sendMessage(QString(QChar::fromLatin1(static_cast(MessageCommand::DestroyWindow))), winId); mWinIds.remove(winId); } void QHtmlService::setGeometry(int winId, int x, int y, int width, int height) const { - sendMessage(MessageCommand::SetGeometry, winId, x, y, width, height); + sendMessage(QString(QChar::fromLatin1(static_cast(MessageCommand::SetGeometry))), winId, x, y, width, height); } void QHtmlService::setVisible(int winId, bool visible) const { - sendMessage(MessageCommand::SetVisible, winId, visible); + sendMessage(QString(QChar::fromLatin1(static_cast(MessageCommand::SetVisible))), winId, visible); } void QHtmlService::setWindowTitle(int winId, const QString &title) const { - sendMessage(MessageCommand::SetWindowTitle, winId, QString::fromLatin1(title.toUtf8().toBase64().constData())); + sendMessage(QString(QChar::fromLatin1(static_cast(MessageCommand::SetWindowTitle))), winId, QString::fromLatin1(title.toUtf8().toBase64().constData())); } void QHtmlService::raise(int winId) const { - sendMessage(MessageCommand::Raise, winId); + sendMessage(QString(QChar::fromLatin1(static_cast(MessageCommand::Raise))), winId); } void QHtmlService::flush(int winId, int x, int y, int width, int height, const QByteArray &imageData) const { const QString url = QStringLiteral("data:image/png;base64,") + QString::fromLatin1(imageData.toBase64().constData()); - sendMessage(MessageCommand::Flush, winId, x, y, width, height, url); + sendMessage(QString(QChar::fromLatin1(static_cast(MessageCommand::Flush))), winId, x, y, width, height, url); } void QHtmlService::scroll(int winId, int x, int y, int width, int height, int dx, int dy) const { - sendMessage(MessageCommand::Scroll, winId, x, y, width, height, dx, dy); + sendMessage(QString(QChar::fromLatin1(static_cast(MessageCommand::Scroll))), winId, x, y, width, height, dx, dy); } void QHtmlService::onServerNewConnection() @@ -351,33 +351,176 @@ void QHtmlService::sendWebSocketHandshake(QTcpSocket *socket) // initialize commands foreach (int winId, mWinIds) - sendMessage(socket, MessageCommand::CreateWindow, winId); + sendMessage(socket, QString(QChar::fromLatin1(static_cast(MessageCommand::CreateWindow))), winId); emit flush(); } -template -void QHtmlService::sendMessage(QTcpSocket *socket, MessageCommand command, Args... args) const +//template +//void QHtmlService::sendMessage(QTcpSocket *socket, MessageCommand command, Args... args) const +//{ +// sendMessage(socket, QString(QChar::fromLatin1(static_cast(command))), args...); +//} + +//template +//void QHtmlService::sendMessage(MessageCommand command, Args... args) const +//{ +// sendMessage(QString(QChar::fromLatin1(static_cast(command))), args...); +//} + +//template +//void QHtmlService::sendMessage(QTcpSocket *socket, const QString &message, T arg0, Args... args) const +//{ +// sendMessage(socket, message + QString::fromLatin1(" %1").arg(arg0), args...); +//} + +//template +//void QHtmlService::sendMessage(const QString &message, T arg0, Args... args) const +//{ +// sendMessage(message + QString::fromLatin1(" %1").arg(arg0), args...); +//} + + + +template +void QHtmlService::sendMessage(const QString &message, T1 t1) const { - sendMessage(socket, QString(QChar::fromLatin1(static_cast(command))), args...); + sendMessage(message + QString::fromLatin1(" %1").arg(t1)); } - -template -void QHtmlService::sendMessage(MessageCommand command, Args... args) const +template +void QHtmlService::sendMessage(const QString &message, T1 t1, T2 t2) const { - sendMessage(QString(QChar::fromLatin1(static_cast(command))), args...); + sendMessage(message + + QString::fromLatin1(" %1").arg(t1) + + QString::fromLatin1(" %1").arg(t2) + ); } - -template -void QHtmlService::sendMessage(QTcpSocket *socket, const QString &message, T arg0, Args... args) const +template +void QHtmlService::sendMessage(const QString &message, T1 t1, T2 t2, T3 t3) const +{ + sendMessage(message + + QString::fromLatin1(" %1").arg(t1) + + QString::fromLatin1(" %1").arg(t2) + + QString::fromLatin1(" %1").arg(t3) + ); +} +template +void QHtmlService::sendMessage(const QString &message, T1 t1, T2 t2, T3 t3, T4 t4) const +{ + sendMessage(message + + QString::fromLatin1(" %1").arg(t1) + + QString::fromLatin1(" %1").arg(t2) + + QString::fromLatin1(" %1").arg(t3) + + QString::fromLatin1(" %1").arg(t4) + ); +} +template +void QHtmlService::sendMessage(const QString &message, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) const +{ + sendMessage(message + + QString::fromLatin1(" %1").arg(t1) + + QString::fromLatin1(" %1").arg(t2) + + QString::fromLatin1(" %1").arg(t3) + + QString::fromLatin1(" %1").arg(t4) + + QString::fromLatin1(" %1").arg(t5) + ); +} +template +void QHtmlService::sendMessage(const QString &message, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) const +{ + sendMessage(message + + QString::fromLatin1(" %1").arg(t1) + + QString::fromLatin1(" %1").arg(t2) + + QString::fromLatin1(" %1").arg(t3) + + QString::fromLatin1(" %1").arg(t4) + + QString::fromLatin1(" %1").arg(t5) + + QString::fromLatin1(" %1").arg(t6) + ); +} +template +void QHtmlService::sendMessage(const QString &message, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) const { - sendMessage(socket, message + QString::fromLatin1(" %1").arg(arg0), args...); + sendMessage(message + + QString::fromLatin1(" %1").arg(t1) + + QString::fromLatin1(" %1").arg(t2) + + QString::fromLatin1(" %1").arg(t3) + + QString::fromLatin1(" %1").arg(t4) + + QString::fromLatin1(" %1").arg(t5) + + QString::fromLatin1(" %1").arg(t6) + + QString::fromLatin1(" %1").arg(t7) + ); } -template -void QHtmlService::sendMessage(const QString &message, T arg0, Args... args) const +template +void QHtmlService::sendMessage(QTcpSocket *socket, const QString &message, T1 t1) const { - sendMessage(message + QString::fromLatin1(" %1").arg(arg0), args...); + sendMessage(socket, message + QString::fromLatin1(" %1").arg(t1)); } +template +void QHtmlService::sendMessage(QTcpSocket *socket, const QString &message, T1 t1, T2 t2) const +{ + sendMessage(socket, message + + QString::fromLatin1(" %1").arg(t1) + + QString::fromLatin1(" %1").arg(t2) + ); +} +template +void QHtmlService::sendMessage(QTcpSocket *socket, const QString &message, T1 t1, T2 t2, T3 t3) const +{ + sendMessage(socket, message + + QString::fromLatin1(" %1").arg(t1) + + QString::fromLatin1(" %1").arg(t2) + + QString::fromLatin1(" %1").arg(t3) + ); +} +template +void QHtmlService::sendMessage(QTcpSocket *socket, const QString &message, T1 t1, T2 t2, T3 t3, T4 t4) const +{ + sendMessage(socket, message + + QString::fromLatin1(" %1").arg(t1) + + QString::fromLatin1(" %1").arg(t2) + + QString::fromLatin1(" %1").arg(t3) + + QString::fromLatin1(" %1").arg(t4) + ); +} +template +void QHtmlService::sendMessage(QTcpSocket *socket, const QString &message, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) const +{ + sendMessage(socket, message + + QString::fromLatin1(" %1").arg(t1) + + QString::fromLatin1(" %1").arg(t2) + + QString::fromLatin1(" %1").arg(t3) + + QString::fromLatin1(" %1").arg(t4) + + QString::fromLatin1(" %1").arg(t5) + ); +} +template +void QHtmlService::sendMessage(QTcpSocket *socket, const QString &message, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) const +{ + sendMessage(socket, message + + QString::fromLatin1(" %1").arg(t1) + + QString::fromLatin1(" %1").arg(t2) + + QString::fromLatin1(" %1").arg(t3) + + QString::fromLatin1(" %1").arg(t4) + + QString::fromLatin1(" %1").arg(t5) + + QString::fromLatin1(" %1").arg(t6) + ); +} +template +void QHtmlService::sendMessage(QTcpSocket *socket, const QString &message, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) const +{ + sendMessage(socket, message + + QString::fromLatin1(" %1").arg(t1) + + QString::fromLatin1(" %1").arg(t2) + + QString::fromLatin1(" %1").arg(t3) + + QString::fromLatin1(" %1").arg(t4) + + QString::fromLatin1(" %1").arg(t5) + + QString::fromLatin1(" %1").arg(t6) + + QString::fromLatin1(" %1").arg(t7) + ); +} + + + void QHtmlService::sendMessage(QTcpSocket *socket, const QString &message) const { @@ -388,7 +531,7 @@ void QHtmlService::sendMessage(QTcpSocket *socket, const QString &message) const void QHtmlService::sendMessage(const QString &message) const { const QByteArray payload = message.toLatin1(); - for (auto iter = mWebSocketFrameBuffers.constBegin(); iter != mWebSocketFrameBuffers.constEnd(); ++iter) + for ( QHash::ConstIterator iter = mWebSocketFrameBuffers.constBegin(); iter != mWebSocketFrameBuffers.constEnd(); ++iter) iter.key()->write(webSocketFrame(WS_TEXT, payload)); } diff --git a/src/services/html/qhtmlservice.h b/src/services/html/qhtmlservice.h index 8e89b52..58aa8ee 100644 --- a/src/services/html/qhtmlservice.h +++ b/src/services/html/qhtmlservice.h @@ -84,7 +84,7 @@ private slots: WS_PONG = 10 }; - enum class MessageCommand : char { + enum MessageCommand { SetScreenGeometry = 's', // width, height ChangeCursor = 'c', // shape CreateWindow = 'w', // winId @@ -115,18 +115,38 @@ private slots: void sendWebSocketHandshake(QTcpSocket *socket); // Qt HTTP Platform WebSocket Protocols - template - void sendMessage(QTcpSocket *socket, MessageCommand command, Args... args) const; - template - void sendMessage(MessageCommand command, Args... args) const; - - template - void sendMessage(QTcpSocket *socket, const QString &message, T arg0, Args... args) const; - template - void sendMessage(const QString &message, T arg0, Args... args) const; - + // yes. its stupid, but it works on VS2010 )) void sendMessage(const QString &message) const; + template + void sendMessage(const QString &message, T1 t1) const; + template + void sendMessage(const QString &message, T1 t1, T2 t2) const; + template + void sendMessage(const QString &message, T1 t1, T2 t2, T3 t3) const; + template + void sendMessage(const QString &message, T1 t1, T2 t2, T3 t3, T4 t4) const; + template + void sendMessage(const QString &message, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) const; + template + void sendMessage(const QString &message, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) const; + template + void sendMessage(const QString &message, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) const; + void sendMessage(QTcpSocket *socket, const QString &message) const; + template + void sendMessage(QTcpSocket *socket,const QString &message, T1 t1) const; + template + void sendMessage(QTcpSocket *socket,const QString &message, T1 t1, T2 t2) const; + template + void sendMessage(QTcpSocket *socket,const QString &message, T1 t1, T2 t2, T3 t3) const; + template + void sendMessage(QTcpSocket *socket,const QString &message, T1 t1, T2 t2, T3 t3, T4 t4) const; + template + void sendMessage(QTcpSocket *socket,const QString &message, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) const; + template + void sendMessage(QTcpSocket *socket,const QString &message, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) const; + template + void sendMessage(QTcpSocket *socket,const QString &message, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) const; void processMessage(const QString &message) const; From 902f936e9dbac62c27e009b14a6635e4e90636d8 Mon Sep 17 00:00:00 2001 From: kdeyev Date: Tue, 26 Mar 2013 22:25:52 +0200 Subject: [PATCH 02/11] debug prints --- .../platforms/html/qhtmlbackingstore.cpp | 41 +++++++++++++++++++ .../platforms/html/qhtmlbackingstore.h | 1 + .../platforms/html/qhtmlintegration.cpp | 6 +++ src/plugins/platforms/html/qhtmlintegration.h | 2 + src/plugins/platforms/html/qhtmlscreen.cpp | 7 ++++ src/plugins/platforms/html/qhtmlscreen.h | 1 + src/plugins/platforms/html/qhtmlwindow.cpp | 30 ++++++++++++++ src/plugins/platforms/html/qhtmlwindow.h | 1 + 8 files changed, 89 insertions(+) diff --git a/src/plugins/platforms/html/qhtmlbackingstore.cpp b/src/plugins/platforms/html/qhtmlbackingstore.cpp index 98c90f5..bee17e7 100644 --- a/src/plugins/platforms/html/qhtmlbackingstore.cpp +++ b/src/plugins/platforms/html/qhtmlbackingstore.cpp @@ -34,6 +34,9 @@ QHtmlBackingStore::QHtmlBackingStore(QWindow *window, QObject *htmlService) mHtmlService(htmlService) { connect(mHtmlService, SIGNAL(flush()), SLOT(onFlush())); + mDebug = true; + if (mDebug) + qDebug() << "QHtmlBackingStore::QHtmlBackingStore:" << (quintptr)this; } QHtmlBackingStore::~QHtmlBackingStore() @@ -42,11 +45,24 @@ QHtmlBackingStore::~QHtmlBackingStore() QPaintDevice *QHtmlBackingStore::paintDevice() { + if (mDebug) + qDebug() << "QHtmlBackingStore::paintDevice"; + return &mImage; } void QHtmlBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { + if (mDebug) + qDebug() << "QHtmlBackingStore::flush"; + + if (mDebug) { + static int c = 0; + QString filename = QString::fromLatin1("output%1.png").arg(c++, 4, 10, QLatin1Char('0')); + qDebug() << "QHtmlBackingStore::flush() saving contents to" << filename.toLocal8Bit().constData(); + mImage.save(filename); + } + Q_UNUSED(window); Q_UNUSED(offset); foreach (const QRect &rect, (region & mDirtyRegion).rects()) @@ -56,6 +72,9 @@ void QHtmlBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoi void QHtmlBackingStore::resize(const QSize &size, const QRegion &staticContents) { + if (mDebug) + qDebug() << "QHtmlBackingStore::resize"; + Q_UNUSED(staticContents); if (mImage.size() != size) mImage = QImage(size, QImage::Format_ARGB32_Premultiplied); @@ -66,6 +85,9 @@ extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &o bool QHtmlBackingStore::scroll(const QRegion &area, int dx, int dy) { + if (mDebug) + qDebug() << "QHtmlBackingStore::scroll"; + const QPoint offset(dx, dy); foreach (const QRect &rect, area.rects()) { QMetaObject::invokeMethod(mHtmlService, "scroll", @@ -83,6 +105,9 @@ bool QHtmlBackingStore::scroll(const QRegion &area, int dx, int dy) void QHtmlBackingStore::onFlush() { + if (mDebug) + qDebug() << "QHtmlBackingStore::onFlush"; + window()->handle()->setGeometry(window()->geometry()); window()->handle()->setVisible(window()->isVisible()); flush(QRect(QPoint(0, 0), window()->geometry().size())); @@ -90,11 +115,21 @@ void QHtmlBackingStore::onFlush() void QHtmlBackingStore::flush(const QRect &rect) { + if (mDebug) + qDebug() << "QHtmlBackingStore::flush(rect)"; + const QImage &subImage = mImage.copy(rect); QBuffer imageDataBuffer; subImage.save(&imageDataBuffer, "png"); imageDataBuffer.close(); + if (mDebug) { + static int c = 0; + QString filename = QString::fromLatin1("outputrect%1.png").arg(c++, 4, 10, QLatin1Char('0')); + qDebug() << "QHtmlBackingStore::flush() saving contents to" << filename.toLocal8Bit().constData(); + mImage.save(filename); + } + QMetaObject::invokeMethod(mHtmlService, "flush", Q_ARG(int, static_cast(window()->winId())), Q_ARG(int, rect.x()), @@ -106,12 +141,18 @@ void QHtmlBackingStore::flush(const QRect &rect) void QHtmlBackingStore::beginPaint(const QRegion ®ion) { + if (mDebug) + qDebug() << "QHtmlBackingStore::beginPaint"; + mDirtyRegion += region; QPlatformBackingStore::beginPaint(region); } void QHtmlBackingStore::endPaint() { + if (mDebug) + qDebug() << "QHtmlBackingStore::endPaint"; + QPlatformBackingStore::endPaint(); } diff --git a/src/plugins/platforms/html/qhtmlbackingstore.h b/src/plugins/platforms/html/qhtmlbackingstore.h index f9ed021..b499a67 100644 --- a/src/plugins/platforms/html/qhtmlbackingstore.h +++ b/src/plugins/platforms/html/qhtmlbackingstore.h @@ -55,6 +55,7 @@ public slots: QImage mImage; QRegion mDirtyRegion; + bool mDebug; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/html/qhtmlintegration.cpp b/src/plugins/platforms/html/qhtmlintegration.cpp index 342644f..dc7eb05 100644 --- a/src/plugins/platforms/html/qhtmlintegration.cpp +++ b/src/plugins/platforms/html/qhtmlintegration.cpp @@ -50,6 +50,7 @@ QHtmlIntegration::QHtmlIntegration() : mEventDispatcher(createUnixEventDispatcher()) #endif { + mDebug = true; QGuiApplicationPrivate::instance()->setEventDispatcher(mEventDispatcher); mHtmlService.reset(QServiceManager().loadInterface(QString::fromLatin1(interfaceName))); @@ -64,11 +65,16 @@ QHtmlIntegration::QHtmlIntegration() : QPlatformWindow *QHtmlIntegration::createPlatformWindow(QWindow *window) const { + if (mDebug) + qDebug() << "QHtmlIntegration::createPlatformWindow"; + return new QHtmlWindow(window, mHtmlService.data()); } QPlatformBackingStore *QHtmlIntegration::createPlatformBackingStore(QWindow *window) const { + if (mDebug) + qDebug() << "QHtmlIntegration::createPlatformBackingStore"; return new QHtmlBackingStore(window, mHtmlService.data()); } diff --git a/src/plugins/platforms/html/qhtmlintegration.h b/src/plugins/platforms/html/qhtmlintegration.h index 0a1daa1..403075f 100644 --- a/src/plugins/platforms/html/qhtmlintegration.h +++ b/src/plugins/platforms/html/qhtmlintegration.h @@ -48,6 +48,8 @@ class QHtmlIntegration : public QPlatformIntegration QScopedPointer mScreen; QScopedPointer mFontDatabase; + + bool mDebug; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/html/qhtmlscreen.cpp b/src/plugins/platforms/html/qhtmlscreen.cpp index 28b76b3..a4064da 100644 --- a/src/plugins/platforms/html/qhtmlscreen.cpp +++ b/src/plugins/platforms/html/qhtmlscreen.cpp @@ -32,6 +32,10 @@ QT_BEGIN_NAMESPACE QHtmlScreen::QHtmlScreen(QObject *htmlService) : mHtmlService(htmlService) { + mDebug = true; + if (mDebug) + qDebug() << "QHtmlScreen"; + mCursor.reset(new QHtmlCursor(this, mHtmlService)); connect(mHtmlService, SIGNAL(setScreenGeometry(int, int, int, int)), SLOT(setGeometry(int, int, int, int))); @@ -65,6 +69,9 @@ QImage::Format QHtmlScreen::format() const void QHtmlScreen::setGeometry(int x, int y, int width, int height) { + if (mDebug) + qDebug() << "QHtmlScreen::setGeometry"; + mGeometry = QRect(x, y, width, height); QWindowSystemInterface::handleScreenGeometryChange(screen(), mGeometry); } diff --git a/src/plugins/platforms/html/qhtmlscreen.h b/src/plugins/platforms/html/qhtmlscreen.h index 0a1b9b8..b267a6a 100644 --- a/src/plugins/platforms/html/qhtmlscreen.h +++ b/src/plugins/platforms/html/qhtmlscreen.h @@ -44,6 +44,7 @@ public slots: void setGeometry(int x, int y, int width, int height); private: QObject *mHtmlService; + bool mDebug; QRect mGeometry; QScopedPointer mCursor; diff --git a/src/plugins/platforms/html/qhtmlwindow.cpp b/src/plugins/platforms/html/qhtmlwindow.cpp index dda49c2..8947253 100644 --- a/src/plugins/platforms/html/qhtmlwindow.cpp +++ b/src/plugins/platforms/html/qhtmlwindow.cpp @@ -32,6 +32,7 @@ QHtmlWindow::QHtmlWindow(QWindow *window, QObject *htmlService) : QPlatformWindow(window), mHtmlService(htmlService) { + mDebug = true; QMetaObject::invokeMethod(mHtmlService, "allocateWinId", Q_RETURN_ARG(int, mWinId), Q_ARG(int, static_cast(window->type()))); @@ -67,6 +68,8 @@ QHtmlWindow::~QHtmlWindow() void QHtmlWindow::setGeometry(const QRect &rect) { + if (mDebug) + qDebug() << "QHtmlWindow::setGeometry"; QPlatformWindow::setGeometry(rect); QMetaObject::invokeMethod(mHtmlService, "setGeometry", Q_ARG(int, mWinId), @@ -78,12 +81,16 @@ void QHtmlWindow::setGeometry(const QRect &rect) QMargins QHtmlWindow::frameMargins() const { + if (mDebug) + qDebug() << "QHtmlWindow::frameMargins"; // TODO return QPlatformWindow::frameMargins(); } void QHtmlWindow::setVisible(bool visible) { + if (mDebug) + qDebug() << "QHtmlWindow::setVisible"; QMetaObject::invokeMethod(mHtmlService, "setVisible", Q_ARG(int, mWinId), Q_ARG(bool, visible)); @@ -96,6 +103,9 @@ WId QHtmlWindow::winId() const void QHtmlWindow::setWindowTitle(const QString &title) { + if (mDebug) + qDebug() << "QHtmlWindow::setWindowTitle"; + QMetaObject::invokeMethod(mHtmlService, "setWindowTitle", Q_ARG(int, mWinId), Q_ARG(QString, title)); @@ -103,12 +113,17 @@ void QHtmlWindow::setWindowTitle(const QString &title) void QHtmlWindow::raise() { + if (mDebug) + qDebug() << "QHtmlWindow::raise"; QMetaObject::invokeMethod(mHtmlService, "raise", Q_ARG(int, mWinId)); } void QHtmlWindow::onDestroy(int winId) { + if (mDebug) + qDebug() << "QHtmlWindow::onDestroy"; + if (winId == mWinId) { QWindowSystemInterface::handleCloseEvent(window()); } @@ -116,6 +131,9 @@ void QHtmlWindow::onDestroy(int winId) void QHtmlWindow::onActivated(int winId) { + if (mDebug) + qDebug() << "QHtmlWindow::onActivated"; + if (winId == mWinId) { QWindowSystemInterface::handleWindowActivated(window()); } @@ -123,6 +141,9 @@ void QHtmlWindow::onActivated(int winId) void QHtmlWindow::onSetGeometry(int winId, int x, int y, int width, int height) { + if (mDebug) + qDebug() << "QHtmlWindow::onSetGeometry"; + if (winId == mWinId) { const QRect rect(x, y, width, height); QPlatformWindow::setGeometry(rect); @@ -132,6 +153,9 @@ void QHtmlWindow::onSetGeometry(int winId, int x, int y, int width, int height) void QHtmlWindow::onKeyEvent(int winId, int type, int code, int modifiers, const QString &text) { + if (mDebug) + qDebug() << "QHtmlWindow::onKeyEvent"; + if (winId == mWinId) { QWindowSystemInterface::handleKeyEvent(window(), QEvent::Type(type), code, Qt::KeyboardModifiers(modifiers), text); } @@ -139,6 +163,9 @@ void QHtmlWindow::onKeyEvent(int winId, int type, int code, int modifiers, const void QHtmlWindow::onMouseEvent(int winId, int localX, int localY, int globalX, int globalY, int buttons, int modifiers) { + if (mDebug) + qDebug() << "QHtmlWindow::onMouseEvent"; + if (winId == mWinId) { QWindowSystemInterface::handleMouseEvent(window(), QPoint(localX, localY), QPoint(globalX, globalY), Qt::MouseButtons(buttons), Qt::KeyboardModifiers(modifiers)); @@ -147,6 +174,9 @@ void QHtmlWindow::onMouseEvent(int winId, int localX, int localY, int globalX, i void QHtmlWindow::onMouseWheel(int winId, int localX, int localY, int globalX, int globalY, int delta, int modifiers) { + if (mDebug) + qDebug() << "QHtmlWindow::onMouseWheel"; + if (winId == mWinId) { delta *= 120; QWindowSystemInterface::handleWheelEvent(window(), QPoint(localX, localY), QPoint(globalX, globalY), diff --git a/src/plugins/platforms/html/qhtmlwindow.h b/src/plugins/platforms/html/qhtmlwindow.h index b1c485c..0edeb95 100644 --- a/src/plugins/platforms/html/qhtmlwindow.h +++ b/src/plugins/platforms/html/qhtmlwindow.h @@ -54,6 +54,7 @@ public slots: void onMouseWheel(int winId, int localX, int localY, int globalX, int globalY, int delta, int modifiers); private: QObject *mHtmlService; + bool mDebug; int mWinId; }; From 53b9f42002e90bc521d66d6d59d9deaf3a0fda6d Mon Sep 17 00:00:00 2001 From: kdeyev Date: Tue, 26 Mar 2013 22:39:08 +0200 Subject: [PATCH 03/11] trick for fast debugging --- src/plugins/platforms/html/html_embed.pro | 46 +++++++++++++++++++ .../platforms/html/qhtmlintegration.cpp | 5 +- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/plugins/platforms/html/html_embed.pro diff --git a/src/plugins/platforms/html/html_embed.pro b/src/plugins/platforms/html/html_embed.pro new file mode 100644 index 0000000..9ded585 --- /dev/null +++ b/src/plugins/platforms/html/html_embed.pro @@ -0,0 +1,46 @@ +#TARGET = qhtml +#load(qt_plugin) + +TARGET = qhtml + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QHtmlIntegrationPlugin +load(qt_plugin) + + +QT += serviceframework core-private gui-private platformsupport-private network + +#DEFINES += \ +# QT_NO_CAST_FROM_BYTEARRAY \ +# QT_NO_CAST_FROM_ASCII \ +# QT_NO_CAST_TO_ASCII + +HEADERS = \ + qhtmlintegration.h \ + qhtmlscreen.h \ + qhtmlcursor.h \ + qhtmlwindow.h \ + qhtmlbackingstore.h \ + ../../../services/html/qhtmlservice.h + + +SOURCES = \ + main.cpp \ + qhtmlintegration.cpp \ + qhtmlscreen.cpp \ + qhtmlcursor.cpp \ + qhtmlwindow.cpp \ + qhtmlbackingstore.cpp \ + ../../../services/html/qhtmlservice.cpp + + +DESTDIR = $$QT.gui.plugins/platforms +target.path += $$[QT_INSTALL_PLUGINS]/platforms +INSTALLS += target + +OTHER_FILES += \ + ../../../services/html/client.js \ + ../../../services/html/client.html + +RESOURCES += \ + ../../../services/html/html.qrc diff --git a/src/plugins/platforms/html/qhtmlintegration.cpp b/src/plugins/platforms/html/qhtmlintegration.cpp index dc7eb05..3881081 100644 --- a/src/plugins/platforms/html/qhtmlintegration.cpp +++ b/src/plugins/platforms/html/qhtmlintegration.cpp @@ -39,6 +39,8 @@ #include +#include <../../../services/html/qhtmlservice.h> // trick for fast debugging + QT_BEGIN_NAMESPACE static const char *interfaceName = "com.nokia.qt.qpa.HtmlService"; @@ -53,7 +55,8 @@ QHtmlIntegration::QHtmlIntegration() : mDebug = true; QGuiApplicationPrivate::instance()->setEventDispatcher(mEventDispatcher); - mHtmlService.reset(QServiceManager().loadInterface(QString::fromLatin1(interfaceName))); + //mHtmlService.reset(QServiceManager().loadInterface(QString::fromLatin1(interfaceName))); + mHtmlService.reset( new QHtmlService ); // trick for fast debugging if (mHtmlService.data() == NULL) exit(0); From 05024470beb42f993cdc5619ffa67ec9ecbcc864 Mon Sep 17 00:00:00 2001 From: kdeyev Date: Tue, 26 Mar 2013 23:15:10 +0200 Subject: [PATCH 04/11] small fixes --- src/plugins/platforms/html/qhtmlwindow.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/platforms/html/qhtmlwindow.cpp b/src/plugins/platforms/html/qhtmlwindow.cpp index 8947253..29986f0 100644 --- a/src/plugins/platforms/html/qhtmlwindow.cpp +++ b/src/plugins/platforms/html/qhtmlwindow.cpp @@ -33,6 +33,9 @@ QHtmlWindow::QHtmlWindow(QWindow *window, QObject *htmlService) mHtmlService(htmlService) { mDebug = true; + + QWindowSystemInterface::setSynchronousWindowsSystemEvents(true); // resize - paint bug + QMetaObject::invokeMethod(mHtmlService, "allocateWinId", Q_RETURN_ARG(int, mWinId), Q_ARG(int, static_cast(window->type()))); @@ -94,6 +97,7 @@ void QHtmlWindow::setVisible(bool visible) QMetaObject::invokeMethod(mHtmlService, "setVisible", Q_ARG(int, mWinId), Q_ARG(bool, visible)); + QPlatformWindow::setVisible(visible); } WId QHtmlWindow::winId() const From 8f0981fc9f6ebbcc84be26bc00c2be7b0bf1b0c1 Mon Sep 17 00:00:00 2001 From: kdeyev Date: Wed, 27 Mar 2013 21:48:38 +0200 Subject: [PATCH 05/11] debug prints --- .../platforms/html/qhtmlbackingstore.cpp | 23 +++++------ .../platforms/html/qhtmlbackingstore.h | 1 + src/plugins/platforms/html/qhtmlwindow.cpp | 38 ++++++++++++------- src/plugins/platforms/html/qhtmlwindow.h | 1 + 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/src/plugins/platforms/html/qhtmlbackingstore.cpp b/src/plugins/platforms/html/qhtmlbackingstore.cpp index bee17e7..167f029 100644 --- a/src/plugins/platforms/html/qhtmlbackingstore.cpp +++ b/src/plugins/platforms/html/qhtmlbackingstore.cpp @@ -34,7 +34,8 @@ QHtmlBackingStore::QHtmlBackingStore(QWindow *window, QObject *htmlService) mHtmlService(htmlService) { connect(mHtmlService, SIGNAL(flush()), SLOT(onFlush())); - mDebug = true; + mDebug = false; + mPrintDebugImages = false; if (mDebug) qDebug() << "QHtmlBackingStore::QHtmlBackingStore:" << (quintptr)this; } @@ -46,7 +47,7 @@ QHtmlBackingStore::~QHtmlBackingStore() QPaintDevice *QHtmlBackingStore::paintDevice() { if (mDebug) - qDebug() << "QHtmlBackingStore::paintDevice"; + qDebug() << "QHtmlBackingStore::paintDevice " << static_cast(window()->winId()); return &mImage; } @@ -54,9 +55,9 @@ QPaintDevice *QHtmlBackingStore::paintDevice() void QHtmlBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { if (mDebug) - qDebug() << "QHtmlBackingStore::flush"; + qDebug() << "QHtmlBackingStore::flush " << static_cast(window->winId()); - if (mDebug) { + if (mPrintDebugImages) { static int c = 0; QString filename = QString::fromLatin1("output%1.png").arg(c++, 4, 10, QLatin1Char('0')); qDebug() << "QHtmlBackingStore::flush() saving contents to" << filename.toLocal8Bit().constData(); @@ -73,7 +74,7 @@ void QHtmlBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoi void QHtmlBackingStore::resize(const QSize &size, const QRegion &staticContents) { if (mDebug) - qDebug() << "QHtmlBackingStore::resize"; + qDebug() << "QHtmlBackingStore::resize " << static_cast(window()->winId()); Q_UNUSED(staticContents); if (mImage.size() != size) @@ -86,7 +87,7 @@ extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &o bool QHtmlBackingStore::scroll(const QRegion &area, int dx, int dy) { if (mDebug) - qDebug() << "QHtmlBackingStore::scroll"; + qDebug() << "QHtmlBackingStore::scroll " << static_cast(window()->winId()); const QPoint offset(dx, dy); foreach (const QRect &rect, area.rects()) { @@ -106,7 +107,7 @@ bool QHtmlBackingStore::scroll(const QRegion &area, int dx, int dy) void QHtmlBackingStore::onFlush() { if (mDebug) - qDebug() << "QHtmlBackingStore::onFlush"; + qDebug() << "QHtmlBackingStore::onFlush " << static_cast(window()->winId()); window()->handle()->setGeometry(window()->geometry()); window()->handle()->setVisible(window()->isVisible()); @@ -116,14 +117,14 @@ void QHtmlBackingStore::onFlush() void QHtmlBackingStore::flush(const QRect &rect) { if (mDebug) - qDebug() << "QHtmlBackingStore::flush(rect)"; + qDebug() << "QHtmlBackingStore::flush(rect) " << static_cast(window()->winId()); const QImage &subImage = mImage.copy(rect); QBuffer imageDataBuffer; subImage.save(&imageDataBuffer, "png"); imageDataBuffer.close(); - if (mDebug) { + if (mPrintDebugImages) { static int c = 0; QString filename = QString::fromLatin1("outputrect%1.png").arg(c++, 4, 10, QLatin1Char('0')); qDebug() << "QHtmlBackingStore::flush() saving contents to" << filename.toLocal8Bit().constData(); @@ -142,7 +143,7 @@ void QHtmlBackingStore::flush(const QRect &rect) void QHtmlBackingStore::beginPaint(const QRegion ®ion) { if (mDebug) - qDebug() << "QHtmlBackingStore::beginPaint"; + qDebug() << "QHtmlBackingStore::beginPaint " << static_cast(window()->winId()); mDirtyRegion += region; QPlatformBackingStore::beginPaint(region); @@ -151,7 +152,7 @@ void QHtmlBackingStore::beginPaint(const QRegion ®ion) void QHtmlBackingStore::endPaint() { if (mDebug) - qDebug() << "QHtmlBackingStore::endPaint"; + qDebug() << "QHtmlBackingStore::endPaint " << static_cast(window()->winId()); QPlatformBackingStore::endPaint(); } diff --git a/src/plugins/platforms/html/qhtmlbackingstore.h b/src/plugins/platforms/html/qhtmlbackingstore.h index b499a67..dca9a1b 100644 --- a/src/plugins/platforms/html/qhtmlbackingstore.h +++ b/src/plugins/platforms/html/qhtmlbackingstore.h @@ -56,6 +56,7 @@ public slots: QImage mImage; QRegion mDirtyRegion; bool mDebug; + bool mPrintDebugImages; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/html/qhtmlwindow.cpp b/src/plugins/platforms/html/qhtmlwindow.cpp index 29986f0..91eec28 100644 --- a/src/plugins/platforms/html/qhtmlwindow.cpp +++ b/src/plugins/platforms/html/qhtmlwindow.cpp @@ -33,6 +33,7 @@ QHtmlWindow::QHtmlWindow(QWindow *window, QObject *htmlService) mHtmlService(htmlService) { mDebug = true; + mDebugEvents = false; QWindowSystemInterface::setSynchronousWindowsSystemEvents(true); // resize - paint bug @@ -65,6 +66,9 @@ QHtmlWindow::QHtmlWindow(QWindow *window, QObject *htmlService) QHtmlWindow::~QHtmlWindow() { + if (mDebug) + qDebug() << "QHtmlWindow::~QHtmlWindow " << mWinId; + QMetaObject::invokeMethod(mHtmlService, "deallocateWinId", Q_ARG(int, mWinId)); } @@ -72,7 +76,8 @@ QHtmlWindow::~QHtmlWindow() void QHtmlWindow::setGeometry(const QRect &rect) { if (mDebug) - qDebug() << "QHtmlWindow::setGeometry"; + qDebug() << "QHtmlWindow::setGeometry " << mWinId; + QPlatformWindow::setGeometry(rect); QMetaObject::invokeMethod(mHtmlService, "setGeometry", Q_ARG(int, mWinId), @@ -85,7 +90,8 @@ void QHtmlWindow::setGeometry(const QRect &rect) QMargins QHtmlWindow::frameMargins() const { if (mDebug) - qDebug() << "QHtmlWindow::frameMargins"; + qDebug() << "QHtmlWindow::frameMargins " << mWinId; + // TODO return QPlatformWindow::frameMargins(); } @@ -93,7 +99,8 @@ QMargins QHtmlWindow::frameMargins() const void QHtmlWindow::setVisible(bool visible) { if (mDebug) - qDebug() << "QHtmlWindow::setVisible"; + qDebug() << "QHtmlWindow::setVisible " << mWinId; + QMetaObject::invokeMethod(mHtmlService, "setVisible", Q_ARG(int, mWinId), Q_ARG(bool, visible)); @@ -108,25 +115,28 @@ WId QHtmlWindow::winId() const void QHtmlWindow::setWindowTitle(const QString &title) { if (mDebug) - qDebug() << "QHtmlWindow::setWindowTitle"; + qDebug() << "QHtmlWindow::setWindowTitle " << mWinId; QMetaObject::invokeMethod(mHtmlService, "setWindowTitle", Q_ARG(int, mWinId), Q_ARG(QString, title)); + QPlatformWindow::setWindowTitle(title); } void QHtmlWindow::raise() { if (mDebug) - qDebug() << "QHtmlWindow::raise"; + qDebug() << "QHtmlWindow::raise " << mWinId; + QMetaObject::invokeMethod(mHtmlService, "raise", Q_ARG(int, mWinId)); + QPlatformWindow::raise(); } void QHtmlWindow::onDestroy(int winId) { if (mDebug) - qDebug() << "QHtmlWindow::onDestroy"; + qDebug() << "QHtmlWindow::onDestroy " << mWinId; if (winId == mWinId) { QWindowSystemInterface::handleCloseEvent(window()); @@ -136,7 +146,7 @@ void QHtmlWindow::onDestroy(int winId) void QHtmlWindow::onActivated(int winId) { if (mDebug) - qDebug() << "QHtmlWindow::onActivated"; + qDebug() << "QHtmlWindow::onActivated " << mWinId; if (winId == mWinId) { QWindowSystemInterface::handleWindowActivated(window()); @@ -146,7 +156,7 @@ void QHtmlWindow::onActivated(int winId) void QHtmlWindow::onSetGeometry(int winId, int x, int y, int width, int height) { if (mDebug) - qDebug() << "QHtmlWindow::onSetGeometry"; + qDebug() << "QHtmlWindow::onSetGeometry " << mWinId; if (winId == mWinId) { const QRect rect(x, y, width, height); @@ -157,8 +167,8 @@ void QHtmlWindow::onSetGeometry(int winId, int x, int y, int width, int height) void QHtmlWindow::onKeyEvent(int winId, int type, int code, int modifiers, const QString &text) { - if (mDebug) - qDebug() << "QHtmlWindow::onKeyEvent"; + if (mDebugEvents) + qDebug() << "QHtmlWindow::onKeyEvent " << mWinId; if (winId == mWinId) { QWindowSystemInterface::handleKeyEvent(window(), QEvent::Type(type), code, Qt::KeyboardModifiers(modifiers), text); @@ -167,8 +177,8 @@ void QHtmlWindow::onKeyEvent(int winId, int type, int code, int modifiers, const void QHtmlWindow::onMouseEvent(int winId, int localX, int localY, int globalX, int globalY, int buttons, int modifiers) { - if (mDebug) - qDebug() << "QHtmlWindow::onMouseEvent"; + if (mDebugEvents) + qDebug() << "QHtmlWindow::onMouseEvent " << mWinId; if (winId == mWinId) { QWindowSystemInterface::handleMouseEvent(window(), QPoint(localX, localY), QPoint(globalX, globalY), @@ -178,8 +188,8 @@ void QHtmlWindow::onMouseEvent(int winId, int localX, int localY, int globalX, i void QHtmlWindow::onMouseWheel(int winId, int localX, int localY, int globalX, int globalY, int delta, int modifiers) { - if (mDebug) - qDebug() << "QHtmlWindow::onMouseWheel"; + if (mDebugEvents) + qDebug() << "QHtmlWindow::onMouseWheel " << mWinId; if (winId == mWinId) { delta *= 120; diff --git a/src/plugins/platforms/html/qhtmlwindow.h b/src/plugins/platforms/html/qhtmlwindow.h index 0edeb95..c8dea9b 100644 --- a/src/plugins/platforms/html/qhtmlwindow.h +++ b/src/plugins/platforms/html/qhtmlwindow.h @@ -55,6 +55,7 @@ public slots: private: QObject *mHtmlService; bool mDebug; + bool mDebugEvents; int mWinId; }; From 2544360e3c04ece79bf92f0985bea710f069d823 Mon Sep 17 00:00:00 2001 From: kdeyev Date: Thu, 28 Mar 2013 00:53:52 +0200 Subject: [PATCH 06/11] title/visible fix --- src/plugins/platforms/html/qhtmlwindow.cpp | 21 +++++++ src/plugins/platforms/html/qhtmlwindow.h | 2 + src/services/html/qhtmlservice.cpp | 67 +++++++++++++++++----- src/services/html/qhtmlservice.h | 7 +++ 4 files changed, 83 insertions(+), 14 deletions(-) diff --git a/src/plugins/platforms/html/qhtmlwindow.cpp b/src/plugins/platforms/html/qhtmlwindow.cpp index 91eec28..503a76c 100644 --- a/src/plugins/platforms/html/qhtmlwindow.cpp +++ b/src/plugins/platforms/html/qhtmlwindow.cpp @@ -55,6 +55,8 @@ QHtmlWindow::QHtmlWindow(QWindow *window, QObject *htmlService) connect(mHtmlService, SIGNAL(mouseWheel(int, int, int, int, int, int, int)), SLOT(onMouseWheel(int, int, int, int, int, int, int))); + connect(mHtmlService, SIGNAL(flush()), SLOT(onFlush())); + const QRect rect = window->geometry(); QMetaObject::invokeMethod(mHtmlService, "setGeometry", Q_ARG(int, mWinId), @@ -133,6 +135,25 @@ void QHtmlWindow::raise() QPlatformWindow::raise(); } +void QHtmlWindow::onFlush() +{ + const QRect rect = window()->geometry(); + QMetaObject::invokeMethod(mHtmlService, "setGeometry", + Q_ARG(int, mWinId), + Q_ARG(int, rect.x()), + Q_ARG(int, rect.y()), + Q_ARG(int, rect.width()), + Q_ARG(int, rect.height())); + + QMetaObject::invokeMethod(mHtmlService, "setWindowTitle", + Q_ARG(int, mWinId), + Q_ARG(QString, window()->title())); + + QMetaObject::invokeMethod(mHtmlService, "setVisible", + Q_ARG(int, mWinId), + Q_ARG(bool, window()->isVisible())); +} + void QHtmlWindow::onDestroy(int winId) { if (mDebug) diff --git a/src/plugins/platforms/html/qhtmlwindow.h b/src/plugins/platforms/html/qhtmlwindow.h index c8dea9b..6d7beea 100644 --- a/src/plugins/platforms/html/qhtmlwindow.h +++ b/src/plugins/platforms/html/qhtmlwindow.h @@ -45,6 +45,8 @@ class QHtmlWindow : public QObject, public QPlatformWindow void setWindowTitle(const QString &title); void raise(); +public slots: + void onFlush(); public slots: void onDestroy(int winId); void onActivated(int winId); diff --git a/src/services/html/qhtmlservice.cpp b/src/services/html/qhtmlservice.cpp index acb1e0b..28003ca 100644 --- a/src/services/html/qhtmlservice.cpp +++ b/src/services/html/qhtmlservice.cpp @@ -31,11 +31,13 @@ #include #include #include +#include QT_BEGIN_NAMESPACE QHtmlService::QHtmlService() : mScreenGeometry(0, 0, INT_MAX, INT_MAX) { + mDebug = true; connect(&mServer, SIGNAL(newConnection()), SLOT(onServerNewConnection())); mServer.listen(QHostAddress::Any, 8080); // TODO configurable address and port } @@ -58,12 +60,15 @@ void QHtmlService::changeCursor(int shape) const int QHtmlService::allocateWinId(int windowType) { int newWinId = 1; + { + QMutexLocker lock(&mWinIdsMutex); foreach (int winId, mWinIds) if (newWinId > winId) break; else ++newWinId; mWinIds.insert(newWinId); + } const int popup = windowType == Qt::Popup ? 1 : 0; sendMessage(QString(QChar::fromLatin1(static_cast(MessageCommand::CreateWindow))), newWinId, popup); @@ -73,6 +78,7 @@ int QHtmlService::allocateWinId(int windowType) void QHtmlService::deallocateWinId(int winId) { sendMessage(QString(QChar::fromLatin1(static_cast(MessageCommand::DestroyWindow))), winId); + QMutexLocker lock(&mWinIdsMutex); mWinIds.remove(winId); } @@ -111,6 +117,8 @@ void QHtmlService::onServerNewConnection() { while (mServer.hasPendingConnections()) { QTcpSocket * const socket = mServer.nextPendingConnection(); + //if (mDebug) + // qDebug() << "mServer.nextPendingConnection"; connect(socket, SIGNAL(readyRead()), SLOT(onHttpSocketReadyRead())); connect(socket, SIGNAL(disconnected()), SLOT(onSocketDisconnected())); } @@ -121,6 +129,8 @@ void QHtmlService::onHttpSocketReadyRead() QTcpSocket * const socket = qobject_cast(sender()); Q_ASSERT(socket); + //QMutexLocker lock(&mWebSocketHandshakeHeadersMutex); + // If we are waiting for full websocket handshake header QHash::iterator header = mWebSocketHandshakeHeaders.find(socket); if (header != mWebSocketHandshakeHeaders.end()) { @@ -168,36 +178,43 @@ void QHtmlService::onHttpSocketReadyRead() void QHtmlService::onWebSocketReadyRead() { QTcpSocket * const socket = qobject_cast(sender()); + QByteArray arr; + { + QMutexLocker lock(&mWebSocketFrameBuffersMutex); QHash::Iterator iter = mWebSocketFrameBuffers.find(socket); - iter.value() += socket->readAll(); + if (iter == mWebSocketFrameBuffers.end()) + return; - while (iter.value().size() >= 2) + arr = iter.value(); + arr += socket->readAll(); + } + while (arr.size() >= 2) { - bool fin = static_cast(iter.value().constData()[0]) & 0x80; - WebSocketOpcode opcode = static_cast(static_cast(iter.value().constData()[0]) & 0x0f); - bool mask = static_cast(iter.value().constData()[1]) & 0x80; - quint64 payloadLen = static_cast(iter.value().constData()[1]) & 0x7f; + bool fin = static_cast(arr.constData()[0]) & 0x80; + WebSocketOpcode opcode = static_cast(static_cast(arr.constData()[0]) & 0x0f); + bool mask = static_cast(arr.constData()[1]) & 0x80; + quint64 payloadLen = static_cast(arr.constData()[1]) & 0x7f; int headerLen = 2; if (payloadLen == 127) { - if (iter.value().size() < 10) + if (arr.size() < 10) return; - payloadLen = qFromBigEndian(reinterpret_cast(iter.value().constData() + 2)); + payloadLen = qFromBigEndian(reinterpret_cast(arr.constData() + 2)); headerLen += 8; } else if (payloadLen == 126) { - if (iter.value().size() < 4) + if (arr.size() < 4) return; - payloadLen = qFromBigEndian(reinterpret_cast(iter.value().constData() + 2)); + payloadLen = qFromBigEndian(reinterpret_cast(arr.constData() + 2)); headerLen += 2; } payloadLen += mask ? 4 : 0; - if (static_cast(iter.value().size()) < payloadLen) + if (static_cast(arr.size()) < payloadLen) return; - iter.value().remove(0, headerLen); - QByteArray payload = iter.value().left(payloadLen); - iter.value().remove(0, payloadLen); + arr.remove(0, headerLen); + QByteArray payload = arr.left(payloadLen); + arr.remove(0, payloadLen); if (mask) { for (int i = 4; i < payload.size(); ++i) @@ -222,8 +239,17 @@ void QHtmlService::onWebSocketReadyRead() void QHtmlService::onSocketDisconnected() { QTcpSocket * const socket = qobject_cast(sender()); + if (mDebug) + qDebug() << "QHtmlService::onSocketDisconnected"; + + { + //QMutexLocker lock(&mWebSocketHandshakeHeadersMutex); mWebSocketHandshakeHeaders.remove(socket); + } + { + QMutexLocker lock(&mWebSocketFrameBuffersMutex); mWebSocketFrameBuffers.remove(socket); + } socket->deleteLater(); } @@ -295,6 +321,8 @@ void QHtmlService::sendWebSocketHandshake(QTcpSocket *socket) { static const char *SEC_WEBSOCKET_KEY_MAGIC = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; + // QMutexLocker lock(&mWebSocketHandshakeHeadersMutex); + QString key; foreach (const QString &line, mWebSocketHandshakeHeaders[socket]) { const QString field = line.section(QLatin1Char(':'), 0, 0); @@ -347,11 +375,21 @@ void QHtmlService::sendWebSocketHandshake(QTcpSocket *socket) "\r\n").arg(accept); socket->write(responseHeader.toLatin1()); connect(socket, SIGNAL(readyRead()), SLOT(onWebSocketReadyRead())); + + if (mDebug) + qDebug() << "QHtmlService::sendWebSocketHandshake"; + + { + QMutexLocker lock(&mWebSocketFrameBuffersMutex); mWebSocketFrameBuffers.insert(socket, QByteArray()); + } + { + QMutexLocker lock(&mWinIdsMutex); // initialize commands foreach (int winId, mWinIds) sendMessage(socket, QString(QChar::fromLatin1(static_cast(MessageCommand::CreateWindow))), winId); + } emit flush(); } @@ -531,6 +569,7 @@ void QHtmlService::sendMessage(QTcpSocket *socket, const QString &message) const void QHtmlService::sendMessage(const QString &message) const { const QByteArray payload = message.toLatin1(); + QMutexLocker lock(&mWebSocketFrameBuffersMutex); for ( QHash::ConstIterator iter = mWebSocketFrameBuffers.constBegin(); iter != mWebSocketFrameBuffers.constEnd(); ++iter) iter.key()->write(webSocketFrame(WS_TEXT, payload)); } diff --git a/src/services/html/qhtmlservice.h b/src/services/html/qhtmlservice.h index 58aa8ee..ced2304 100644 --- a/src/services/html/qhtmlservice.h +++ b/src/services/html/qhtmlservice.h @@ -28,6 +28,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -156,6 +157,12 @@ private slots: mutable QRect mScreenGeometry; QSet mWinIds; + + //QMutex mWebSocketHandshakeHeadersMutex; + mutable QMutex mWebSocketFrameBuffersMutex; + QMutex mWinIdsMutex; + + bool mDebug; }; QT_END_NAMESPACE From bbc5e6950bed7837c21c1f59fa8408a9d0104525 Mon Sep 17 00:00:00 2001 From: "oleksandr.chupryna" Date: Wed, 15 Jun 2016 14:43:21 +0300 Subject: [PATCH 07/11] Fixed build errors, ported to qt 5.2.1 --- .gitignore | 1 + README.md | 2 +- src/plugins/html/.gitignore | 1 + src/{services => plugins}/html/client.html | 0 src/{services => plugins}/html/client.js | 0 src/plugins/{platforms => }/html/html.json | 0 src/{services => plugins}/html/html.qrc | 0 .../{platforms => }/html/html_embed.pro | 22 ++++--- src/plugins/{platforms => }/html/main.cpp | 5 +- .../html/qhtmlbackingstore.cpp | 0 .../{platforms => }/html/qhtmlbackingstore.h | 0 .../{platforms => }/html/qhtmlcursor.cpp | 0 .../{platforms => }/html/qhtmlcursor.h | 2 +- .../{platforms => }/html/qhtmlintegration.cpp | 15 +++-- .../{platforms => }/html/qhtmlintegration.h | 6 +- .../{platforms => }/html/qhtmlscreen.cpp | 0 .../{platforms => }/html/qhtmlscreen.h | 0 .../html/qhtmlservice.cpp | 9 ++- src/{services => plugins}/html/qhtmlservice.h | 1 + .../{platforms => }/html/qhtmlwindow.cpp | 0 .../{platforms => }/html/qhtmlwindow.h | 3 +- src/plugins/platforms/html/html.pro | 31 ---------- src/plugins/platforms/platforms.pro | 3 - src/plugins/plugins.pro | 2 +- src/services/html/html.pro | 18 ------ src/services/html/html.xml | 13 ----- src/services/html/main.cpp | 58 ------------------- src/services/services.pro | 3 - src/src.pro | 2 +- 29 files changed, 43 insertions(+), 154 deletions(-) create mode 100644 src/plugins/html/.gitignore rename src/{services => plugins}/html/client.html (100%) rename src/{services => plugins}/html/client.js (100%) rename src/plugins/{platforms => }/html/html.json (100%) rename src/{services => plugins}/html/html.qrc (100%) rename src/plugins/{platforms => }/html/html_embed.pro (58%) rename src/plugins/{platforms => }/html/main.cpp (92%) rename src/plugins/{platforms => }/html/qhtmlbackingstore.cpp (100%) rename src/plugins/{platforms => }/html/qhtmlbackingstore.h (100%) rename src/plugins/{platforms => }/html/qhtmlcursor.cpp (100%) rename src/plugins/{platforms => }/html/qhtmlcursor.h (97%) rename src/plugins/{platforms => }/html/qhtmlintegration.cpp (88%) rename src/plugins/{platforms => }/html/qhtmlintegration.h (88%) rename src/plugins/{platforms => }/html/qhtmlscreen.cpp (100%) rename src/plugins/{platforms => }/html/qhtmlscreen.h (100%) rename src/{services => plugins}/html/qhtmlservice.cpp (99%) rename src/{services => plugins}/html/qhtmlservice.h (99%) rename src/plugins/{platforms => }/html/qhtmlwindow.cpp (100%) rename src/plugins/{platforms => }/html/qhtmlwindow.h (96%) delete mode 100644 src/plugins/platforms/html/html.pro delete mode 100644 src/plugins/platforms/platforms.pro delete mode 100644 src/services/html/html.pro delete mode 100644 src/services/html/html.xml delete mode 100644 src/services/html/main.cpp delete mode 100644 src/services/services.pro diff --git a/.gitignore b/.gitignore index 54d1f91..60c5c45 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ qrc_*.cpp *.cpp.swp *.js.swp src/services/html/htmlservice +*.pro.user diff --git a/README.md b/README.md index 38e89b3..7f80a13 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ This is the Qt HTML backend utilizing the Qt Platform Abstraction (QPA). -Compile against Qt5 (Depend on the Qt Service Framework in qtsystems). +Compile against Qt5 [Video Demo](http://www.youtube.com/watch?v=qDyWjNju1yU) diff --git a/src/plugins/html/.gitignore b/src/plugins/html/.gitignore new file mode 100644 index 0000000..75c107b --- /dev/null +++ b/src/plugins/html/.gitignore @@ -0,0 +1 @@ +*.pro.user diff --git a/src/services/html/client.html b/src/plugins/html/client.html similarity index 100% rename from src/services/html/client.html rename to src/plugins/html/client.html diff --git a/src/services/html/client.js b/src/plugins/html/client.js similarity index 100% rename from src/services/html/client.js rename to src/plugins/html/client.js diff --git a/src/plugins/platforms/html/html.json b/src/plugins/html/html.json similarity index 100% rename from src/plugins/platforms/html/html.json rename to src/plugins/html/html.json diff --git a/src/services/html/html.qrc b/src/plugins/html/html.qrc similarity index 100% rename from src/services/html/html.qrc rename to src/plugins/html/html.qrc diff --git a/src/plugins/platforms/html/html_embed.pro b/src/plugins/html/html_embed.pro similarity index 58% rename from src/plugins/platforms/html/html_embed.pro rename to src/plugins/html/html_embed.pro index 9ded585..c5934f4 100644 --- a/src/plugins/platforms/html/html_embed.pro +++ b/src/plugins/html/html_embed.pro @@ -1,14 +1,12 @@ -#TARGET = qhtml -#load(qt_plugin) - TARGET = qhtml +#DEFINES += QT_FONTS_ARE_RESOURCES PLUGIN_TYPE = platforms PLUGIN_CLASS_NAME = QHtmlIntegrationPlugin load(qt_plugin) -QT += serviceframework core-private gui-private platformsupport-private network +QT += core-private gui-private platformsupport-private network #DEFINES += \ # QT_NO_CAST_FROM_BYTEARRAY \ @@ -21,7 +19,7 @@ HEADERS = \ qhtmlcursor.h \ qhtmlwindow.h \ qhtmlbackingstore.h \ - ../../../services/html/qhtmlservice.h + qhtmlservice.h SOURCES = \ @@ -31,16 +29,16 @@ SOURCES = \ qhtmlcursor.cpp \ qhtmlwindow.cpp \ qhtmlbackingstore.cpp \ - ../../../services/html/qhtmlservice.cpp + qhtmlservice.cpp -DESTDIR = $$QT.gui.plugins/platforms -target.path += $$[QT_INSTALL_PLUGINS]/platforms -INSTALLS += target +#DESTDIR = $$QT.gui.plugins/platforms +#target.path += $$[QT_INSTALL_PLUGINS]/platforms +#INSTALLS += target OTHER_FILES += \ - ../../../services/html/client.js \ - ../../../services/html/client.html + client.js \ + client.html RESOURCES += \ - ../../../services/html/html.qrc + html.qrc diff --git a/src/plugins/platforms/html/main.cpp b/src/plugins/html/main.cpp similarity index 92% rename from src/plugins/platforms/html/main.cpp rename to src/plugins/html/main.cpp index 26d7d7d..5e6e9dd 100644 --- a/src/plugins/platforms/html/main.cpp +++ b/src/plugins/html/main.cpp @@ -23,7 +23,8 @@ #include "qhtmlintegration.h" -#include +//#include +#include #include QT_BEGIN_NAMESPACE @@ -31,7 +32,7 @@ QT_BEGIN_NAMESPACE class QHtmlIntegrationPlugin : public QPlatformIntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.1" FILE "html.json") + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "html.json") public: QStringList keys() const; QPlatformIntegration *create(const QString&, const QStringList&); diff --git a/src/plugins/platforms/html/qhtmlbackingstore.cpp b/src/plugins/html/qhtmlbackingstore.cpp similarity index 100% rename from src/plugins/platforms/html/qhtmlbackingstore.cpp rename to src/plugins/html/qhtmlbackingstore.cpp diff --git a/src/plugins/platforms/html/qhtmlbackingstore.h b/src/plugins/html/qhtmlbackingstore.h similarity index 100% rename from src/plugins/platforms/html/qhtmlbackingstore.h rename to src/plugins/html/qhtmlbackingstore.h diff --git a/src/plugins/platforms/html/qhtmlcursor.cpp b/src/plugins/html/qhtmlcursor.cpp similarity index 100% rename from src/plugins/platforms/html/qhtmlcursor.cpp rename to src/plugins/html/qhtmlcursor.cpp diff --git a/src/plugins/platforms/html/qhtmlcursor.h b/src/plugins/html/qhtmlcursor.h similarity index 97% rename from src/plugins/platforms/html/qhtmlcursor.h rename to src/plugins/html/qhtmlcursor.h index aaee343..640d8be 100644 --- a/src/plugins/platforms/html/qhtmlcursor.h +++ b/src/plugins/html/qhtmlcursor.h @@ -24,7 +24,7 @@ #ifndef QHTMLCURSOR_H #define QHTMLCURSOR_h -#include +#include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/html/qhtmlintegration.cpp b/src/plugins/html/qhtmlintegration.cpp similarity index 88% rename from src/plugins/platforms/html/qhtmlintegration.cpp rename to src/plugins/html/qhtmlintegration.cpp index 3881081..85633f7 100644 --- a/src/plugins/platforms/html/qhtmlintegration.cpp +++ b/src/plugins/html/qhtmlintegration.cpp @@ -37,9 +37,7 @@ #include #endif -#include - -#include <../../../services/html/qhtmlservice.h> // trick for fast debugging +#include "qhtmlservice.h" QT_BEGIN_NAMESPACE @@ -53,10 +51,10 @@ QHtmlIntegration::QHtmlIntegration() : #endif { mDebug = true; - QGuiApplicationPrivate::instance()->setEventDispatcher(mEventDispatcher); + QGuiApplication::instance()->setEventDispatcher(mEventDispatcher); //mHtmlService.reset(QServiceManager().loadInterface(QString::fromLatin1(interfaceName))); - mHtmlService.reset( new QHtmlService ); // trick for fast debugging + mHtmlService.reset( new QHtmlService() ); if (mHtmlService.data() == NULL) exit(0); @@ -81,11 +79,16 @@ QPlatformBackingStore *QHtmlIntegration::createPlatformBackingStore(QWindow *win return new QHtmlBackingStore(window, mHtmlService.data()); } -QAbstractEventDispatcher *QHtmlIntegration::guiThreadEventDispatcher() const +QAbstractEventDispatcher *QHtmlIntegration::createEventDispatcher() const { return mEventDispatcher; } +//QAbstractEventDispatcher *QHtmlIntegration::guiThreadEventDispatcher() const +//{ +// return mEventDispatcher; +//} + QPlatformFontDatabase *QHtmlIntegration::fontDatabase() const { return mFontDatabase.data(); diff --git a/src/plugins/platforms/html/qhtmlintegration.h b/src/plugins/html/qhtmlintegration.h similarity index 88% rename from src/plugins/platforms/html/qhtmlintegration.h rename to src/plugins/html/qhtmlintegration.h index 403075f..e5bb994 100644 --- a/src/plugins/platforms/html/qhtmlintegration.h +++ b/src/plugins/html/qhtmlintegration.h @@ -25,6 +25,7 @@ #define QHTMLINTEGRATION_H #include +//#include QT_BEGIN_NAMESPACE @@ -38,9 +39,12 @@ class QHtmlIntegration : public QPlatformIntegration QPlatformWindow *createPlatformWindow(QWindow *window) const; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; - QAbstractEventDispatcher *guiThreadEventDispatcher() const; +// QAbstractEventDispatcher *guiThreadEventDispatcher() const; QPlatformFontDatabase *fontDatabase() const; + // Event dispatcher: + virtual QAbstractEventDispatcher *createEventDispatcher() const; + private: QAbstractEventDispatcher *mEventDispatcher; diff --git a/src/plugins/platforms/html/qhtmlscreen.cpp b/src/plugins/html/qhtmlscreen.cpp similarity index 100% rename from src/plugins/platforms/html/qhtmlscreen.cpp rename to src/plugins/html/qhtmlscreen.cpp diff --git a/src/plugins/platforms/html/qhtmlscreen.h b/src/plugins/html/qhtmlscreen.h similarity index 100% rename from src/plugins/platforms/html/qhtmlscreen.h rename to src/plugins/html/qhtmlscreen.h diff --git a/src/services/html/qhtmlservice.cpp b/src/plugins/html/qhtmlservice.cpp similarity index 99% rename from src/services/html/qhtmlservice.cpp rename to src/plugins/html/qhtmlservice.cpp index 28003ca..527c884 100644 --- a/src/services/html/qhtmlservice.cpp +++ b/src/plugins/html/qhtmlservice.cpp @@ -42,6 +42,11 @@ QHtmlService::QHtmlService() : mScreenGeometry(0, 0, INT_MAX, INT_MAX) mServer.listen(QHostAddress::Any, 8080); // TODO configurable address and port } +QHtmlService::~QHtmlService() +{ + +} + int QHtmlService::getScreenWidth() const { return mScreenGeometry.width(); @@ -230,7 +235,7 @@ void QHtmlService::onWebSocketReadyRead() processMessage(QString::fromLatin1(payload.constData())); break; default: - qWarning(qPrintable(QString::fromLatin1("Unhandled opcode '%1'").arg(opcode))); + qWarning() << QString::fromLatin1("Unhandled opcode '%1'").arg(opcode); break; } } @@ -622,7 +627,7 @@ void QHtmlService::processMessage(const QString &message) const args[6].toInt(), args[7].toInt()); break; default: - qWarning(qPrintable(QString::fromLatin1("Unhandled Message '%1'").arg(message))); + qWarning() << QString::fromLatin1("Unhandled Message '%1'").arg(message); break; } } diff --git a/src/services/html/qhtmlservice.h b/src/plugins/html/qhtmlservice.h similarity index 99% rename from src/services/html/qhtmlservice.h rename to src/plugins/html/qhtmlservice.h index ced2304..3627423 100644 --- a/src/services/html/qhtmlservice.h +++ b/src/plugins/html/qhtmlservice.h @@ -37,6 +37,7 @@ class QHtmlService : public QObject Q_OBJECT public: QHtmlService(); + ~QHtmlService(); // PlatformScreen Services Q_INVOKABLE int getScreenWidth() const; diff --git a/src/plugins/platforms/html/qhtmlwindow.cpp b/src/plugins/html/qhtmlwindow.cpp similarity index 100% rename from src/plugins/platforms/html/qhtmlwindow.cpp rename to src/plugins/html/qhtmlwindow.cpp diff --git a/src/plugins/platforms/html/qhtmlwindow.h b/src/plugins/html/qhtmlwindow.h similarity index 96% rename from src/plugins/platforms/html/qhtmlwindow.h rename to src/plugins/html/qhtmlwindow.h index 6d7beea..a27f385 100644 --- a/src/plugins/platforms/html/qhtmlwindow.h +++ b/src/plugins/html/qhtmlwindow.h @@ -24,7 +24,8 @@ #ifndef QHTMLWINDOW_H #define QHTMLWINDOW_H -#include +//#include +#include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/html/html.pro b/src/plugins/platforms/html/html.pro deleted file mode 100644 index 9145c14..0000000 --- a/src/plugins/platforms/html/html.pro +++ /dev/null @@ -1,31 +0,0 @@ -TARGET = qhtml - -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QHtmlIntegrationPlugin -load(qt_plugin) - -QT += serviceframework core-private gui-private platformsupport-private - -DEFINES += \ - QT_NO_CAST_FROM_BYTEARRAY \ - QT_NO_CAST_FROM_ASCII \ - QT_NO_CAST_TO_ASCII - -HEADERS = \ - qhtmlintegration.h \ - qhtmlscreen.h \ - qhtmlcursor.h \ - qhtmlwindow.h \ - qhtmlbackingstore.h - -SOURCES = \ - main.cpp \ - qhtmlintegration.cpp \ - qhtmlscreen.cpp \ - qhtmlcursor.cpp \ - qhtmlwindow.cpp \ - qhtmlbackingstore.cpp - -DESTDIR = $$QT.gui.plugins/platforms -target.path += $$[QT_INSTALL_PLUGINS]/platforms -INSTALLS += target diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro deleted file mode 100644 index e30727d..0000000 --- a/src/plugins/platforms/platforms.pro +++ /dev/null @@ -1,3 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += html diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 301d35a..89a1e58 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs -SUBDIRS += platforms +SUBDIRS += html/html_embed.pro diff --git a/src/services/html/html.pro b/src/services/html/html.pro deleted file mode 100644 index 11a0fba..0000000 --- a/src/services/html/html.pro +++ /dev/null @@ -1,18 +0,0 @@ -TARGET = htmlservice - -QT += network serviceframework - -QMAKE_CXXFLAGS += -std=c++0x - -DEFINES += \ - QT_NO_CAST_FROM_BYTEARRAY \ - QT_NO_CAST_FROM_ASCII \ - QT_NO_CAST_TO_ASCII - -HEADERS += \ - qhtmlservice.h -SOURCES += \ - main.cpp \ - qhtmlservice.cpp - -RESOURCES += html.qrc diff --git a/src/services/html/html.xml b/src/services/html/html.xml deleted file mode 100644 index ba012d0..0000000 --- a/src/services/html/html.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - HtmlService - html_service - Html Platform Integration Service - - com.nokia.qt.qpa.HtmlService - 1.0 - Default implementation of HtmlService - - - diff --git a/src/services/html/main.cpp b/src/services/html/main.cpp deleted file mode 100644 index ce423b1..0000000 --- a/src/services/html/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 by Etrnls -** etrnls@gmail.com -** -** This file is part of the Qt HTML service daemon. -** -** Qt HTML service daemon is free software: you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation, either version 3 of the License, -** or (at your option) any later version. -** -** Qt HTML service daemon is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with Qt HTML service daemon. If not, see -** . -** -****************************************************************************/ - -#include -#include -#include - -#include "qhtmlservice.h" - -static const char *serviceName = "HtmlService"; -static const char *interfaceName = "com.nokia.qt.qpa.HtmlService"; -static const char *version = "1.0"; -static const char *ident = "html_service"; - -int main(int argc, char** argv) -{ - QCoreApplication app(argc, argv); - - QRemoteServiceRegister *serviceRegister = new QRemoteServiceRegister(); - QRemoteServiceRegister::Entry entry; - entry = serviceRegister->createEntry(QString::fromLatin1(serviceName), - QString::fromLatin1(interfaceName), - QString::fromLatin1(version)); - - entry.setInstantiationType(QRemoteServiceRegister::GlobalInstance); - serviceRegister->publishEntries(QString::fromLatin1(ident)); - - // this will start the server and keep it running - QObject *htmlService = QServiceManager().loadInterface(QString::fromLatin1(interfaceName)); - if (htmlService == NULL) - exit(0); - - const int returnCode = app.exec(); - delete htmlService; - delete serviceRegister; - return returnCode; -} - diff --git a/src/services/services.pro b/src/services/services.pro deleted file mode 100644 index e30727d..0000000 --- a/src/services/services.pro +++ /dev/null @@ -1,3 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += html diff --git a/src/src.pro b/src/src.pro index 1c2253b..d173fd3 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs -SUBDIRS += plugins services +SUBDIRS += plugins \ No newline at end of file From 8d9d0b74fe7906981856aaa93a08cf7387608277 Mon Sep 17 00:00:00 2001 From: "oleksandr.chupryna" Date: Fri, 17 Jun 2016 16:42:34 +0300 Subject: [PATCH 08/11] Fixed several issues --- src/plugins/html/client.html | 10 +- src/plugins/html/html.qrc | 23 +- src/plugins/html/html_embed.pro | 6 +- .../images/ui-bg_flat_0_aaaaaa_40x100.png | Bin 0 -> 180 bytes .../images/ui-bg_flat_75_ffffff_40x100.png | Bin 0 -> 178 bytes .../images/ui-bg_glass_55_fbf9ee_1x400.png | Bin 0 -> 120 bytes .../images/ui-bg_glass_65_ffffff_1x400.png | Bin 0 -> 105 bytes .../images/ui-bg_glass_75_dadada_1x400.png | Bin 0 -> 111 bytes .../images/ui-bg_glass_75_e6e6e6_1x400.png | Bin 0 -> 110 bytes .../images/ui-bg_glass_95_fef1ec_1x400.png | Bin 0 -> 119 bytes .../ui-bg_highlight-soft_75_cccccc_1x100.png | Bin 0 -> 101 bytes .../html/images/ui-icons_222222_256x240.png | Bin 0 -> 4369 bytes .../html/images/ui-icons_2e83ff_256x240.png | Bin 0 -> 4369 bytes .../html/images/ui-icons_454545_256x240.png | Bin 0 -> 4369 bytes .../html/images/ui-icons_888888_256x240.png | Bin 0 -> 4369 bytes .../html/images/ui-icons_cd0a0a_256x240.png | Bin 0 -> 4369 bytes src/plugins/html/jquery-ui.css | 566 ++++++++++++++++++ src/plugins/html/jquery-ui.min.js | 414 +++++++++++++ src/plugins/html/jquery.min.js | 4 + src/plugins/html/main.cpp | 3 +- src/plugins/html/qhtmlintegration.cpp | 11 +- src/plugins/html/qhtmlintegration.h | 5 +- src/plugins/html/qhtmlservice.cpp | 9 +- 23 files changed, 1028 insertions(+), 23 deletions(-) create mode 100644 src/plugins/html/images/ui-bg_flat_0_aaaaaa_40x100.png create mode 100644 src/plugins/html/images/ui-bg_flat_75_ffffff_40x100.png create mode 100644 src/plugins/html/images/ui-bg_glass_55_fbf9ee_1x400.png create mode 100644 src/plugins/html/images/ui-bg_glass_65_ffffff_1x400.png create mode 100644 src/plugins/html/images/ui-bg_glass_75_dadada_1x400.png create mode 100644 src/plugins/html/images/ui-bg_glass_75_e6e6e6_1x400.png create mode 100644 src/plugins/html/images/ui-bg_glass_95_fef1ec_1x400.png create mode 100644 src/plugins/html/images/ui-bg_highlight-soft_75_cccccc_1x100.png create mode 100644 src/plugins/html/images/ui-icons_222222_256x240.png create mode 100644 src/plugins/html/images/ui-icons_2e83ff_256x240.png create mode 100644 src/plugins/html/images/ui-icons_454545_256x240.png create mode 100644 src/plugins/html/images/ui-icons_888888_256x240.png create mode 100644 src/plugins/html/images/ui-icons_cd0a0a_256x240.png create mode 100644 src/plugins/html/jquery-ui.css create mode 100644 src/plugins/html/jquery-ui.min.js create mode 100644 src/plugins/html/jquery.min.js diff --git a/src/plugins/html/client.html b/src/plugins/html/client.html index bed2cc4..114d7f0 100644 --- a/src/plugins/html/client.html +++ b/src/plugins/html/client.html @@ -1,11 +1,11 @@ - - - - - + + + + +