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>
This commit is contained in:
parent
ad120dbf13
commit
852dbe7658
@ -177,7 +177,7 @@ Q_GLOBAL_STATIC(StaticVariables, staticVariables);
|
|||||||
[super becomeFirstResponder];
|
[super becomeFirstResponder];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateUITextInputDelegate:(NSNumber *)intQuery
|
- (void)updateUITextInputDelegate:(Qt::InputMethodQueries)query
|
||||||
{
|
{
|
||||||
// As documented, we should not report textWillChange/textDidChange unless the text
|
// 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
|
// 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)
|
if (m_inSendEventToFocusObject)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Qt::InputMethodQueries query = Qt::InputMethodQueries([intQuery intValue]);
|
|
||||||
if (query & (Qt::ImCursorPosition | Qt::ImAnchorPosition)) {
|
if (query & (Qt::ImCursorPosition | Qt::ImAnchorPosition)) {
|
||||||
[self.inputDelegate selectionWillChange:id<UITextInput>(self)];
|
[self.inputDelegate selectionWillChange:id<UITextInput>(self)];
|
||||||
[self.inputDelegate selectionDidChange: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.
|
// not be any performance gain by only updating \a query.
|
||||||
staticVariables()->inputMethodQueryEvent = QInputMethodQueryEvent(Qt::ImQueryInput);
|
staticVariables()->inputMethodQueryEvent = QInputMethodQueryEvent(Qt::ImQueryInput);
|
||||||
QCoreApplication::sendEvent(focusObject, &staticVariables()->inputMethodQueryEvent);
|
QCoreApplication::sendEvent(focusObject, &staticVariables()->inputMethodQueryEvent);
|
||||||
[self updateUITextInputDelegate:[NSNumber numberWithInt:int(query)]];
|
[self updateUITextInputDelegate:query];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)sendEventToFocusObject:(QEvent &)e
|
- (void)sendEventToFocusObject:(QEvent &)e
|
||||||
@ -234,20 +233,23 @@ Q_GLOBAL_STATIC(StaticVariables, staticVariables);
|
|||||||
{
|
{
|
||||||
[self setMarkedText:@"" selectedRange:NSMakeRange(0, 0)];
|
[self setMarkedText:@"" selectedRange:NSMakeRange(0, 0)];
|
||||||
[self updateInputMethodWithQuery:Qt::ImQueryInput];
|
[self updateInputMethodWithQuery:Qt::ImQueryInput];
|
||||||
|
|
||||||
// Guard agains recursive callbacks by posting calls to UITextInput
|
// Guard agains recursive callbacks by posting calls to UITextInput
|
||||||
[self performSelectorOnMainThread:@selector(updateKeyboardLayout) withObject:nil waitUntilDone:NO];
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[self performSelectorOnMainThread:@selector(updateUITextInputDelegate:)
|
[self updateKeyboardLayout];
|
||||||
withObject:[NSNumber numberWithInt:int(Qt::ImQueryInput)]
|
[self updateUITextInputDelegate:Qt::ImQueryInput];
|
||||||
waitUntilDone:NO];
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)commit
|
- (void)commit
|
||||||
{
|
{
|
||||||
[self unmarkText];
|
[self unmarkText];
|
||||||
|
|
||||||
// Guard agains recursive callbacks by posting calls to UITextInput
|
// Guard agains recursive callbacks by posting calls to UITextInput
|
||||||
[self performSelectorOnMainThread:@selector(updateUITextInputDelegate:)
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
withObject:[NSNumber numberWithInt:int(Qt::ImSurroundingText)]
|
[self updateKeyboardLayout];
|
||||||
waitUntilDone:NO];
|
[self updateUITextInputDelegate:Qt::ImSurroundingText];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (QVariant)imValue:(Qt::InputMethodQuery)query
|
- (QVariant)imValue:(Qt::InputMethodQuery)query
|
||||||
|
Loading…
x
Reference in New Issue
Block a user