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

Keypress event doesn't take into account xmodmap rebindings

    XMLWordPrintable

Details

    Description

      I have remapped keys with xmodmap, and those are taken into account by all applications except the ones that use Qt5.8.

      My xmodmap command is :

      xmodmap \
      	-e 'clear Control' \
      	-e 'keycode 37 = n' \
      	-e 'keycode 57 = Control_L' \
      	-e 'add Control = Control_L'
      

      It swaps the key `n` with the `Control_L` key.

      Here is a test script (in Python)

      #!/usr/bin/env python3
      
      from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QHBoxLayout
      
      class KeyWidget(QWidget):
      
          def __init__(self, parent=None):
              super().__init__(parent)
              self._layout = QHBoxLayout(self)
              self._label = QLabel(text="Waiting for keypress...")
              self._layout.addWidget(self._label)
      
          def keyPressEvent(self, e):
              lines = [
                  'key: 0x{:x}'.format(int(e.key())),
                  'modifiers: 0x{:x}'.format(int(e.modifiers())),
                  'text: {!r}'.format(e.text()),
              ]
              self._label.setText('\n'.join(lines))
      
      
      app = QApplication([])
      w = KeyWidget()
      w.show()
      app.exec_()
      

      However, I get following results :

      If I hit the key n on my keyboard :

      N
      
      key: 0x4e
      modifiers: 0x0
      text: 'n'
      

      If I hit the left ctrl key :

      None
      
      key: 0x1000021
      modifiers: 0x4000000
      text: ''
      

      And If I hit n and b at the same time (n then b , without releasing n)

      Ctrl+B
      
      key: 0x42
      modifiers: 0x4000000
      text: '\x02'
      

      This issue was first opened here : https://github.com/qutebrowser/qutebrowser/issues/2350#issuecomment-282592037

      But since it seems to be a Qt issue, I open it here now

      Attachments

        Issue Links

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

          Activity

            People

              paeglis Gatis Paeglis
              jirauser43750 user-56075 (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes