#include <private/qsgrenderer_p.h>
#include <private/qsgflashnode_p.h>
+#include <private/qguiapplication_p.h>
+#include <QtGui/QPlatformInputContext>
+
#include <private/qabstractanimation_p.h>
#include <QtGui/qpainter.h>
#include <QtWidgets/qgraphicssceneevent.h>
#include <QtGui/qmatrix4x4.h>
-#include <QtWidgets/qinputcontext.h>
#include <QtCore/qvarlengtharray.h>
#include <QtCore/qabstractanimation.h>
return d->vsyncAnimations;
}
+/*!
+ This function is an attempt to localize all uses of QInputContext::update in
+ one place up until the point where we have public API for the QInputContext API.
+ */
+void QSGCanvasPrivate::updateInputContext()
+{
+ QPlatformInputContext *ic = QGuiApplicationPrivate::platformIntegration()->inputContext();
+ if (ic)
+ ic->update();
+}
+/*!
+ This function is an attempt to localize all uses of QInputContext::reset in
+ one place up until the point where we have public API for the QInputContext API.
+ */
+void QSGCanvasPrivate::resetInputContext()
+{
+ QPlatformInputContext *ic = QGuiApplicationPrivate::platformIntegration()->inputContext();
+ if (ic)
+ ic->reset();
+}
+
void QSGCanvasPrivate::initializeSceneGraph()
{
Q_Q(QSGCanvas);
rootItem = new QSGRootItem;
- rootItem->setFocus(true);
QSGItemPrivate *rootItemPrivate = QSGItemPrivate::get(rootItem);
rootItemPrivate->canvas = q;
rootItemPrivate->flags |= QSGItem::ItemIsFocusScope;
+ // QML always has focus. It is important that this call happens after the rootItem
+ // has a canvas..
+ rootItem->setFocus(true);
+
thread = new QSGCanvasRenderThread;
thread->renderer = q;
thread->d = this;
if (oldActiveFocusItem) {
#ifndef QT_NO_IM
- // ### refactor: port properly...
- qDebug("QSGCanvas: input context resetting is not implemented");
-// if (QInputContext *ic = inputContext())
-// ic->reset();
+ resetInputContext();
#endif
activeFocusItem = 0;
Q_ASSERT(oldActiveFocusItem);
#ifndef QT_NO_IM
- // ### refactor: port properly
- qDebug("QSGCanvas: clear focus in scope, not implemented");
-// if (QInputContext *ic = inputContext())
-// ic->reset();
+ resetInputContext();
#endif
activeFocusItem = 0;
void syncSceneGraph();
void renderSceneGraph(const QSize &size);
+ void updateInputContext();
+ void resetInputContext();
+
QSGItem::UpdatePaintNodeData updatePaintNodeData;
QSGItem *dirtyItemList;
#include <QtDeclarative/qdeclarativeinfo.h>
#include <QtWidgets/qgraphicstransform.h>
#include <QtGui/qpen.h>
-#include <QtWidgets/qinputcontext.h>
#include <QtCore/qdebug.h>
#include <QtCore/qcoreevent.h>
#include <QtCore/qnumeric.h>
if (!d->canvas || d->canvas->activeFocusItem() != this)
return;
- QSGCanvasPrivate::get(d->canvas)->updateInputMethodData();
+ QSGCanvasPrivate *cd = QSGCanvasPrivate::get(d->canvas);
+ cd->updateInputMethodData();
#ifndef QT_NO_IM
- // ### refactor: port properly
- qDebug("QSGItem: setInputMethodHints: not implemented");
-// if (QInputContext *inputContext = d->canvas->inputContext())
-// inputContext->update();
+ cd->updateInputContext();
#endif
}
{
#ifndef QT_NO_IM
Q_D(QSGItem);
- if (d->canvas) {
- // ### refactor: port properly
- qDebug("QSGItem: setInputMethodHints: not implemented");
- // if (QInputContext *inputContext = d->canvas->inputContext())
- // inputContext->update();
- }
+ if (d->canvas)
+ QSGCanvasPrivate::get(d->canvas)->updateInputContext();
#endif
}
void QSGTextEdit::openSoftwareInputPanel()
{
if (qApp) {
- // ### refactor:port properly
- qDebug("QSGTextEdit: opening of virtual keyboard not implemented");
-// if (canvas() && canvas() == qApp->focusWidget()) {
-// QEvent event(QEvent::RequestSoftwareInputPanel);
-// QApplication::sendEvent(canvas(), &event);
-// }
+ if (canvas()) {
+ QEvent event(QEvent::RequestSoftwareInputPanel);
+ QApplication::sendEvent(canvas(), &event);
+ }
}
}
void QSGTextEdit::closeSoftwareInputPanel()
{
if (qApp) {
- // ### refactor: port properly
- qDebug("QSGTextEdit: closing of virtual keyboard not implemented...");
-// if (canvas() && canvas() == qApp->focusWidget()) {
-// QEvent event(QEvent::CloseSoftwareInputPanel);
-// QApplication::sendEvent(canvas(), &event);
-// }
+ if (canvas()) {
+ QEvent event(QEvent::CloseSoftwareInputPanel);
+ QApplication::sendEvent(canvas(), &event);
+ }
}
}
void QSGTextInput::openSoftwareInputPanel()
{
- QEvent event(QEvent::RequestSoftwareInputPanel);
if (qApp) {
- if (canvas() && canvas() == QGuiApplication::activeWindow()) {
+ if (canvas()) {
QEvent event(QEvent::RequestSoftwareInputPanel);
QApplication::sendEvent(canvas(), &event);
}
void QSGTextInput::closeSoftwareInputPanel()
{
if (qApp) {
- if (canvas() && canvas() == QGuiApplication::activeWindow()) {
- // ### refactor: port properly
- qDebug("QSGTextInput: closing virtual keyboard not implemented");
-// QEvent event(QEvent::CloseSoftwareInputPanel);
-// QApplication::sendEvent(canvas(), &event);
+ if (canvas()) {
+ QEvent event(QEvent::CloseSoftwareInputPanel);
+ QApplication::sendEvent(canvas(), &event);
}
}
}