diff options
author | Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com> | 2016-04-28 13:42:50 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com> | 2016-05-06 07:21:49 +0000 |
commit | 697cbf3474d32ebd4f7e22695223cdb8cdf44f35 (patch) | |
tree | 073db9cc6a587ed41611fb0e530bd0f9c020d5d2 /src/quick | |
parent | 9a7cf067a178c7a08a7ed9f2c6253e1feade5569 (diff) |
QQuickWindowPrivate: Only update transform on polish if needed
As it stood, whenever QtQuick did a polish we would update
IM transform. The result would be that we signaled changes
to e.g cursor rectangle and input rectangle each time the
cursor was redrawn. This of course caused code elsewhere, e.g
in the platform plugins, to recalculate overlays such as
cursor handles when nothing with regards to input item
transform had actually changed.
This patch will add some extra checks that the effective transform
of the focus object has really changed before telling IM
to update.
Change-Id: If7057e4dd8f41e251a27d68fcaebdb10da953ee7
Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
Diffstat (limited to 'src/quick')
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index b94b0b7d59..54e4339f7e 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -257,6 +257,26 @@ void QQuickWindow::focusInEvent(QFocusEvent *ev) d->updateFocusItemTransform(); } +#ifndef QT_NO_IM +static bool transformDirtyOnItemOrAncestor(const QQuickItem *item) +{ + while (item) { + if (QQuickItemPrivate::get(item)->dirtyAttributes & ( + QQuickItemPrivate::TransformOrigin | + QQuickItemPrivate::Transform | + QQuickItemPrivate::BasicTransform | + QQuickItemPrivate::Position | + QQuickItemPrivate::Size | + QQuickItemPrivate::ParentChanged | + QQuickItemPrivate::Clip)) { + return true; + } + item = item->parentItem(); + } + return false; +} +#endif + void QQuickWindowPrivate::polishItems() { // An item can trigger polish on another item, or itself for that matter, @@ -276,7 +296,17 @@ void QQuickWindowPrivate::polishItems() if (recursionSafeguard == 0) qWarning("QQuickWindow: possible QQuickItem::polish() loop"); - updateFocusItemTransform(); +#ifndef QT_NO_IM + if (QQuickItem *focusItem = q_func()->activeFocusItem()) { + // If the current focus item, or any of its anchestors, has changed location + // inside the window, we need inform IM about it. This to ensure that overlays + // such as selection handles will be updated. + const bool isActiveFocusItem = (focusItem == QGuiApplication::focusObject()); + const bool hasImEnabled = focusItem->inputMethodQuery(Qt::ImEnabled).toBool(); + if (isActiveFocusItem && hasImEnabled && transformDirtyOnItemOrAncestor(focusItem)) + updateFocusItemTransform(); + } +#endif } /*! |