Skip to content

Comments

PARSEC-5572 - Support additional character sets on macOS#170

Open
mtrang1263 wants to merge 4 commits intostablefrom
mt-macos-ascii
Open

PARSEC-5572 - Support additional character sets on macOS#170
mtrang1263 wants to merge 4 commits intostablefrom
mt-macos-ascii

Conversation

@mtrang1263
Copy link

@mtrang1263 mtrang1263 commented Feb 10, 2026

Update our text event handler to allow user to supply other unicode characters that are beyond the ascii character set.

QA Notes

Summary of changes

Update our handling of IMGUI text input to support additional characters. The method that sends the keypress events to the host is not affected (window_keyboard_event)

Platforms Affected

  • macOS

Test cases performed

  • macOS 26.2 / macOS 15.3.1
    • Able to type additional characters like æ (Option + ') Æ (Option + Shift + ') in the login screen (email and password) as well as the host search field.
    • Control characters, like backspace, are ignored and processed correctly by IMGUI
    • Able to pass additional characters when connected to macOS host (both 26.2 and 15.3.1) [This was working previously]
    • Connected to Windows host and keyboard inputs are working as expected.

Test cases untested

  • More thorough ASCII control codes and other Unicode control / odd characters.
    • I went through some of them, like Forward Delete on macOS but we are allowing additional unicode characters through that was previously dropped.

@mtrang1263 mtrang1263 requested a review from a team as a code owner February 10, 2026 21:01
@mtrang1263 mtrang1263 requested a review from Copilot February 10, 2026 21:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the macOS text event path to allow non-ASCII input by only filtering ASCII control characters (instead of restricting to “visible ASCII”).

Changes:

  • Replaces the “visible ASCII” gate with an early-return guard that only rejects ASCII control characters.
  • Allows multi-byte UTF-8 text to flow through to MTY_EVENT_TEXT.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

.type = MTY_EVENT_TEXT,
.window = ctx->window,
};
if (!text || !text[0] || (strlen(text) == 1 && (text[0] < 0x20 || text[0] == 0x7F)))
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strlen(text) == 1 scans the full string when you only need to know whether it’s a single byte/char. Prefer a constant-time check like text[1] == '\\0' to avoid unnecessary work in a hot text-input path (and to avoid reliance on potentially long/unterminated buffers).

Suggested change
if (!text || !text[0] || (strlen(text) == 1 && (text[0] < 0x20 || text[0] == 0x7F)))
if (!text || !text[0] || (text[1] == '\0' && (text[0] < 0x20 || text[0] == 0x7F)))

Copilot uses AI. Check for mistakes.
Comment on lines 781 to 784
if (!text || !text[0] || (strlen(text) == 1 && (text[0] < 0x20 || text[0] == 0x7F)))
// Ignore ASCII control characters
return;

Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guard condition is fairly dense and mixes three concerns (null/empty, single-byte check, control-character check). Consider splitting into a couple of straightforward if statements (or a small helper predicate) and adding braces for clarity to reduce the chance of future mistakes when this logic is modified.

Suggested change
if (!text || !text[0] || (strlen(text) == 1 && (text[0] < 0x20 || text[0] == 0x7F)))
// Ignore ASCII control characters
return;
if (!text || !text[0]) {
return;
}
if (strlen(text) == 1) {
unsigned char c = (unsigned char) text[0];
// Ignore ASCII control characters
if (c < 0x20 || c == 0x7F) {
return;
}
}

Copilot uses AI. Check for mistakes.
@mtrang1263 mtrang1263 requested a review from Copilot February 10, 2026 22:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// Keyboard

static bool is_function_key(NSEvent *event) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this function so we can still ignore function keys that were previously ignored by the strict ASCII value check.

@mtrang1263 mtrang1263 added 1. Coding Feature has been described inside of the parsec branch, and you are coding on it. 2. Review requested You have coded your code, and can now be reviewed. and removed 1. Coding Feature has been described inside of the parsec branch, and you are coding on it. 2. Review requested You have coded your code, and can now be reviewed. labels Feb 11, 2026
@mtrang1263
Copy link
Author

Moving back to coding to see if we can get the dead key support for additional accents.

@mtrang1263 mtrang1263 added 2. Review requested You have coded your code, and can now be reviewed. and removed 1. Coding Feature has been described inside of the parsec branch, and you are coding on it. labels Feb 13, 2026
@mtrang1263
Copy link
Author

Spent the day exploring dead keys. The complexity is a bit high for an edge case that's resolved by the webview. Marking as ready for review. Since no changes since I've last run it, we should be good for code review and then QA.

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

Labels

2. Review requested You have coded your code, and can now be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant