From a41e073fca65671a370c6a4800310caad3ae75e8 Mon Sep 17 00:00:00 2001
From: Lars Knoll <lars.knoll@nokia.com>
Date: Wed, 7 Sep 2011 21:55:47 +0200
Subject: [PATCH] Ensure the itemTransform in QInputPanel is always up to date

Hook into the render loop and update the itemTransform in
the QInputPanel before we repaint.

Change-Id: If9122ba0fbe31cff3bfcc3edc48f684cc9b16984
Reviewed-on: http://codereview.qt-project.org/4405
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Vesa Rantanen <vesa.rantanen@nokia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
---
 src/declarative/items/qsgcanvas.cpp | 9 +++++++++
 src/declarative/items/qsgcanvas_p.h | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/src/declarative/items/qsgcanvas.cpp b/src/declarative/items/qsgcanvas.cpp
index 979fc161bc..6e81656ad6 100644
--- a/src/declarative/items/qsgcanvas.cpp
+++ b/src/declarative/items/qsgcanvas.cpp
@@ -70,6 +70,13 @@ DEFINE_BOOL_CONFIG_OPTION(qmlNoThreadedRenderer, QML_BAD_GUI_RENDER_LOOP)
 
 extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);
 
+void QSGCanvasRenderLoop::updateFocusItemTransform()
+{
+    QSGItem *focus = renderer->activeFocusItem();
+    if (focus && qApp->inputPanel()->inputItem() == focus)
+        qApp->inputPanel()->setInputItemTranform(QSGItemPrivate::get(focus)->itemToCanvasTransform());
+}
+
 class QSGCanvasPlainRenderLoop : public QObject, public QSGCanvasRenderLoop
 {
 public:
@@ -85,6 +92,7 @@ public:
     virtual void paint() {
         if (animationRunning && animationDriver())
             animationDriver()->advance();
+        updateFocusItemTransform();
         syncSceneGraph();
         makeCurrent();
         glViewport(0, 0, size.width(), size.height());
@@ -2030,6 +2038,7 @@ void QSGCanvasRenderThread::sync(bool guiAlreadyLocked)
     renderThreadAwakened = false;
 
     polishItems();
+    updateFocusItemTransform();
 
     wake();
     wait();
diff --git a/src/declarative/items/qsgcanvas_p.h b/src/declarative/items/qsgcanvas_p.h
index acd52a8a2a..b0c63f0d01 100644
--- a/src/declarative/items/qsgcanvas_p.h
+++ b/src/declarative/items/qsgcanvas_p.h
@@ -68,6 +68,7 @@
 #include <qopenglcontext.h>
 #include <QtGui/qopenglframebufferobject.h>
 #include <QtGui/qevent.h>
+#include <QtGui/qinputpanel.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -204,6 +205,7 @@ protected:
     void renderSceneGraph(const QSize &size) { d->renderSceneGraph(size); }
     void polishItems() { d->polishItems(); }
     QAnimationDriver *animationDriver() const { return d->animationDriver; }
+    void updateFocusItemTransform();
 
     inline QOpenGLContext *glContext() const { return gl; }
     void createGLContext();
-- 
GitLab