summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/quiview_textinput.mm
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2014-08-20 17:13:07 +0200
committerTor Arne Vestbø <tor.arne.vestbo@digia.com>2014-08-26 18:13:04 +0200
commit852dbe76584d244523c55f60c49c96ba0b5a0741 (patch)
tree888a4f67eb487641c42f115bb1e46212d3b1f3b2 /src/plugins/platforms/ios/quiview_textinput.mm
parentad120dbf13ddb7bff26e4489fbd0333facc1d38f (diff)
iOS: Use dispatch_async instead of performSelectorOnMainThread for IME
Gets rid of awkward wrapping of Qt::InputMethodQueries as integer in a NSObject. Change-Id: Ia7e368fc12ec7957ca8ab602d8cec1e0a071af1d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src/plugins/platforms/ios/quiview_textinput.mm')
-rw-r--r--src/plugins/platforms/ios/quiview_textinput.mm22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/plugins/platforms/ios/quiview_textinput.mm b/src/plugins/platforms/ios/quiview_textinput.mm
index 861c8151c6..2280b8259a 100644
--- a/src/plugins/platforms/ios/quiview_textinput.mm
+++ b/src/plugins/platforms/ios/quiview_textinput.mm
@@ -177,7 +177,7 @@ Q_GLOBAL_STATIC(StaticVariables, staticVariables);
[super becomeFirstResponder];
}
-- (void)updateUITextInputDelegate:(NSNumber *)intQuery
+- (void)updateUITextInputDelegate:(Qt::InputMethodQueries)query
{
// As documented, we should not report textWillChange/textDidChange unless the text
// was changed externally. That will cause spell checking etc to fail. But we don't
@@ -187,7 +187,6 @@ Q_GLOBAL_STATIC(StaticVariables, staticVariables);
if (m_inSendEventToFocusObject)
return;
- Qt::InputMethodQueries query = Qt::InputMethodQueries([intQuery intValue]);
if (query & (Qt::ImCursorPosition | Qt::ImAnchorPosition)) {
[self.inputDelegate selectionWillChange:id<UITextInput>(self)];
[self.inputDelegate selectionDidChange:id<UITextInput>(self)];
@@ -213,7 +212,7 @@ Q_GLOBAL_STATIC(StaticVariables, staticVariables);
// not be any performance gain by only updating \a query.
staticVariables()->inputMethodQueryEvent = QInputMethodQueryEvent(Qt::ImQueryInput);
QCoreApplication::sendEvent(focusObject, &staticVariables()->inputMethodQueryEvent);
- [self updateUITextInputDelegate:[NSNumber numberWithInt:int(query)]];
+ [self updateUITextInputDelegate:query];
}
- (void)sendEventToFocusObject:(QEvent &)e
@@ -234,20 +233,23 @@ Q_GLOBAL_STATIC(StaticVariables, staticVariables);
{
[self setMarkedText:@"" selectedRange:NSMakeRange(0, 0)];
[self updateInputMethodWithQuery:Qt::ImQueryInput];
+
// Guard agains recursive callbacks by posting calls to UITextInput
- [self performSelectorOnMainThread:@selector(updateKeyboardLayout) withObject:nil waitUntilDone:NO];
- [self performSelectorOnMainThread:@selector(updateUITextInputDelegate:)
- withObject:[NSNumber numberWithInt:int(Qt::ImQueryInput)]
- waitUntilDone:NO];
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [self updateKeyboardLayout];
+ [self updateUITextInputDelegate:Qt::ImQueryInput];
+ });
}
- (void)commit
{
[self unmarkText];
+
// Guard agains recursive callbacks by posting calls to UITextInput
- [self performSelectorOnMainThread:@selector(updateUITextInputDelegate:)
- withObject:[NSNumber numberWithInt:int(Qt::ImSurroundingText)]
- waitUntilDone:NO];
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [self updateKeyboardLayout];
+ [self updateUITextInputDelegate:Qt::ImSurroundingText];
+ });
}
- (QVariant)imValue:(Qt::InputMethodQuery)query