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

feat: allow running rdev in a thread #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Pranav2612000
Copy link

What does this PR do?

  • This PR allows us to capture events on a non-main thread. At the moment, the rdev crate only works if run on the main thread.

Why do we need this change?

  • At the moment, the listen loop runs using CFRunLoopGetMain which returns the loop of the main thread. This causes problems if rdev listen is called in a non-main thread.
  • We replace CFRunLoopGetMain with CFRunLoopGetCurrent which returns the loop of the current thread. This seems to fix the issue. This is also the way its done in the original rdev crate LINK

Gotcha's

  • The PR and other explanations are based on the understanding of the difference between CFRunLoopGetCurrent vs CFRunLoopGetMain which fixes the issue.

@clearlysid clearlysid deleted the fix/mac-event-capturing branch November 29, 2024 06:23
@HuakunShen
Copy link

But using CFRunLoopGetCurrent will result in a crash in Tauri apps when keyboard is pressed. Not sure why that happens, using CFRunLoopGetMain solves the problem, but in exit_grab, CFRunLoopStop(CUR_LOOP); could not kill the loop.

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