Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-138256

QPlatformInputContext::update() called with stale focus object

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.10
    • None
    • All

    Description

      The QPlatformInputContext contract assumes that changes to the focus object of the application will be reported via QPlatformInputContext::setFocusObject().

      Most/all of our platform input context implementations use this method to record the current focus object, which is then used in other code paths to e.g. probe or answer questions about the IM state.

      However our own machinery in Qt fails to call setFocusObject in time. For example:

      • During QGuiApplicationPrivate::processFocusWindowEvent we send QEvent::FocusIn to the new focus window, before later calling QGuiApplicationPrivate::_q_updateFocusObject which calls setFocusObject.
        • During the QEvent::FocusIn we end up in QQuickDeliveryAgentPrivate::updateFocusItemTransform, calling activeFocusItem->updateInputMethod(Qt::ImInputItemClipRectangle), resulting in the platform input context getting an update() for the wrong focus object
        • Potential other clients could react to the FocusIn the same way
      • During QQuickDeliveryAgentPrivate::setFocusInScope, when moving focus between items n a scene, we again end up in QQuickDeliveryAgentPrivate::updateFocusItemTransform before doing emit rootItem->window()->focusObjectChanged(activeFocusItem);

      Interestingly, in QtWidgets we call f->d_func()->updateFocusChild() (which updates the input context focus object) before calling QApplicationPrivate::setFocusWidget(f, reason); (which sends FocusOut/In), so we have some precedence to that approach. Although it feels more correct that the app observes a focus in of a new window before seeing a focus object change.

      In the iOS input context we explicitly detect the situation in update(), and refresh our cached reflection of the focus object.

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-138256
          # Subject Branch Project Status CR V

          Activity

            People

              vestbo Tor Arne Vestbø
              vestbo Tor Arne Vestbø
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change