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

Improve nseventforwarder #7229

Merged
merged 2 commits into from
Nov 27, 2024
Merged

Conversation

MarkusPettersson98
Copy link
Contributor

@MarkusPettersson98 MarkusPettersson98 commented Nov 24, 2024

This PR improves the nseventforwarder implementation in the following ways:

  • Use clearly named variables
  • Add some more documentation to distinguish what's happening on the nodejs vs rust side
  • Get rid of the static Mutex, effectively allowing multiple nsevent-callback to be running at once. Because why not

This is not critical in any way, but especially the static Mutex bothered me since it didn't seem necessary :-)


This change is Reviewable

hulthe
hulthe previously approved these changes Nov 25, 2024
Copy link
Contributor

@hulthe hulthe left a comment

Choose a reason for hiding this comment

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

Nice! I'm also happy to see the mutex gone :)

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @MarkusPettersson98)


desktop/packages/nseventforwarder/nseventforwarder-rs/lib.rs line 57 at r1 (raw file):

                NSEventMask::LeftMouseDown | NSEventMask::RightMouseDown,
                &RcBlock::new(move |nsevent| {
                    nsevent_callback(nsevent);

⛏️ This closure is redundant, you can pass nsevent_callback directly (if you change its return type)

&RcBlock::new(nsevent_callback)

Copy link
Contributor Author

@MarkusPettersson98 MarkusPettersson98 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 2 files reviewed, all discussions resolved (waiting on @hulthe)


desktop/packages/nseventforwarder/nseventforwarder-rs/lib.rs line 57 at r1 (raw file):

Previously, hulthe (Joakim Hulthe) wrote…

⛏️ This closure is redundant, you can pass nsevent_callback directly (if you change its return type)

&RcBlock::new(nsevent_callback)

Nice one! ✨

Copy link
Contributor

@hulthe hulthe left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

- Move `Arc` closer to actual use
- Clearly separate the callback on nsveent from the nodejs callback
- Name the NSEvent that macOS gives us
Create one `NSEventContext` per call to `start`, effectively allowing
multiple, independenct callback to be registered at once.
@MarkusPettersson98 MarkusPettersson98 force-pushed the even-better-nseventforwarder branch from 244b360 to c43ac26 Compare November 27, 2024 06:19
@MarkusPettersson98 MarkusPettersson98 merged commit 56e46c5 into main Nov 27, 2024
26 checks passed
@MarkusPettersson98 MarkusPettersson98 deleted the even-better-nseventforwarder branch November 27, 2024 06:26
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