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

Cannot input on the VirtualKeyboard after Window being toggled from Hidden to Windowed

    XMLWordPrintable

Details

    • Windows

    Description

      How to reproduce

      1) Launch the provided qml snippet

      2) Before the window shows up make it loose focus by clicking somewhere else. For example click the window search bar

      3) After that make the Qt application regain focus by clicking the text box

      4) The Keyboard is broken

       

      Since a video value more than 1000 words look at the attached video

       

      Analysis

      I've done my homework and basically debug a little bit the Qt internals and that's what i discovered so far

      1. The bug is mainly caused by the Window visibility toggling from Windowed -> Hidden -> Windowed
      2. The virtual keyboard does not input any key because the input engine has no input method. Infact i usually get a 'Input method is not set' when this error occurs.
      3. The Input method is not set because the function "updateInputMethod()" in virtual keyboard "Keyboard.qml" is not called
      4. The "updateInputMethod()" is not called because the handler "onFucusChanged" of the Connection of the InputContext.priv is not called in "Keyboard.qml"
        Connections { target: InputContext. function onFocusChanged() { if (InputContext.priv.focus) updateInputMethod() } 
      1. By debugging i discovered that the InputContext.priv.focus should be toggled in "PlatformInputContext::update"
        void PlatformInputContext::update(Qt::InputMethodQueries queries)
        {
            VIRTUALKEYBOARD_DEBUG() << "PlatformInputContext::update():" << queries;
            bool enabled = inputMethodQuery(Qt::ImEnabled).toBool();
        #ifdef QT_VIRTUALKEYBOARD_DESKTOP
            if (enabled && !m_inputPanel && !m_desktopModeDisabled) {
                m_inputPanel = new DesktopInputPanel(this);
                m_inputPanel->createView();
                if (m_inputContext) {
                    m_selectionControl = new DesktopInputSelectionControl(this, m_inputContext);
                    m_selectionControl->createHandles();
                }
            }
        #endif
            if (m_inputContext) {
                if (enabled) {
                    m_inputContext->priv()->update(queries);
                    if (m_visible)
                        updateInputPanelVisible();
                } else {
                    hideInputPanel();
                }
                m_inputContext->priv()->setFocus(enabled);
            }
        }  
      1. The PlatformInputContext is usually called when the Window gets focus. But this does not happen

       

      Maybe this bug is related to QTBUG-86190 and in particular its patch  set https://codereview.qt-project.org/c/qt/qtvirtualkeyboard/+/316091 changed the line

       bool enabled = inputMethodQuery(Qt::ImEnabled).toBool();

       to

      bool enabled = inputMethodAccepted(); 

      Attachments

        1. 2020-10-08_9-38-43.mp4
          2.68 MB
        2. main.qml
          0.8 kB
        3. qtbug87277.zip
          3 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              vhilshei Volker Hilsheimer
              cuke Filippo Cucchetto
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes