diff options
author | Gunnar Sletta <gunnar.sletta@nokia.com> | 2011-08-04 10:34:08 +0200 |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-08-05 10:46:12 +0200 |
commit | 8f3b218099d9f1d9aa4ae58474430f864a8758ef (patch) | |
tree | f48d70803a3b9e5fe3c4f879d8b90a5919f8fde4 /src | |
parent | a61337b33ae1a3ee2df1570da30880e8fe9237e9 (diff) |
Make QSGCanvas a QWindow instead of a QGLWidget
Change-Id: I71a04f61acff893a35c00204ed11bdf852830485
Reviewed-on: http://codereview.qt.nokia.com/2675
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/declarative.pro | 2 | ||||
-rw-r--r-- | src/declarative/items/qsgcanvas.cpp | 301 | ||||
-rw-r--r-- | src/declarative/items/qsgcanvas.h | 14 | ||||
-rw-r--r-- | src/declarative/items/qsgcanvas_p.h | 11 | ||||
-rw-r--r-- | src/declarative/items/qsgitem.cpp | 24 | ||||
-rw-r--r-- | src/declarative/items/qsgtextedit.cpp | 32 | ||||
-rw-r--r-- | src/declarative/items/qsgtextinput.cpp | 19 | ||||
-rw-r--r-- | src/declarative/items/qsgview.cpp | 48 | ||||
-rw-r--r-- | src/declarative/items/qsgview.h | 7 | ||||
-rw-r--r-- | src/imports/imports.pro | 3 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmltooling.pro | 6 | ||||
-rw-r--r-- | src/src.pro | 5 |
12 files changed, 140 insertions, 332 deletions
diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro index d8126d0d9c..c959e4caaf 100644 --- a/src/declarative/declarative.pro +++ b/src/declarative/declarative.pro @@ -6,7 +6,7 @@ QPRO_PWD = $$PWD CONFIG += module MODULE_PRI += ../../modules/qt_declarative.pri -QT = core-private gui-private script-private network script opengl-private widgets-private +QT = core-private gui-private script-private network script opengl opengl-private widgets-private contains(QT_CONFIG, svg): QT += svg DEFINES += QT_BUILD_DECLARATIVE_LIB QT_NO_URL_CAST_FROM_STRING win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000 diff --git a/src/declarative/items/qsgcanvas.cpp b/src/declarative/items/qsgcanvas.cpp index a2af67ce37..341d3bd2f0 100644 --- a/src/declarative/items/qsgcanvas.cpp +++ b/src/declarative/items/qsgcanvas.cpp @@ -63,7 +63,6 @@ QT_BEGIN_NAMESPACE -DEFINE_BOOL_CONFIG_OPTION(qmlNoThreadedRenderer, QML_NO_THREADED_RENDERER) DEFINE_BOOL_CONFIG_OPTION(qmlFixedAnimationStep, QML_FIXED_ANIMATION_STEP) extern Q_OPENGL_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha); @@ -146,7 +145,7 @@ have a scope focused item), and the other items will have their focus cleared. // #define MOUSE_DEBUG // #define TOUCH_DEBUG // #define DIRTY_DEBUG -// #define THREAD_DEBUG +#define THREAD_DEBUG // #define FRAME_TIMING @@ -165,134 +164,37 @@ QSGRootItem::QSGRootItem() { } -void QSGCanvas::paintEvent(QPaintEvent *) +void QSGCanvas::exposeEvent(QExposeEvent *) { Q_D(QSGCanvas); - - if (!d->threadedRendering) { -#ifdef FRAME_TIMING - int lastFrame = frameTimer.restart(); -#endif - - if (d->animationDriver && d->animationDriver->isRunning()) - d->animationDriver->advance(); - -#ifdef FRAME_TIMING - int animationTime = frameTimer.elapsed(); -#endif - - Q_ASSERT(d->context); - - d->polishItems(); - - QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::FramePaint); - QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::Painting); - -#ifdef FRAME_TIMING - int polishTime = frameTimer.elapsed(); -#endif - - makeCurrent(); - -#ifdef FRAME_TIMING - int makecurrentTime = frameTimer.elapsed(); -#endif - - d->syncSceneGraph(); - -#ifdef FRAME_TIMING - int syncTime = frameTimer.elapsed(); -#endif - - d->renderSceneGraph(d->widgetSize); - - swapBuffers(); - -#ifdef FRAME_TIMING - printf("FrameTimes, last=%d, animations=%d, polish=%d, makeCurrent=%d, sync=%d, sgrender=%d, readback=%d, total=%d\n", - lastFrame, - animationTime, - polishTime - animationTime, - makecurrentTime - polishTime, - syncTime - makecurrentTime, - sceneGraphRenderTime - syncTime, - readbackTime - sceneGraphRenderTime, - frameTimer.elapsed()); -#endif - - QDeclarativeDebugTrace::endRange(QDeclarativeDebugTrace::Painting); - - if (d->animationDriver && d->animationDriver->isRunning()) - update(); - } else { - if (updatesEnabled()) { - d->thread->paint(); - setUpdatesEnabled(false); - } - } + d->thread->paint(); } void QSGCanvas::resizeEvent(QResizeEvent *e) { Q_D(QSGCanvas); - if (d->threadedRendering) { - d->thread->resize(e->size()); - } else { - d->widgetSize = e->size(); - d->viewportSize = d->widgetSize; - QGLWidget::resizeEvent(e); - } + d->thread->resize(e->size()); } void QSGCanvas::showEvent(QShowEvent *e) { Q_D(QSGCanvas); - QGLWidget::showEvent(e); - - if (!d->contextFailed) { - if (d->threadedRendering) { - if (d->vsyncAnimations) { - if (!d->animationDriver) { - d->animationDriver = d->context->createAnimationDriver(this); - connect(d->animationDriver, SIGNAL(started()), d->thread, SLOT(animationStarted()), Qt::DirectConnection); - connect(d->animationDriver, SIGNAL(stopped()), d->thread, SLOT(animationStopped()), Qt::DirectConnection); - } - d->animationDriver->install(); - } - d->thread->startRenderThread(); - setUpdatesEnabled(true); - } else { - makeCurrent(); - - if (!d->context || !d->context->isReady()) { - d->initializeSceneGraph(); - if (d->vsyncAnimations) { - d->animationDriver = d->context->createAnimationDriver(this); - connect(d->animationDriver, SIGNAL(started()), this, SLOT(update())); - } - } - - if (d->animationDriver) - d->animationDriver->install(); + if (d->vsyncAnimations) { + if (!d->animationDriver) { + d->animationDriver = d->context->createAnimationDriver(this); + connect(d->animationDriver, SIGNAL(started()), d->thread, SLOT(animationStarted()), Qt::DirectConnection); + connect(d->animationDriver, SIGNAL(stopped()), d->thread, SLOT(animationStopped()), Qt::DirectConnection); } + d->animationDriver->install(); } + d->thread->startRenderThread(); } void QSGCanvas::hideEvent(QHideEvent *e) { Q_D(QSGCanvas); - - if (!d->contextFailed) { - if (d->threadedRendering) { - d->thread->stopRenderThread(); - } - - if (d->animationDriver) - d->animationDriver->uninstall(); - } - - QGLWidget::hideEvent(e); + d->thread->stopRenderThread(); } @@ -313,7 +215,7 @@ void QSGCanvas::hideEvent(QHideEvent *e) void QSGCanvas::setVSyncAnimations(bool enabled) { Q_D(QSGCanvas); - if (isVisible()) { + if (visible()) { qWarning("QSGCanvas::setVSyncAnimations: Cannot be changed when widget is shown"); return; } @@ -333,21 +235,6 @@ bool QSGCanvas::vsyncAnimations() const } - -void QSGCanvas::focusOutEvent(QFocusEvent *event) -{ - Q_D(QSGCanvas); - d->rootItem->setFocus(false); - QGLWidget::focusOutEvent(event); -} - -void QSGCanvas::focusInEvent(QFocusEvent *event) -{ - Q_D(QSGCanvas); - d->rootItem->setFocus(true); - QGLWidget::focusInEvent(event); -} - void QSGCanvasPrivate::initializeSceneGraph() { if (!context) @@ -359,11 +246,9 @@ void QSGCanvasPrivate::initializeSceneGraph() QGLContext *glctx = const_cast<QGLContext *>(QGLContext::currentContext()); context->initialize(glctx); - if (!threadedRendering) { - Q_Q(QSGCanvas); - QObject::connect(context->renderer(), SIGNAL(sceneGraphChanged()), q, SLOT(maybeUpdate()), - Qt::DirectConnection); - } + Q_Q(QSGCanvas); + QObject::connect(context->renderer(), SIGNAL(sceneGraphChanged()), q, SLOT(maybeUpdate()), + Qt::DirectConnection); if (!QSGItemPrivate::get(rootItem)->itemNode()->parent()) { context->rootNode()->appendChildNode(QSGItemPrivate::get(rootItem)->itemNode()); @@ -424,8 +309,6 @@ QSGCanvasPrivate::QSGCanvasPrivate() , hoverItem(0) , dirtyItemList(0) , context(0) - , contextFailed(false) - , threadedRendering(false) , animationRunning(false) , renderThreadAwakened(false) , vsyncAnimations(false) @@ -433,7 +316,6 @@ QSGCanvasPrivate::QSGCanvasPrivate() , animationDriver(0) , renderTarget(0) { - threadedRendering = !qmlNoThreadedRenderer(); } QSGCanvasPrivate::~QSGCanvasPrivate() @@ -444,31 +326,19 @@ void QSGCanvasPrivate::init(QSGCanvas *c) { QUnifiedTimer::instance(true)->setConsistentTiming(qmlFixedAnimationStep()); - if (!c->context() || !c->context()->isValid()) { - contextFailed = true; - qWarning("QSGCanvas: Couldn't acquire a GL context."); - } - q_ptr = c; Q_Q(QSGCanvas); - q->setAttribute(Qt::WA_AcceptTouchEvents); - q->setFocusPolicy(Qt::StrongFocus); - rootItem = new QSGRootItem; + rootItem->setFocus(true); QSGItemPrivate *rootItemPrivate = QSGItemPrivate::get(rootItem); rootItemPrivate->canvas = q; rootItemPrivate->flags |= QSGItem::ItemIsFocusScope; - context = QSGContext::createDefaultContext(); - - if (threadedRendering) { - thread = new QSGCanvasRenderThread; - thread->renderer = q; - thread->d = this; - } - + thread = new QSGCanvasRenderThread; + thread->renderer = q; + thread->d = this; } void QSGCanvasPrivate::sceneMouseEventForTransform(QGraphicsSceneMouseEvent &sceneEvent, @@ -516,8 +386,6 @@ Fill in the data in \a sceneEvent based on \a event. This method leaves the ite */ void QSGCanvasPrivate::sceneMouseEventFromMouseEvent(QGraphicsSceneMouseEvent &sceneEvent, QMouseEvent *event) { - Q_Q(QSGCanvas); - Q_ASSERT(event); if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick) { @@ -549,16 +417,16 @@ void QSGCanvasPrivate::sceneMouseEventFromMouseEvent(QGraphicsSceneMouseEvent &s sceneEvent.setScenePos(event->pos()); sceneEvent.setScreenPos(event->globalPos()); sceneEvent.setLastScenePos(lastMousePosition); - sceneEvent.setLastScreenPos(q->mapToGlobal(lastMousePosition)); + sceneEvent.setLastScreenPos(lastMousePosition); // ### refactor: should do mapToGlobal sceneEvent.setButtons(event->buttons()); sceneEvent.setButton(event->button()); sceneEvent.setModifiers(event->modifiers()); - sceneEvent.setWidget(q); +// sceneEvent.setWidget(q); // ### refactor: for (int ii = 0; ii < 5; ++ii) { if (sceneEvent.buttons() & (1 << ii)) { sceneEvent.setButtonDownScenePos((Qt::MouseButton)(1 << ii), buttonDownPositions[ii]); - sceneEvent.setButtonDownScreenPos((Qt::MouseButton)(1 << ii), q->mapToGlobal(buttonDownPositions[ii])); + sceneEvent.setButtonDownScreenPos((Qt::MouseButton)(1 << ii), buttonDownPositions[ii]); // ### refactor: should do mapToGlobal } } @@ -571,9 +439,9 @@ Translates the data in \a touchEvent to this canvas. This method leaves the ite */ void QSGCanvasPrivate::translateTouchEvent(QTouchEvent *touchEvent) { - Q_Q(QSGCanvas); +// Q_Q(QSGCanvas); - touchEvent->setWidget(q); +// touchEvent->setWidget(q); // ### refactor... QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints(); for (int i = 0; i < touchPoints.count(); ++i) { @@ -626,8 +494,10 @@ void QSGCanvasPrivate::setFocusInScope(QSGItem *scope, QSGItem *item, FocusOptio if (oldActiveFocusItem) { #ifndef QT_NO_IM - if (QInputContext *ic = inputContext()) - ic->reset(); + // ### refactor: port properly... + qDebug("QSGCanvas: input context resetting is not implemented"); +// if (QInputContext *ic = inputContext()) +// ic->reset(); #endif activeFocusItem = 0; @@ -671,13 +541,13 @@ void QSGCanvasPrivate::setFocusInScope(QSGItem *scope, QSGItem *item, FocusOptio } if (!(options & DontChangeFocusProperty)) { - if (item != rootItem || q->hasFocus()) { + // if (item != rootItem || q->hasFocus()) { // ### refactor: focus handling... itemPrivate->focus = true; changed << item; - } + // } } - if (newActiveFocusItem && q->hasFocus()) { + if (newActiveFocusItem) { // ### refactor: && q->hasFocus()) { activeFocusItem = newActiveFocusItem; QSGItemPrivate::get(newActiveFocusItem)->activeFocus = true; @@ -736,8 +606,10 @@ void QSGCanvasPrivate::clearFocusInScope(QSGItem *scope, QSGItem *item, FocusOpt Q_ASSERT(oldActiveFocusItem); #ifndef QT_NO_IM - if (QInputContext *ic = inputContext()) - ic->reset(); + // ### refactor: port properly + qDebug("QSGCanvas: clear focus in scope, not implemented"); +// if (QInputContext *ic = inputContext()) +// ic->reset(); #endif activeFocusItem = 0; @@ -816,11 +688,12 @@ void QSGCanvasPrivate::notifyFocusChangesRecur(QSGItem **items, int remaining) void QSGCanvasPrivate::updateInputMethodData() { - Q_Q(QSGCanvas); - bool enabled = activeFocusItem - && (QSGItemPrivate::get(activeFocusItem)->flags & QSGItem::ItemAcceptsInputMethod); - q->setAttribute(Qt::WA_InputMethodEnabled, enabled); - q->setInputMethodHints(enabled ? activeFocusItem->inputMethodHints() : Qt::ImhNone); + // Q_Q(QSGCanvas); + // ### refactor: port.. +// bool enabled = activeFocusItem +// && (QSGItemPrivate::get(activeFocusItem)->flags & QSGItem::ItemAcceptsInputMethod); +// q->setAttribute(Qt::WA_InputMethodEnabled, enabled); +// q->setInputMethodHints(enabled ? activeFocusItem->inputMethodHints() : Qt::ImhNone); } QVariant QSGCanvas::inputMethodQuery(Qt::InputMethodQuery query) const @@ -857,39 +730,17 @@ void QSGCanvasPrivate::cleanup(QSGNode *n) q->maybeUpdate(); } -static QGLFormat tweakFormat(const QGLFormat &format = QGLFormat::defaultFormat()) -{ - QGLFormat f = format; - f.setSwapInterval(0); - return f; -} -QSGCanvas::QSGCanvas(QWidget *parent, Qt::WindowFlags f) - : QGLWidget(*(new QSGCanvasPrivate), tweakFormat(), parent, (QGLWidget *) 0, f) +QSGCanvas::QSGCanvas(QWindow *parent) + : QWindow(parent) { Q_D(QSGCanvas); d->init(this); } -QSGCanvas::QSGCanvas(const QGLFormat &format, QWidget *parent, Qt::WindowFlags f) - : QGLWidget(*(new QSGCanvasPrivate), tweakFormat(format), parent, (QGLWidget *) 0, f) -{ - Q_D(QSGCanvas); - - d->init(this); -} - -QSGCanvas::QSGCanvas(QSGCanvasPrivate &dd, QWidget *parent, Qt::WindowFlags f) -: QGLWidget(dd, tweakFormat(), parent, 0, f) -{ - Q_D(QSGCanvas); - - d->init(this); -} - -QSGCanvas::QSGCanvas(QSGCanvasPrivate &dd, const QGLFormat &format, QWidget *parent, Qt::WindowFlags f) -: QGLWidget(dd, tweakFormat(format), parent, 0, f) +QSGCanvas::QSGCanvas(QSGCanvasPrivate &dd, QWindow *parent) + : QWindow(dd, parent) { Q_D(QSGCanvas); @@ -900,7 +751,7 @@ QSGCanvas::~QSGCanvas() { Q_D(QSGCanvas); - if (d->threadedRendering && d->thread->isRunning()) { + if (d->thread->isRunning()) { d->thread->stopRenderThread(); delete d->thread; d->thread = 0; @@ -914,22 +765,6 @@ QSGCanvas::~QSGCanvas() delete d->rootItem; d->rootItem = 0; d->cleanupNodes(); - - - if (!d->contextFailed) { - // We need to remove all references to textures pointing to "our" QSGContext - // from the QDeclarativePixmapCache. Call into the cache to remove the GL / Scene Graph - // part of those cache entries. - // To "play nice" with other GL apps that are potentially running in the GUI thread, - // We get the current context and only temporarily make our own current - QGLContext *currentContext = const_cast<QGLContext *>(QGLContext::currentContext()); - makeCurrent(); - extern void qt_declarative_pixmapstore_clean(QSGContext *context); - qt_declarative_pixmapstore_clean(d->context); - delete d->context; - if (currentContext) - currentContext->makeCurrent(); - } } QSGItem *QSGCanvas::rootItem() const @@ -960,7 +795,7 @@ void QSGCanvasPrivate::clearHover() if (!hoverItem) return; - QPointF pos = q->mapFromGlobal(QCursor::pos()); + QPointF pos = QCursor::pos(); // ### refactor: q->mapFromGlobal(QCursor::pos()); QSGItem *item = hoverItem; hoverItem = 0; @@ -1019,7 +854,7 @@ bool QSGCanvas::event(QEvent *e) break; } - return QGLWidget::event(e); + return QWindow::event(e); } void QSGCanvas::keyPressEvent(QKeyEvent *e) @@ -1134,7 +969,7 @@ void QSGCanvas::mouseReleaseEvent(QMouseEvent *event) #endif if (!d->mouseGrabberItem) { - QGLWidget::mouseReleaseEvent(event); + QWindow::mouseReleaseEvent(event); return; } @@ -1440,7 +1275,7 @@ bool QSGCanvasPrivate::deliverTouchPoints(QSGItem *item, QTouchEvent *event, con if (eventStates != Qt::TouchPointStationary) { QTouchEvent touchEvent(eventType); - touchEvent.setWidget(q); + // touchEvent.setWidget(q); // ### refactor: what is the consequence of not setting the widget? touchEvent.setDeviceType(event->deviceType()); touchEvent.setModifiers(event->modifiers()); touchEvent.setTouchPointStates(eventStates); @@ -1893,7 +1728,7 @@ void QSGCanvas::maybeUpdate() { Q_D(QSGCanvas); - if (d->threadedRendering && d->thread && d->thread->isRunning()) { + if (d->thread->isRunning()) { Q_ASSERT_X(QThread::currentThread() == QApplication::instance()->thread() || d->thread->inSync, "QSGCanvas::update", "Function can only be called from GUI thread or during QSGItem::updatePaintNode()"); @@ -1912,8 +1747,6 @@ void QSGCanvas::maybeUpdate() d->thread->wake(); d->thread->unlockInGui(); } - } else if (!d->animationDriver || !d->animationDriver->isRunning()) { - update(); } } @@ -1990,13 +1823,7 @@ QGLFramebufferObject *QSGCanvas::renderTarget() const QImage QSGCanvas::grabFrameBuffer() { Q_D(QSGCanvas); - if (d->threadedRendering) - return d->thread ? d->thread->grab() : QImage(); - else { - // render a fresh copy of the scene graph in the current thread. - d->renderSceneGraph(size()); - return QGLWidget::grabFrameBuffer(false); - } + return d->thread ? d->thread->grab() : QImage(); } @@ -2006,7 +1833,15 @@ void QSGCanvasRenderThread::run() qDebug("QML Rendering Thread Started"); #endif - renderer->makeCurrent(); + if (!guiContext) { + guiContext = new QGuiGLContext(); + guiContext->create(); + + glContext = QGLContext::fromGuiGLContext(guiContext); + + } + + guiContext->makeCurrent(renderer); if (!d->context->isReady()) d->initializeSceneGraph(); @@ -2081,7 +1916,7 @@ void QSGCanvasRenderThread::run() printf(" RenderThread: wait for swap...\n"); #endif - renderer->swapBuffers(); + guiContext->swapBuffers(renderer); #ifdef THREAD_DEBUG printf(" RenderThread: swap complete...\n"); @@ -2114,7 +1949,7 @@ void QSGCanvasRenderThread::run() printf(" RenderThread: exited... Good Night!\n"); #endif - renderer->doneCurrent(); + guiContext->doneCurrent(); lock(); hasExited = true; @@ -2142,8 +1977,6 @@ void QSGCanvasRenderThread::sync(bool guiAlreadyLocked) #ifdef THREAD_DEBUG printf("GUI: sync - %s\n", guiAlreadyLocked ? "outside event" : "inside event"); #endif - Q_ASSERT(d->threadedRendering); - if (!guiAlreadyLocked) d->thread->lockInGui(); @@ -2243,10 +2076,6 @@ void QSGCanvasRenderThread::paint() wait(); } unlockInGui(); - - // paint is only called for the inital show. After that we will do all - // drawing ourselves, so block future updates.. - renderer->setUpdatesEnabled(false); } @@ -2286,8 +2115,6 @@ void QSGCanvasRenderThread::startRenderThread() shouldExit = false; isGuiBlocked = 0; isGuiBlockPending = false; - - renderer->doneCurrent(); start(); } diff --git a/src/declarative/items/qsgcanvas.h b/src/declarative/items/qsgcanvas.h index 2fb80bf954..a7846d818a 100644 --- a/src/declarative/items/qsgcanvas.h +++ b/src/declarative/items/qsgcanvas.h @@ -57,13 +57,13 @@ class QSGEngine; class QSGCanvasPrivate; class QGLFramebufferObject; -class Q_DECLARATIVE_EXPORT QSGCanvas : public QGLWidget +class Q_DECLARATIVE_EXPORT QSGCanvas : public QWindow { Q_OBJECT Q_DECLARE_PRIVATE(QSGCanvas) public: - QSGCanvas(QWidget *parent = 0, Qt::WindowFlags f = 0); - QSGCanvas(const QGLFormat &format, QWidget *parent = 0, Qt::WindowFlags f = 0); + QSGCanvas(QWindow *parent = 0); + virtual ~QSGCanvas(); QSGItem *rootItem() const; @@ -89,18 +89,14 @@ Q_SIGNALS: void sceneGraphInitialized(); protected: - QSGCanvas(QSGCanvasPrivate &dd, QWidget *parent = 0, Qt::WindowFlags f = 0); - QSGCanvas(QSGCanvasPrivate &dd, const QGLFormat &format, QWidget *parent = 0, Qt::WindowFlags f = 0); + QSGCanvas(QSGCanvasPrivate &dd, QWindow *parent = 0); - virtual void paintEvent(QPaintEvent *); + virtual void exposeEvent(QExposeEvent *); virtual void resizeEvent(QResizeEvent *); virtual void showEvent(QShowEvent *); virtual void hideEvent(QHideEvent *); - virtual void focusOutEvent(QFocusEvent *); - virtual void focusInEvent(QFocusEvent *); - virtual bool event(QEvent *); virtual void keyPressEvent(QKeyEvent *); virtual void keyReleaseEvent(QKeyEvent *); diff --git a/src/declarative/items/qsgcanvas_p.h b/src/declarative/items/qsgcanvas_p.h index 20fc332e1b..b147bb3325 100644 --- a/src/declarative/items/qsgcanvas_p.h +++ b/src/declarative/items/qsgcanvas_p.h @@ -64,7 +64,9 @@ #include <QtCore/qmutex.h> #include <QtCore/qwaitcondition.h> #include <private/qwidget_p.h> +#include <private/qwindow_p.h> #include <private/qgl_p.h> +#include <qguiglcontext_qpa.h> #include <QtOpenGL/qglframebufferobject.h> QT_BEGIN_NAMESPACE @@ -82,7 +84,7 @@ class QSGCanvasPrivate; class QTouchEvent; class QSGCanvasRenderThread; -class QSGCanvasPrivate : public QGLWidgetPrivate +class QSGCanvasPrivate : public QWindowPrivate { public: Q_DECLARE_PUBLIC(QSGCanvas) @@ -156,8 +158,6 @@ public: QSGContext *context; - uint contextFailed : 1; - uint threadedRendering : 1; uint animationRunning: 1; uint renderThreadAwakened : 1; @@ -182,6 +182,8 @@ class QSGCanvasRenderThread : public QThread public: QSGCanvasRenderThread() : mutex(QMutex::NonRecursive) + , guiContext(0) + , glContext(0) , isGuiBlocked(0) , isPaintCompleted(false) , isGuiBlockPending(false) @@ -225,6 +227,9 @@ public: QSGCanvas *renderer; QSGCanvasPrivate *d; + QGuiGLContext *guiContext; + QGLContext *glContext; + int isGuiBlocked; uint isPaintCompleted : 1; uint isGuiBlockPending : 1; diff --git a/src/declarative/items/qsgitem.cpp b/src/declarative/items/qsgitem.cpp index 5274e312e5..cf521d9540 100644 --- a/src/declarative/items/qsgitem.cpp +++ b/src/declarative/items/qsgitem.cpp @@ -1168,9 +1168,6 @@ void QSGItemPrivate::initCanvas(InitializationState *state, QSGCanvas *c) if (canvas && polishScheduled) QSGCanvasPrivate::get(canvas)->itemsToPolish.insert(q); - if (canvas && hoverEnabled && !canvas->hasMouseTracking()) - canvas->setMouseTracking(true); - // XXX todo - why aren't these added to the destroy list? itemNodeInstance = 0; opacityNode = 0; @@ -1728,9 +1725,10 @@ void QSGItem::setInputMethodHints(Qt::InputMethodHints hints) QSGCanvasPrivate::get(d->canvas)->updateInputMethodData(); #ifndef QT_NO_IM - if (d->canvas->hasFocus()) - if (QInputContext *inputContext = d->canvas->inputContext()) - inputContext->update(); + // ### refactor: port properly + qDebug("QSGItem: setInputMethodHints: not implemented"); +// if (QInputContext *inputContext = d->canvas->inputContext()) +// inputContext->update(); #endif } @@ -1738,9 +1736,12 @@ void QSGItem::updateMicroFocus() { #ifndef QT_NO_IM Q_D(QSGItem); - if (d->canvas && d->canvas->hasFocus()) - if (QInputContext *inputContext = d->canvas->inputContext()) - inputContext->update(); + if (d->canvas) { + // ### refactor: port properly + qDebug("QSGItem: setInputMethodHints: not implemented"); + // if (QInputContext *inputContext = d->canvas->inputContext()) + // inputContext->update(); + } #endif } @@ -3005,7 +3006,7 @@ bool QSGItem::isUnderMouse() const return false; QPoint cursorPos = QCursor::pos(); - if (QRectF(0, 0, width(), height()).contains(mapFromScene(d->canvas->mapFromGlobal(cursorPos)))) + if (QRectF(0, 0, width(), height()).contains(mapFromScene(cursorPos))) // ### refactor: d->canvas->mapFromGlobal(cursorPos)))) return true; return false; } @@ -3020,9 +3021,6 @@ void QSGItem::setAcceptHoverEvents(bool enabled) { Q_D(QSGItem); d->hoverEnabled = enabled; - - if (d->canvas && d->hoverEnabled && !d->canvas->hasMouseTracking()) - d->canvas->setMouseTracking(true); } void QSGItem::grabMouse() diff --git a/src/declarative/items/qsgtextedit.cpp b/src/declarative/items/qsgtextedit.cpp index 00c9d5ff16..6c529db3d5 100644 --- a/src/declarative/items/qsgtextedit.cpp +++ b/src/declarative/items/qsgtextedit.cpp @@ -834,9 +834,11 @@ void QSGTextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) d->control->processEvent(event, QPointF(0, -d->yoff)); if (!d->showInputPanelOnFocus) { // input panel on click if (d->focusOnPress && !isReadOnly() && boundingRect().contains(event->pos())) { - if (canvas() && canvas() == qApp->focusWidget()) { - qt_widget_private(canvas())->handleSoftwareInputPanel(event->button(), d->clickCausedFocus); - } + // ### refactor: port properly + qDebug("QSGTextEdit: virtual keyboard handling not implemented"); +// if (canvas() && canvas() == qApp->focusWidget()) { +// qt_widget_private(canvas())->handleSoftwareInputPanel(event->button(), d->clickCausedFocus); +// } } } d->clickCausedFocus = false; @@ -886,7 +888,7 @@ void QSGTextEdit::itemChange(ItemChange change, const ItemChangeData &value) { Q_D(QSGTextEdit); if (change == ItemActiveFocusHasChanged) { - setCursorVisible(value.boolValue && d->canvas && d->canvas->hasFocus()); + setCursorVisible(value.boolValue); // ### refactor: focus handling && d->canvas && d->canvas->hasFocus()); } QSGItem::itemChange(change, value); } @@ -1191,20 +1193,24 @@ void QSGTextEditPrivate::updateDefaultTextOption() void QSGTextEdit::openSoftwareInputPanel() { if (qApp) { - if (canvas() && canvas() == qApp->focusWidget()) { - QEvent event(QEvent::RequestSoftwareInputPanel); - QApplication::sendEvent(canvas(), &event); - } + // ### refactor:port properly + qDebug("QSGTextEdit: opening of virtual keyboard not implemented"); +// if (canvas() && canvas() == qApp->focusWidget()) { +// QEvent event(QEvent::RequestSoftwareInputPanel); +// QApplication::sendEvent(canvas(), &event); +// } } } void QSGTextEdit::closeSoftwareInputPanel() -{ +{ if (qApp) { - if (canvas() && canvas() == qApp->focusWidget()) { - QEvent event(QEvent::CloseSoftwareInputPanel); - QApplication::sendEvent(canvas(), &event); - } + // ### refactor: port properly + qDebug("QSGTextEdit: closing of virtual keyboard not implemented..."); +// if (canvas() && canvas() == qApp->focusWidget()) { +// QEvent event(QEvent::CloseSoftwareInputPanel); +// QApplication::sendEvent(canvas(), &event); +// } } } diff --git a/src/declarative/items/qsgtextinput.cpp b/src/declarative/items/qsgtextinput.cpp index b60143a67d..d55bdc8924 100644 --- a/src/declarative/items/qsgtextinput.cpp +++ b/src/declarative/items/qsgtextinput.cpp @@ -686,8 +686,10 @@ void QSGTextInput::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) } if (!d->showInputPanelOnFocus) { // input panel on click if (d->focusOnPress && !isReadOnly() && boundingRect().contains(event->pos())) { - if (canvas() && canvas() == qApp->focusWidget()) { - qt_widget_private(canvas())->handleSoftwareInputPanel(event->button(), d->clickCausedFocus); + if (canvas() && canvas() == QGuiApplication::activeWindow()) { + // ### refactor: implement virtual keyboard properly.. + qDebug("QSGTextInput: virtual keyboard no implemented..."); +// qt_widget_private(canvas())->handleSoftwareInputPanel(event->button(), d->clickCausedFocus); } } } @@ -767,7 +769,6 @@ bool QSGTextInput::event(QEvent* ev) void QSGTextInput::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { - Q_D(QSGTextInput); if (newGeometry.width() != oldGeometry.width()) { updateSize(); updateCursorRectangle(); @@ -1057,7 +1058,7 @@ void QSGTextInput::openSoftwareInputPanel() { QEvent event(QEvent::RequestSoftwareInputPanel); if (qApp) { - if (canvas() && canvas() == qApp->focusWidget()) { + if (canvas() && canvas() == QGuiApplication::activeWindow()) { QEvent event(QEvent::RequestSoftwareInputPanel); QApplication::sendEvent(canvas(), &event); } @@ -1067,9 +1068,11 @@ void QSGTextInput::openSoftwareInputPanel() void QSGTextInput::closeSoftwareInputPanel() { if (qApp) { - if (canvas() && canvas() == qApp->focusWidget()) { - QEvent event(QEvent::CloseSoftwareInputPanel); - QApplication::sendEvent(canvas(), &event); + if (canvas() && canvas() == QGuiApplication::activeWindow()) { + // ### refactor: port properly + qDebug("QSGTextInput: closing virtual keyboard not implemented"); +// QEvent event(QEvent::CloseSoftwareInputPanel); +// QApplication::sendEvent(canvas(), &event); } } } @@ -1091,7 +1094,7 @@ void QSGTextInput::itemChange(ItemChange change, const ItemChangeData &value) if (change == ItemActiveFocusHasChanged) { bool hasFocus = value.boolValue; d->focused = hasFocus; - setCursorVisible(hasFocus && d->canvas && d->canvas->hasFocus()); + setCursorVisible(hasFocus); // ### refactor: && d->canvas && d->canvas->hasFocus() if(echoMode() == QSGTextInput::PasswordEchoOnEdit && !hasFocus) d->control->updatePasswordEchoEditing(false);//QLineControl sets it on key events, but doesn't deal with focus events if (!hasFocus) diff --git a/src/declarative/items/qsgview.cpp b/src/declarative/items/qsgview.cpp index 416b803814..cf906386e8 100644 --- a/src/declarative/items/qsgview.cpp +++ b/src/declarative/items/qsgview.cpp @@ -91,7 +91,6 @@ public: void QSGViewPrivate::init() { - q_func()->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); QDeclarativeEnginePrivate::get(&engine)->sgContext = QSGCanvasPrivate::context; QDeclarativeInspectorService::instance()->addView(q_func()); @@ -141,28 +140,17 @@ void QSGViewPrivate::itemGeometryChanged(QSGItem *resizeItem, const QRectF &newG QSGItemChangeListener::itemGeometryChanged(resizeItem, newGeometry, oldGeometry); } -QSGView::QSGView(QWidget *parent, Qt::WindowFlags f) -: QSGCanvas(*(new QSGViewPrivate), parent, f) +QSGView::QSGView(QWindow *parent, Qt::WindowFlags f) +: QSGCanvas(*(new QSGViewPrivate), parent) { + setWindowFlags(f); d_func()->init(); } -QSGView::QSGView(const QGLFormat &format, QWidget *parent, Qt::WindowFlags f) -: QSGCanvas(*(new QSGViewPrivate), format, parent, f) -{ - d_func()->init(); -} - -QSGView::QSGView(const QUrl &source, QWidget *parent, Qt::WindowFlags f) -: QSGCanvas(*(new QSGViewPrivate), parent, f) -{ - d_func()->init(); - setSource(source); -} - -QSGView::QSGView(const QUrl &source, const QGLFormat &format, QWidget *parent, Qt::WindowFlags f) -: QSGCanvas(*(new QSGViewPrivate), format, parent, f) +QSGView::QSGView(const QUrl &source, QWindow *parent, Qt::WindowFlags f) +: QSGCanvas(*(new QSGViewPrivate), parent) { + setWindowFlags(f); d_func()->init(); setSource(source); } @@ -260,8 +248,6 @@ void QSGViewPrivate::updateSize() if (!qFuzzyCompare(q->height(), root->height())) root->setHeight(q->height()); } - - q->updateGeometry(); } QSize QSGViewPrivate::rootObjectSize() const @@ -351,11 +337,9 @@ void QSGViewPrivate::setRootObject(QObject *obj) if (root) { initialSize = rootObjectSize(); - if ((resizeMode == QSGView::SizeViewToRootObject || !q->testAttribute(Qt::WA_Resized)) + if ((resizeMode == QSGView::SizeViewToRootObject) // ### refactor: || !q->testAttribute(Qt::WA_Resized) && initialSize != q->size()) { - if (!(q->parentWidget() && q->parentWidget()->layout())) { - q->resize(initialSize); - } + q->resize(initialSize); } initResize(); } @@ -416,22 +400,6 @@ void QSGView::resizeEvent(QResizeEvent *e) QSGCanvas::resizeEvent(e); } -/*! - \internal -*/ -void QSGView::paintEvent(QPaintEvent *event) -{ - Q_D(QSGView); - int time = 0; - if (frameRateDebug()) - time = d->frameTimer.restart(); - - QSGCanvas::paintEvent(event); - - if (frameRateDebug()) - qDebug() << "paintEvent:" << d->frameTimer.elapsed() << "time since last frame:" << time; -} - void QSGView::keyPressEvent(QKeyEvent *e) { QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::Key); diff --git a/src/declarative/items/qsgview.h b/src/declarative/items/qsgview.h index 9b5ace13f3..62b52c865b 100644 --- a/src/declarative/items/qsgview.h +++ b/src/declarative/items/qsgview.h @@ -66,10 +66,8 @@ class Q_DECLARATIVE_EXPORT QSGView : public QSGCanvas Q_PROPERTY(QUrl source READ source WRITE setSource DESIGNABLE true) Q_ENUMS(ResizeMode Status) public: - explicit QSGView(QWidget *parent = 0, Qt::WindowFlags f = 0); - explicit QSGView(const QGLFormat &format, QWidget *parent = 0, Qt::WindowFlags f = 0); - QSGView(const QUrl &source, QWidget *parent = 0, Qt::WindowFlags f = 0); - QSGView(const QUrl &source, const QGLFormat &format, QWidget *parent = 0, Qt::WindowFlags f = 0); + explicit QSGView(QWindow *parent = 0, Qt::WindowFlags f = 0); + QSGView(const QUrl &source, QWindow *parent = 0, Qt::WindowFlags f = 0); virtual ~QSGView(); QUrl source() const; @@ -102,7 +100,6 @@ private Q_SLOTS: protected: virtual void resizeEvent(QResizeEvent *); - virtual void paintEvent(QPaintEvent *event); virtual void timerEvent(QTimerEvent*); virtual void keyPressEvent(QKeyEvent *); diff --git a/src/imports/imports.pro b/src/imports/imports.pro index c60e72db08..6096ad7a6a 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,5 +1,6 @@ TEMPLATE = subdirs SUBDIRS += qtquick1 qt47 folderlistmodel particles gestures inputcontext etcprovider -contains(QT_CONFIG, qmltest): SUBDIRS += testlib +# ### refactor: port properly +# contains(QT_CONFIG, qmltest): SUBDIRS += testlib diff --git a/src/plugins/qmltooling/qmltooling.pro b/src/plugins/qmltooling/qmltooling.pro index 8220109efc..d400f741cc 100644 --- a/src/plugins/qmltooling/qmltooling.pro +++ b/src/plugins/qmltooling/qmltooling.pro @@ -1,4 +1,8 @@ TEMPLATE = subdirs -SUBDIRS = qmldbg_tcp qmldbg_inspector +SUBDIRS = qmldbg_tcp + +# ### refactor: +# SUBDIRS = qmldbg_inspector + symbian:SUBDIRS += qmldbg_ost diff --git a/src/src.pro b/src/src.pro index b7407cc102..f214763f52 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,6 +1,9 @@ TEMPLATE = subdirs CONFIG += ordered SUBDIRS += declarative qtquick1 plugins -contains(QT_CONFIG, qmltest): SUBDIRS += qmltest + +# ### refactor: port properly +# contains(QT_CONFIG, qmltest): SUBDIRS += qmltest + SUBDIRS += imports QT += script widgets widgets-private |