Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locked keyboard modifier synchronisation #105

Open
any1 opened this issue Nov 2, 2023 · 2 comments
Open

Locked keyboard modifier synchronisation #105

any1 opened this issue Nov 2, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@any1
Copy link
Owner

any1 commented Nov 2, 2023

The following situations cause lock key state to become desynchronised:

  • Client connects while a key is locked
  • Client window loses focus, lock key state is changed, window gets focus
  • Physical keyboard state on the server is altered
  • Another client modifies keyboard state

This should be implemented per-client to support multi-seat.

Extensions:

See: any1/wayvnc#271

@any1 any1 added the enhancement New feature or request label Nov 2, 2023
@any1
Copy link
Owner Author

any1 commented Apr 7, 2024

I've been looking at this more closely, and I've discovered the following:

  • The virtual keyboard does not share LED state with other keyboards
  • When you create a new virtual keyboard, its initial LED state is always unset.
  • There is no wayland protocol that allows setting the LED state. It can only be set by a keyboard.

Each client has its own virtual keyboard. This means that we don't have to worry about synchonising state between clients and we do not have to worry about getting the right state when we connect.

However, I have noticed, that when connecting with TigerVNC, the following sequence of events causes issues:

  • Focus outside VNC client and press CAPS LOCK
  • Focus VNC client, and type. The text will not be upper case.

It appears that the client does not make any attempt at synchonising the state.

@any1
Copy link
Owner Author

any1 commented Apr 7, 2024

Since LED state cannot change on the server side and it's reset when the client disconnects, and it's not shared between clients, a client that's connecting to WayVNC can reliably track the state without the server's help. However, it seems that VNC clients won't do this. They depend on the qemu/vmware extensions.

To pacify those clients, LED state extensions need to be implemented, but since the VNC client can't update the local LED state, it must fight the server instead. I.e. whenever the server sends a new state, the client needs to toggle modifiers to achieve its own desired state. This is bound to race and/or cause contention if done immediately upon receiving a LED state event from the server.

It seems that the only reasonable solution is to force the LED state upon the server right before any keyboard event. This can still race, but causes less contention.

I've implemented the LED state extensions, and now TigerVNC will actually sync the state, but only after focusing the window again for a second time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant