Skip to content

macos: Add a hook to update stale modifiers#5

Merged
murarth merged 1 commit intomurarth:modifiers-changed-window-eventfrom
rye:macos-update-stale-modifiers
Jan 22, 2020
Merged

macos: Add a hook to update stale modifiers#5
murarth merged 1 commit intomurarth:modifiers-changed-window-eventfrom
rye:macos-update-stale-modifiers

Conversation

@rye
Copy link
Copy Markdown

@rye rye commented Jan 22, 2020

Sometimes, our stored ViewState and the NSEvent we process might have different values for their stored modifiers flags, especially if loss of window focus has occurred. These are internally stored as a bitmask in the latter and an enum in the former.

We can check to see if they differ, and if they do, automatically dispatch an event to update consumers of modifier state as well as the stored state.modifiers. That's what the hook does.

This hook is then called in the key_down, mouse_entered, mouse_exited, mouse_click, scroll_wheel, and pressure_change_with_event callbacks, which each will contain updated modifiers.

Sometimes, `ViewState` and `event` might have different values for their
stored `modifiers` flags.  These are internally stored as a bitmask in
the latter and an enum in the former.

We can check to see if they differ, and if they do, automatically
dispatch an event to update consumers of modifier state as well as the
stored `state.modifiers`.  That's what the hook does.

This hook is then called in the key_down, mouse_entered, mouse_exited,
mouse_click, scroll_wheel, and pressure_change_with_event callbacks,
which each will contain updated modifiers.

Signed-off-by: Kristofer Rye <kristofer.rye@gmail.com>
@murarth murarth merged commit 4a8d78f into murarth:modifiers-changed-window-event Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants