summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2012-04-02 12:16:45 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-04-12 05:56:59 (GMT)
commit49e63efd2a45e1872468d8d6de1308c96ee92fcb (patch)
treef03975735f6e8745d657ef2b147a9d63811309e3 /src/gui
parent44c14470e5b28e45c19d6959b114e063cf3f4d83 (diff)
downloadQt-49e63efd2a45e1872468d8d6de1308c96ee92fcb.zip
Qt-49e63efd2a45e1872468d8d6de1308c96ee92fcb.tar.gz
Qt-49e63efd2a45e1872468d8d6de1308c96ee92fcb.tar.bz2
Ensure that the IME composition is handled correctly on Mac
When the language menu was shown while IME composition was underway, it would cause the composition text to be in an invalid state. Task-number: QTBUG-25107 Change-Id: Iaf06f330fb055e30c25ccc9874f15132ea000bc2 Reviewed-by: Tasuku Suzuki <tasuku.suzuki@nokia.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/inputmethod/qmacinputcontext_mac.cpp4
-rw-r--r--src/gui/inputmethod/qmacinputcontext_p.h3
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm11
3 files changed, 13 insertions, 5 deletions
diff --git a/src/gui/inputmethod/qmacinputcontext_mac.cpp b/src/gui/inputmethod/qmacinputcontext_mac.cpp
index 5fa5e63..282013a 100644
--- a/src/gui/inputmethod/qmacinputcontext_mac.cpp
+++ b/src/gui/inputmethod/qmacinputcontext_mac.cpp
@@ -58,7 +58,7 @@ extern bool qt_sendSpontaneousEvent(QObject*, QEvent*);
QMacInputContext::QMacInputContext(QObject *parent)
: QInputContext(parent), composing(false), recursionGuard(false), textDocument(0),
- keydownEvent(0)
+ keydownEvent(0), lastFocusWid(0)
{
// createTextDocument();
}
@@ -141,6 +141,8 @@ bool QMacInputContext::isComposing() const
void QMacInputContext::setFocusWidget(QWidget *w)
{
+ if (!w)
+ lastFocusWid = focusWidget();
createTextDocument();
#ifndef QT_MAC_USE_COCOA
if(w)
diff --git a/src/gui/inputmethod/qmacinputcontext_p.h b/src/gui/inputmethod/qmacinputcontext_p.h
index 1387246..39d19ab 100644
--- a/src/gui/inputmethod/qmacinputcontext_p.h
+++ b/src/gui/inputmethod/qmacinputcontext_p.h
@@ -81,7 +81,7 @@ public:
EventRef lastKeydownEvent() { return keydownEvent; }
void setLastKeydownEvent(EventRef);
-
+ QWidget *lastFocusWidget() const { return lastFocusWid; }
protected:
void mouseHandler(int pos, QMouseEvent *);
private:
@@ -90,6 +90,7 @@ private:
TSMDocumentID textDocument;
QString currentText;
EventRef keydownEvent;
+ QWidget *lastFocusWid;
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 84cb03a..63bbd29 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -1022,12 +1022,17 @@ static int qCocoaViewCount = 0;
// 256 to the key events handling process.
if (([aString length] && (composing || commitText.at(0).unicode() > 0xff)) || !fromKeyDownEvent) {
// Send the commit string to the widget.
- composing = false;
- sendKeyEvents = false;
QInputMethodEvent e;
e.setCommitString(commitText);
- if (QWidget *widgetToGetKey = qt_mac_getTargetForKeyEvent(qwidget))
+ QWidget *widgetToGetKey = 0;
+ if (!composing || qApp->focusWidget())
+ widgetToGetKey = qt_mac_getTargetForKeyEvent(qwidget);
+ else if (QMacInputContext *mic = qobject_cast<QMacInputContext *>(qApp->inputContext()))
+ widgetToGetKey = mic->lastFocusWidget();
+ if (widgetToGetKey)
qt_sendSpontaneousEvent(widgetToGetKey, &e);
+ composing = false;
+ sendKeyEvents = false;
} else {
// The key sequence "`q" on a French Keyboard will generate two calls to insertText before
// it returns from interpretKeyEvents. The first call will turn off 'composing' and accept