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

Investigate using RegisterEventHotKey instead of Event taps. #31

Open
numist opened this issue Jul 22, 2013 · 2 comments
Open

Investigate using RegisterEventHotKey instead of Event taps. #31

numist opened this issue Jul 22, 2013 · 2 comments
Milestone

Comments

@numist
Copy link
Owner

numist commented Jul 22, 2013

This is a pretty low priority—it would only be useful for listing Switch in the App Store.

@numist numist closed this as completed Aug 5, 2013
@borismus
Copy link

@numist why closed? Did you find this to be impossible?

@numist
Copy link
Owner Author

numist commented Nov 12, 2013

Not at all, but there were other factors at play specific to Switch's purpose.

Two arguments in favour of Switch sticking with an event tap:

  • Switch doesn't want to be the active application; it makes application and window order more difficult to maintain, and the Accessibility IPC calls are inherently slow and, sadly, error-prone. At the same time, Switch does want to receive mouse events when it is in use. The event manager implemented in Switch forwards mouse events to the UI when it is being shown, solving both of these problems.
  • Ultimately I'd like to support custom keybindings. While this is totally possible with RegisterEventHotKey, it is not possible to override ⌘⇥ using anything other than an event tap.

Those two arguments are very application-specific, and there exist at least as many good general arguments against using an event tap:

  • Event taps slow down the entire system. It's critically important that the event handler be the fastest part of your application because it will be run for every single input event. Even if your handler is a return statement there is a significant cost—the time spent context switching adds up. With RegisterEventHotKey, you only get events when they are relevant to you.
  • Event taps do not work in sandboxed applications. I believe the sandbox to be generally a Good Thing™ for users, and a decent guardrail for developers. Unfortunately, it's already impossible to sandbox Switch due to the use of Accessibility and CGWindowListCreateImage.

@numist numist added bug and removed wontfix labels May 6, 2015
@numist numist added this to the GM milestone May 6, 2015
@numist numist reopened this May 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants