diff --git a/src/gui/inputmethod/qinputcontext.cpp b/src/gui/inputmethod/qinputcontext.cpp
index 639a38c..6e154e2 100644
--- a/src/gui/inputmethod/qinputcontext.cpp
+++ b/src/gui/inputmethod/qinputcontext.cpp
@@ -68,6 +68,7 @@
 #include "qpalette.h"
 
 #include <stdlib.h>
+#include <QDebug>
 #include <limits.h>
 
 QT_BEGIN_NAMESPACE
@@ -302,10 +303,12 @@ void QInputContext::mouseHandler(int /*x*/, QMouseEvent *event)
 {
     // Default behavior for simple ephemeral input contexts. Some
     // complex input contexts should not be reset here.
-    if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick)
-	reset();
-}
 
+    if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick) {
+        qDebug() << __FUNCTION__ << "Calling reset";
+        reset();
+    }
+}
 
 /*!
     Returns the font of the current input widget
diff --git a/src/gui/inputmethod/qwininputcontext_win.cpp b/src/gui/inputmethod/qwininputcontext_win.cpp
index 4005b72..2db706e 100644
--- a/src/gui/inputmethod/qwininputcontext_win.cpp
+++ b/src/gui/inputmethod/qwininputcontext_win.cpp
@@ -50,7 +50,7 @@
 #include "qtextformat.h"
 #include "qtextboundaryfinder.h"
 
-//#define Q_IME_DEBUG
+#define Q_IME_DEBUG
 
 #ifdef Q_IME_DEBUG
 #include "qdebug.h"
@@ -483,7 +483,7 @@ void QWinInputContext::reset()
     QWidget *fw = focusWidget();
 
 #ifdef Q_IME_DEBUG
-    qDebug() << "sending accept to focus widget" <<  fw;
+    qDebug() << __FUNCTION__ << "sending accept to focus widget" <<  fw;
 #endif
 
     if (fw && imePosition != -1) {
@@ -690,7 +690,7 @@ void QWinInputContext::updateImeStatus(QWidget *w, bool hasFocus)
             && !(focusProxyWidget->inputMethodHints() & (Qt::ImhExclusiveInputMask | Qt::ImhHiddenText));
     bool hasIme = e && hasFocus;
 #ifdef Q_IME_DEBUG
-    qDebug("%s HasFocus = %d hasIme = %d e = %d ", w->metaObject()->className(), hasFocus, hasIme, e);
+    qDebug("updateImeStatus %s HasFocus = %d hasIme = %d e = %d ", w->metaObject()->className(), hasFocus, hasIme, e);
 #endif
     if (hasFocus || e) {
         if (isInPopup(w))
@@ -728,7 +728,7 @@ void QWinInputContext::enable(QWidget *w, bool e)
 {
     if(w) {
 #ifdef Q_IME_DEBUG
-        qDebug() <<"enable: w=" << w << "enable=" << e;
+        qDebug() << __FUNCTION__ << "enable: w=" << w << "enable=" << e;
 #endif
         if (!w->testAttribute(Qt::WA_WState_Created))
             return;
@@ -775,8 +775,11 @@ void QWinInputContext::mouseHandler(int pos, QMouseEvent *e)
     if(e->type() != QEvent::MouseButtonPress)
         return;
 
-    if (pos < 0 || pos > imeComposition->length())
+
+    if (pos < 0 || pos > imeComposition->length()) {
+        qDebug() << __FUNCTION__ << "Calling reset";
         reset();
+    }
 
     // Probably should pass the correct button, but it seems to work fine like this.
     DWORD button = MK_LBUTTON;
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 428588d..905102b 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -2195,6 +2195,7 @@ QWidget *QApplication::focusWidget()
 
 void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason)
 {
+    qDebug() << __FUNCTION__ << focus << reason;
 #ifndef QT_NO_GRAPHICSVIEW
     if (focus && focus->window()->graphicsProxyWidget())
         return;
@@ -2225,6 +2226,7 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason)
             || !focus_widget->testAttribute(Qt::WA_WState_Created))))) {
              QInputContext *qic = prev->inputContext();
             if(qic) {
+                qDebug() << __FUNCTION__ << "Calling reset";
                 qic->reset();
                 qic->setFocusWidget(0);
             }
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 276d73a..b707456 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -2330,12 +2330,16 @@ extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wPa
             QWidget *fw = QApplication::focusWidget();
             QWinInputContext *im = fw ? qobject_cast<QWinInputContext *>(fw->inputContext()) : 0;
             if (fw && im) {
-                if(message == WM_IME_STARTCOMPOSITION)
+                if(message == WM_IME_STARTCOMPOSITION) {
+                    qDebug("WM_IME_STARTCOMPOSITION");
                     result = im->startComposition();
-                else if (message == WM_IME_ENDCOMPOSITION)
+                } else if (message == WM_IME_ENDCOMPOSITION) {
+                    qDebug("WM_IME_ENDCOMPOSITION");
                     result = im->endComposition();
-                else if (message == WM_IME_COMPOSITION)
+                } else if (message == WM_IME_COMPOSITION) {
+                    qDebug("WM_IME_COMPOSITION");
                     result = im->composition(lParam);
+                }
             }
             break;
         }
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index df8269f..4a7044f 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -56,6 +56,7 @@
 #ifndef QT_NO_GRAPHICSVIEW
 #include "qgraphicssceneevent.h"
 #endif
+#include <QDebug>
 
 QT_BEGIN_NAMESPACE
 
@@ -444,6 +445,7 @@ void QLineControl::moveCursor(int pos, bool mark)
 */
 void QLineControl::processInputMethodEvent(QInputMethodEvent *event)
 {
+    qDebug() << __FUNCTION__ << parent() << event->commitString().size() << "chars";
     int priorState = 0;
     int originalSelectionStart = m_selstart;
     int originalSelectionEnd = m_selend;
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 97f0308..8c1d51a 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -1337,6 +1337,7 @@ void QLineEdit::deselect()
 */
 void QLineEdit::insert(const QString &newText)
 {
+    qDebug() << __FUNCTION__ << this << newText;
 //     q->resetInputContext(); //#### FIX ME IN QT
     Q_D(QLineEdit);
     d->control->insert(newText);
