all: widen Key to uint32 on every platform#42
Merged
Merged
Conversation
Media-key support needs wider key codes than the current types allow: X11 XF86* keysyms such as XF86AudioPlay (0x1008FF14) overflow uint16, and macOS needs more than uint8 to disambiguate media keys from Carbon keycodes. Unify Key as uint32 across all platforms (was uint8 on darwin/nocgo, uint16 on linux/windows). Minor source-compatibility note: code doing an explicit narrowing cast like uint16(key) needs updating; hotkey.KeyA and hotkey.Key(0x15) are unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Foundational change for media-key support (#28). Media keys need wider codes than the current
Keytypes allow:XF86*keysyms (e.g.XF86AudioPlay=0x1008FF14) overflowuint16.uint8to disambiguate media keys from Carbon keycodes.Unifies
Keyasuint32on all platforms (wasuint8on darwin/nocgo,uint16on linux/windows). Uniform width also removes a longstanding per-platform divergence.Source-compat note: code doing an explicit narrowing cast like
uint16(key)needs updating.hotkey.KeyA,hotkey.Key(0x15), and comparisons are unaffected. Verified by build + existing tests on all platforms.Foundation for the Linux/Windows media constants and the macOS CGEventTap backend that follow.