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

Unbalanced KeyPress/KeyRelease events when key modifier is released in between

    XMLWordPrintable

    Details

    • Platform/s:
      Linux/X11, macOS, Windows

      Description

      Steps to reproduce:

      0) Select en_US keyboard
      1) Press and hold Shift key
      2) Press and hold key '2' (which is for '@' symbol)
      3) Release Shift key
      4) Release key '2'

      In the result of this sequence the application gets a really weird sequnece of events:

      1) QEvent::KeyPress -> Qt::Key_Shift
      2) QEvent::KeyPress -> Qt::Key_At
      3) QEvent::KeyRelease -> Qt::Key_Shift
      4) QEvent::KeyRelease -> Qt::Key_2 # this key has never been pressed before!

      The problem happens because key's scancode is converted into qt-key using the modifiers at the moment of the event generation, which makes the qt-key code for key '2' generated incorrectly.

      I've made two patches for Krita's version of Qt (5.12.12) that fix this issue (Windows and Linux platforms only), though I'm not sure, perhaps it can be fixed in a more general way.

      Linux: https://invent.kde.org/graphics/krita/-/commit/d518783ca601fdc7f4d934cee01067137cc8f08e
      Windows: https://invent.kde.org/graphics/krita/-/commit/d682f0f5b17f64494a718652cb4ea733f725d83c

      PS:
      I don't have a patch for macOS yet, though the issue is reproducible there.

        Attachments

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

          Activity

            People

            Assignee:
            liaqi Liang Qi
            Reporter:
            dkazakov Dmitry Kazakov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes