Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • xserver xserver
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 932
    • Issues 932
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 99
    • Merge requests 99
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • xorg
  • xserverxserver
  • Issues
  • #1214

Closed
Open
Created Aug 20, 2021 by zhang hao@kingderzhang

CopyKeyClass: did need to send XkbSendNewKeyboardNotify event?

I have a scanner, When using a Qt program to input, if the second character is uppercase, the first lowercase character will be converted to a character with shift during the first scan.

On my computer, using xdotool I can also reproduce this phenomenon. see error.mp4 and xdotool.sh

the video show the reproduce step:

  1. open a Qt program and type some character to make sure the keyboard is master device;
  2. then run xdotool.sh and active Qt window, select QLineEdit all text, wait xdotool input;
  3. you will see the first character is error.

note:

  1. reproduce this bug to make sure the second character is uppercase.
  2. xdotool sometime maybe can't reproduce,but scanner always exist.

video: error test shell: xdotool.sh IR code: ircode

Process analysis:

  1. when use xdotool or scanner input, first of all, xorg-server will call CopyKeyClass and send XkbSendNewKeyboardNotify event to Qt program;
  2. when Qt program recvice this event, Qt will call updateKeymap, see Qt code: https://github.com/qt/qtbase/blob/dev/src/plugins/platforms/xcb/qxcbkeyboard.cpp#L393
  3. in the updateKeymap function, Qt will call libxkbcommon to reset xkbState, and this time, libxkbcommon will return Qt a new xkbState, but the value base_mods of xkbState's is not right;

My guess:

  1. When xorg-server send XkbSendNewKeyboardNotify event, Qt and libxkbcommon communicate will spend some time;
  2. If Qt didn't initialized yet, and shift if pressed, and this time xorg-server will give libxkbcommon a error base_mods value of xkbState's.

note:

  1. If you increase the scanner input delay between characters, the probability of recurrence will decrease;
  2. If xorg-server not send XkbSendNewKeyboardNotify event, this bug don't reproduce;

question:

  1. CopyKeyClass note say Copy the device->key into master->key and send a mapping notify to the clients if appropriate. Should we send xkbMapNotify instead of xkbNewKeyboardNotify?
  2. if we don't send xkbNewKeyboardNotify event, will it cause other bugs?
Edited Aug 20, 2021 by zhang hao
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking