Skip to content

Fix macOS volume and media key posting#184

Merged
AprilNEA merged 3 commits into
AprilNEA:masterfrom
jonstuebe:fix/macos-volume-media-keys
Jun 12, 2026
Merged

Fix macOS volume and media key posting#184
AprilNEA merged 3 commits into
AprilNEA:masterfrom
jonstuebe:fix/macos-volume-media-keys

Conversation

@jonstuebe

Copy link
Copy Markdown
Contributor

Summary

  • Post macOS volume and media controls as NSSystemDefined subtype 8 NX events instead of standard keyboard events
  • Wire Volume Up/Down/Mute plus Play/Pause/Next/Previous through the shared media-key helper
  • Add macOS objc2 AppKit/CoreGraphics bindings needed to create and post NSEvents

Validation

  • cargo check -p openlogi-core
  • cargo fmt --check

Fixes mouse-button bindings for Volume Up/Down/Mute on macOS, where kVK_Volume* keyboard events are ignored by the system volume handler.

@greptile-apps

greptile-apps Bot commented Jun 8, 2026

Copy link
Copy Markdown

Greptile Summary

Review completed and submitted via submit_review tool.

Confidence Score: 5/5

Safe to merge.

No blocking issues found.

No files require special attention.

Reviews (2): Last reviewed commit: "fix(core): drain media-key NSEvent autor..." | Re-trigger Greptile

Comment thread crates/openlogi-core/src/binding.rs Outdated
Comment on lines +1004 to +1013
) else {
tracing::warn!(nx_key, phase, "NSEvent::otherEventWithType failed");
return;
};
let Some(cg_event) = ns_event.CGEvent() else {
tracing::warn!(nx_key, phase, "NSEvent::CGEvent failed");
return;
};
CGEvent::post(CGEventTapLocation::HIDEventTap, Some(&cg_event));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Early return can leave key-down posted without matching key-up

If the first iteration (key-down) posts successfully and the second iteration (key-up) then hits either NSEvent::otherEventWithType returning None or ns_event.CGEvent() returning None, the return exits the function entirely — leaving a key-down event in the system with no paired key-up. The post_click function in the same module handles this more gracefully with if let Ok. Using break instead of return in the failure branches would avoid posting orphaned key-down events for volume/media while still aborting any remaining work.

Fix in Codex Fix in Claude Code

@rwkyyy

rwkyyy commented Jun 11, 2026

Copy link
Copy Markdown

@AprilNEA can we get this merged please?

AprilNEA added 2 commits June 11, 2026 21:23
…dia-keys

# Conflicts:
#	crates/openlogi-core/Cargo.toml
post_media_key runs on the hook/gesture dispatch threads, which have no
run loop to drain autorelease pools, and NSEvent creation plus the
CGEvent getter both autorelease temporaries — every media/volume press
leaked them for the lifetime of the thread. Wrap the exchange in an
explicit objc2::rc::autoreleasepool, the same pattern (and reasoning)
as the hook's frontmost_bundle_id. This also puts the previously unused
direct objc2 dependency to use.
@AprilNEA AprilNEA merged commit c952f2f into AprilNEA:master Jun 12, 2026
8 checks passed
This was referenced Jun 12, 2026
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.

3 participants