Widgets: update widget transform upon receiving QEvent::FocusIn

QWidgetPrivate::updateWidgetTransform will only update the
transform if the widget is the current focus object.
But if someone calls QApplication::setActiveWindow, Qt will
call QWindow::requestActivate and then send focus
in/out events, all in the same event loop recursion.

The problem now is that requestActivate is not guaranteed to be
synchronous (it's not on iOS). So the window activation
(together with updating the focus object) will still be pending
when the widget receives the focus-in event. As such, the
transform update will also fail.

This patch will give the event as input to the function, so
that we don't depend on window activation being synchronous.

This will fix IM spell checking popups on iOS to show at the
correct place, also after closing font popups etc.

Change-Id: If0ee70f55692bbd613821b126923364e39ed1199
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
Richard Moe Gustavsen 2014-02-07 14:43:37 +01:00 committed by The Qt Project
parent 2a9944e281
commit 34dba9261e
2 changed files with 6 additions and 6 deletions

View File

@ -353,10 +353,10 @@ void QWidgetPrivate::scrollChildren(int dx, int dy)
}
}
void QWidgetPrivate::updateWidgetTransform()
void QWidgetPrivate::updateWidgetTransform(QEvent *event)
{
Q_Q(QWidget);
if (q == qGuiApp->focusObject()) {
if (q == qGuiApp->focusObject() || event->type() == QEvent::FocusIn) {
QTransform t;
QPoint p = q->mapTo(q->topLevelWidget(), QPoint(0,0));
t.translate(p.x(), p.y());
@ -8058,7 +8058,7 @@ bool QWidget::event(QEvent *event)
break;
case QEvent::FocusIn:
focusInEvent((QFocusEvent*)event);
d->updateWidgetTransform();
d->updateWidgetTransform(event);
break;
case QEvent::FocusOut:
@ -8100,12 +8100,12 @@ bool QWidget::event(QEvent *event)
case QEvent::Move:
moveEvent((QMoveEvent*)event);
d->updateWidgetTransform();
d->updateWidgetTransform(event);
break;
case QEvent::Resize:
resizeEvent((QResizeEvent*)event);
d->updateWidgetTransform();
d->updateWidgetTransform(event);
break;
case QEvent::Close:

View File

@ -438,7 +438,7 @@ public:
void syncBackingStore(const QRegion &region);
// tells the input method about the widgets transform
void updateWidgetTransform();
void updateWidgetTransform(QEvent *event);
void reparentFocusWidgets(QWidget *oldtlw);