Skip to content

Support {MODE=VIRTUAL} on macOS#13402

Open
allenbenz wants to merge 1 commit into
keepassxreboot:developfrom
allenbenz:screen-sharing-osx
Open

Support {MODE=VIRTUAL} on macOS#13402
allenbenz wants to merge 1 commit into
keepassxreboot:developfrom
allenbenz:screen-sharing-osx

Conversation

@allenbenz

@allenbenz allenbenz commented Jun 1, 2026

Copy link
Copy Markdown

This adds support for typing through Screen Sharing (and presumably VNC and similar keyboard passthrough windows) #8433
It works similarly to the windows approach except VkKeyScanExW doesn't exist on OSX. (as far as I can tell) and so we have to enumerate through all the keycodes * modifiers to find the keyboard event to character mapping. This could be more efficient with caching it but it was fast enough as is so I thought it wasn't worth the complexity of caching the mapping. This still uses the else if (mode == Mode::VIRTUAL) branch to gate everything so these changes shouldn't impact regular use.

There are a couple limitations to this approach:

  • It doesn't work if the keyboard of the host and the remote differ with regard to any of the text being typed.
  • It can't type passwords that take more than a keypress and a modifier

I didn't see a way to avoid the limitations when the keypresses are being forwarded to the remote.

An alternative approach would be to always do the key to text mapping lookup, this would let the remote typing to work in a lot of situations without needing {MODE=VIRTUAL}, but that doesn't allow for error messages when the mapping fails and I didn't want to make this kind of change on the main autotype path, if you want that change I can do that but it'll swallow errors.

On that note, I made {MODE=VIRTUAL} fail with an error if the key to text mapping failed, the error has the same text as a similar failure in AutoTypeXCB.cpp. I didn't wire up the translations as I thought that might make the PR harder to read. Do you want me to add the translations or maybe do something else?

Generative AI was used extensively. I am not deeply familiar with either qt or cocoa.

Testing strategy

Ran autotype from an osx laptop to a osx remote via Screen Sharing

  • {MODE=VIRTUAL} with over the enumerations of combinations of username,password,enter,tab. Worked as expected
  • {MODE=VIRTUAL} with a password that wasn't typeable, got an error message as expected.
  • same without {MODE=VIRTUAL}, writes 'a' instead as expected
    Ran autotype from an osx laptop to the local console window
  • Same tests as above, same results for the first two, and for the third everything works (no {MODE=VIRTUAL})

Type of change

  • ✅ Bug fix (non-breaking change that fixes an issue)
  • ✅ New feature (change that adds functionality)

@allenbenz allenbenz force-pushed the screen-sharing-osx branch from ae36208 to 663c142 Compare June 2, 2026 04:07
@varjolintu varjolintu added platform: macOS pr: ai-assisted Pull request contains significant contributions by generative AI labels Jun 2, 2026
@allenbenz allenbenz force-pushed the screen-sharing-osx branch 2 times, most recently from 11d972b to 941a812 Compare June 8, 2026 19:39
@allenbenz allenbenz force-pushed the screen-sharing-osx branch from 941a812 to c96be68 Compare June 21, 2026 23:14
@allenbenz allenbenz force-pushed the screen-sharing-osx branch from c96be68 to 53b5345 Compare June 23, 2026 05:39
@allenbenz

allenbenz commented Jun 23, 2026

Copy link
Copy Markdown
Author

Fixed the formatting for the test file and possibly fixed the test failure by setting includeAllInstalled for the TISCreateInputSourceList call in the tests to true so it won't be limited to activated keyboard layouts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform: macOS pr: ai-assisted Pull request contains significant contributions by generative AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants